New upstream version 1.11.0+dfsg
authorJochen Sprickerhof <git@jochen.sprickerhof.de>
Fri, 22 May 2020 16:29:43 +0000 (18:29 +0200)
committerJochen Sprickerhof <git@jochen.sprickerhof.de>
Fri, 22 May 2020 16:29:43 +0000 (18:29 +0200)
958 files changed:
.ci/azure-pipelines/azure-pipelines.yaml [new file with mode: 0644]
.ci/azure-pipelines/build-macos.yaml [new file with mode: 0644]
.ci/azure-pipelines/build-macos.yml [deleted file]
.ci/azure-pipelines/build-ubuntu-16-04.yaml [deleted file]
.ci/azure-pipelines/build-ubuntu-19-10.yaml [deleted file]
.ci/azure-pipelines/build-ubuntu.yaml [new file with mode: 0644]
.ci/azure-pipelines/build-windows.yaml [new file with mode: 0644]
.ci/azure-pipelines/build-windows.yml [deleted file]
.ci/azure-pipelines/documentation.yaml [new file with mode: 0644]
.ci/azure-pipelines/documentation.yml [deleted file]
.ci/azure-pipelines/env.yml [new file with mode: 0644]
.ci/azure-pipelines/formatting.yaml [new file with mode: 0644]
.ci/azure-pipelines/formatting.yml [deleted file]
.ci/azure-pipelines/tutorials.yaml [new file with mode: 0644]
.ci/azure-pipelines/tutorials.yml [deleted file]
.clang-format
.dev/docker/doc/Dockerfile
.dev/docker/env/Dockerfile
.dev/docker/fmt/Dockerfile
.dev/format.sh
.dev/scripts/generate_changelog.py [new file with mode: 0755]
.github/change_log.py [deleted file]
2d/include/pcl/2d/convolution.h
2d/include/pcl/2d/edge.h
2d/include/pcl/2d/impl/convolution.hpp
2d/include/pcl/2d/impl/edge.hpp
2d/include/pcl/2d/impl/kernel.hpp
2d/include/pcl/2d/impl/keypoint.hpp
2d/include/pcl/2d/impl/morphology.hpp
2d/include/pcl/2d/keypoint.h
2d/src/examples.cpp
AUTHORS.txt
CHANGES.md
CMakeLists.txt
CONTRIBUTING.md
README.md
apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h
apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp
apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp
apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp
apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h
apps/3d_rec_framework/src/tools/openni_frame_source.cpp
apps/CMakeLists.txt
apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp
apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h
apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp
apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp
apps/cloud_composer/src/commands.cpp
apps/cloud_composer/src/items/cloud_item.cpp
apps/cloud_composer/src/merge_selection.cpp
apps/cloud_composer/src/project_model.cpp
apps/cloud_composer/tools/euclidean_clustering.cpp
apps/cloud_composer/tools/sanitize_cloud.cpp
apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp
apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h
apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h
apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h
apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/visibility_confidence.h
apps/in_hand_scanner/src/icp.cpp
apps/include/pcl/apps/dominant_plane_segmentation.h
apps/include/pcl/apps/face_detection/face_detection_apps_utils.h
apps/include/pcl/apps/face_detection/openni_frame_source.h
apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp
apps/include/pcl/apps/manual_registration.h
apps/include/pcl/apps/nn_classification.h
apps/include/pcl/apps/openni_passthrough.h
apps/include/pcl/apps/openni_passthrough_qt.h
apps/include/pcl/apps/organized_segmentation_demo.h
apps/include/pcl/apps/organized_segmentation_demo_qt.h
apps/include/pcl/apps/pcd_video_player.h
apps/include/pcl/apps/render_views_tesselated_sphere.h
apps/include/pcl/apps/timer.h
apps/include/pcl/apps/vfh_nn_classifier.h
apps/modeler/include/pcl/apps/modeler/abstract_item.h
apps/modeler/include/pcl/apps/modeler/abstract_worker.h
apps/modeler/include/pcl/apps/modeler/channel_actor_item.h
apps/modeler/include/pcl/apps/modeler/cloud_mesh.h
apps/modeler/include/pcl/apps/modeler/cloud_mesh_item.h
apps/modeler/include/pcl/apps/modeler/cloud_mesh_item_updater.h
apps/modeler/include/pcl/apps/modeler/dock_widget.h
apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h
apps/modeler/include/pcl/apps/modeler/impl/parameter.hpp
apps/modeler/include/pcl/apps/modeler/impl/scene_tree.hpp
apps/modeler/include/pcl/apps/modeler/main_window.h
apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h
apps/modeler/include/pcl/apps/modeler/normals_actor_item.h
apps/modeler/include/pcl/apps/modeler/parameter.h
apps/modeler/include/pcl/apps/modeler/parameter_dialog.h
apps/modeler/include/pcl/apps/modeler/points_actor_item.h
apps/modeler/include/pcl/apps/modeler/poisson_worker.h
apps/modeler/include/pcl/apps/modeler/render_window.h
apps/modeler/include/pcl/apps/modeler/render_window_item.h
apps/modeler/include/pcl/apps/modeler/scene_tree.h
apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h
apps/modeler/include/pcl/apps/modeler/surface_actor_item.h
apps/modeler/include/pcl/apps/modeler/thread_controller.h
apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h
apps/modeler/src/abstract_item.cpp
apps/modeler/src/abstract_worker.cpp
apps/modeler/src/channel_actor_item.cpp
apps/modeler/src/cloud_mesh.cpp
apps/modeler/src/cloud_mesh_item.cpp
apps/modeler/src/cloud_mesh_item_updater.cpp
apps/modeler/src/dock_widget.cpp
apps/modeler/src/icp_registration_worker.cpp
apps/modeler/src/main.cpp
apps/modeler/src/main_window.cpp
apps/modeler/src/normal_estimation_worker.cpp
apps/modeler/src/normals_actor_item.cpp
apps/modeler/src/parameter.cpp
apps/modeler/src/parameter_dialog.cpp
apps/modeler/src/points_actor_item.cpp
apps/modeler/src/poisson_worker.cpp
apps/modeler/src/render_window.cpp
apps/modeler/src/render_window_item.cpp
apps/modeler/src/scene_tree.cpp
apps/modeler/src/statistical_outlier_removal_worker.cpp
apps/modeler/src/surface_actor_item.cpp
apps/modeler/src/thread_controller.cpp
apps/modeler/src/voxel_grid_downsample_worker.cpp
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h
apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h
apps/point_cloud_editor/src/cloudTransformTool.cpp
apps/point_cloud_editor/src/trackball.cpp
apps/src/convolve.cpp
apps/src/dinast_grabber_example.cpp
apps/src/dominant_plane_segmentation.cpp
apps/src/face_detection/face_trainer.cpp
apps/src/face_detection/filesystem_face_detection.cpp
apps/src/face_detection/openni_face_detection.cpp
apps/src/face_detection/openni_frame_source.cpp
apps/src/feature_matching.cpp
apps/src/grabcut_2d.cpp
apps/src/manual_registration/manual_registration.cpp
apps/src/multiscale_feature_persistence_example.cpp
apps/src/ni_agast.cpp
apps/src/ni_brisk.cpp
apps/src/ni_linemod.cpp
apps/src/ni_susan.cpp
apps/src/ni_trajkovic.cpp
apps/src/nn_classification_example.cpp
apps/src/openni_3d_concave_hull.cpp
apps/src/openni_3d_convex_hull.cpp
apps/src/openni_boundary_estimation.cpp
apps/src/openni_change_viewer.cpp
apps/src/openni_color_filter.cpp
apps/src/openni_fast_mesh.cpp
apps/src/openni_feature_persistence.cpp
apps/src/openni_grab_frame.cpp
apps/src/openni_grab_images.cpp
apps/src/openni_ii_normal_estimation.cpp
apps/src/openni_klt.cpp
apps/src/openni_mls_smoothing.cpp
apps/src/openni_mobile_server.cpp
apps/src/openni_octree_compression.cpp
apps/src/openni_organized_compression.cpp
apps/src/openni_organized_edge_detection.cpp
apps/src/openni_organized_multi_plane_segmentation.cpp
apps/src/openni_passthrough.cpp
apps/src/openni_planar_convex_hull.cpp
apps/src/openni_planar_segmentation.cpp
apps/src/openni_shift_to_depth_conversion.cpp
apps/src/openni_tracking.cpp
apps/src/openni_uniform_sampling.cpp
apps/src/openni_voxel_grid.cpp
apps/src/organized_segmentation_demo.cpp
apps/src/pcd_organized_edge_detection.cpp
apps/src/pcd_organized_multi_plane_segmentation.cpp
apps/src/pcd_select_object_plane.cpp
apps/src/pcd_video_player/pcd_video_player.cpp
apps/src/ppf_object_recognition.cpp
apps/src/pyramid_surface_matching.cpp
apps/src/render_views_tesselated_sphere.cpp
apps/src/statistical_multiscale_interest_region_extraction_example.cpp
apps/src/stereo_ground_segmentation.cpp
apps/src/surfel_smoothing_test.cpp
apps/src/test_search.cpp
cmake/Modules/FindClangFormat.cmake
cmake/Modules/Findlibusb-1.0.cmake
cmake/clang-format.cmake
cmake/pcl_targets.cmake
common/CMakeLists.txt
common/include/pcl/PCLHeader.h
common/include/pcl/PCLPointCloud2.h
common/include/pcl/PCLPointField.h
common/include/pcl/PointIndices.h
common/include/pcl/Vertices.h
common/include/pcl/common/boost.h
common/include/pcl/common/centroid.h
common/include/pcl/common/impl/accumulators.hpp
common/include/pcl/common/impl/bivariate_polynomial.hpp
common/include/pcl/common/impl/centroid.hpp
common/include/pcl/common/impl/copy_point.hpp
common/include/pcl/common/impl/eigen.hpp
common/include/pcl/common/impl/gaussian.hpp
common/include/pcl/common/impl/generate.hpp
common/include/pcl/common/impl/intensity.hpp
common/include/pcl/common/impl/intersections.hpp
common/include/pcl/common/impl/io.hpp
common/include/pcl/common/impl/norms.hpp
common/include/pcl/common/impl/pca.hpp
common/include/pcl/common/impl/piecewise_linear_function.hpp
common/include/pcl/common/impl/polynomial_calculations.hpp
common/include/pcl/common/impl/projection_matrix.hpp
common/include/pcl/common/impl/random.hpp
common/include/pcl/common/impl/spring.hpp
common/include/pcl/common/impl/transformation_from_correspondences.hpp
common/include/pcl/common/impl/transforms.hpp
common/include/pcl/common/impl/vector_average.hpp
common/include/pcl/common/io.h
common/include/pcl/common/point_operators.h [deleted file]
common/include/pcl/common/poses_from_matches.h
common/include/pcl/common/transformation_from_correspondences.h
common/include/pcl/common/utils.h
common/include/pcl/common/vector_average.h
common/include/pcl/conversions.h
common/include/pcl/correspondence.h
common/include/pcl/impl/point_types.hpp
common/include/pcl/make_shared.h
common/include/pcl/memory.h [new file with mode: 0644]
common/include/pcl/pcl_base.h
common/include/pcl/pcl_macros.h
common/include/pcl/point_cloud.h
common/include/pcl/point_representation.h
common/include/pcl/point_traits.h
common/include/pcl/point_types.h
common/include/pcl/range_image/bearing_angle_image.h
common/include/pcl/range_image/impl/range_image.hpp
common/include/pcl/range_image/impl/range_image_planar.hpp
common/include/pcl/range_image/impl/range_image_spherical.hpp
common/include/pcl/range_image/range_image.h
common/include/pcl/register_point_struct.h
common/include/pcl/type_traits.h [new file with mode: 0644]
common/include/pcl/types.h [new file with mode: 0644]
common/src/fft/kiss_fft.c
common/src/gaussian.cpp
common/src/range_image.cpp
cuda/apps/src/kinect_debayering.cpp
cuda/apps/src/kinect_dediscretize.cpp
cuda/apps/src/kinect_mapping.cpp
cuda/apps/src/kinect_normals_cuda.cpp
cuda/apps/src/kinect_planes_cuda.cpp
cuda/apps/src/kinect_ransac.cpp
cuda/apps/src/kinect_segmentation_cuda.cpp
cuda/apps/src/kinect_segmentation_planes_cuda.cpp
cuda/apps/src/kinect_tool_standalone.cpp
cuda/apps/src/kinect_viewer_cuda.cpp
cuda/common/include/pcl/cuda/common/point_type_rgb.h
cuda/common/include/pcl/cuda/pcl_cuda_base.h
cuda/common/include/pcl/cuda/point_cloud.h
cuda/nn/organized_neighbor_search.hpp
doc/advanced/CMakeLists.txt
doc/advanced/content/_templates/layout.html [deleted file]
doc/advanced/content/conf.py
doc/advanced/content/pcl_style_guide.rst
doc/doxygen/.gitignore [new file with mode: 0644]
doc/doxygen/CMakeLists.txt
doc/doxygen/doxyfile.in
doc/doxygen/pcl.doxy
doc/requirements.txt [new file with mode: 0644]
doc/tutorials/CMakeLists.txt
doc/tutorials/content/_templates/layout.html [deleted file]
doc/tutorials/content/adding_custom_ptype.rst
doc/tutorials/content/cluster_extraction.rst
doc/tutorials/content/conf.py
doc/tutorials/content/convex_hull_2d.rst
doc/tutorials/content/how_features_work.rst
doc/tutorials/content/hull_2d.rst
doc/tutorials/content/images/form_0.png [deleted file]
doc/tutorials/content/images/form_1.png [deleted file]
doc/tutorials/content/index.rst
doc/tutorials/content/kdtree_search.rst
doc/tutorials/content/normal_estimation.rst
doc/tutorials/content/passthrough.rst
doc/tutorials/content/planar_segmentation.rst
doc/tutorials/content/random_sample_consensus.rst
doc/tutorials/content/range_image_creation.rst
doc/tutorials/content/region_growing_segmentation.rst
doc/tutorials/content/remove_outliers.rst
doc/tutorials/content/resampling.rst
doc/tutorials/content/sources/bspline_fitting/CMakeLists.txt
doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp
doc/tutorials/content/sources/conditional_euclidean_clustering/CMakeLists.txt
doc/tutorials/content/sources/correspondence_grouping/CMakeLists.txt
doc/tutorials/content/sources/cylinder_segmentation/CMakeLists.txt
doc/tutorials/content/sources/don_segmentation/CMakeLists.txt
doc/tutorials/content/sources/ensenso_cameras/ensenso_cloud_images_viewer.cpp
doc/tutorials/content/sources/extract_indices/CMakeLists.txt
doc/tutorials/content/sources/global_hypothesis_verification/CMakeLists.txt
doc/tutorials/content/sources/gpu/people_detect/CMakeLists.txt.backup [deleted file]
doc/tutorials/content/sources/iccv2011/include/registration.h
doc/tutorials/content/sources/iccv2011/include/surface.h
doc/tutorials/content/sources/iccv2011/src/openni_capture.cpp
doc/tutorials/content/sources/iccv2011/src/tutorial.cpp
doc/tutorials/content/sources/implicit_shape_model/CMakeLists.txt
doc/tutorials/content/sources/iros2011/include/solution/registration.h
doc/tutorials/content/sources/iros2011/include/solution/surface.h
doc/tutorials/content/sources/iros2011/include/surface.h
doc/tutorials/content/sources/iros2011/src/openni_capture.cpp
doc/tutorials/content/sources/iterative_closest_point/iterative_closest_point.cpp
doc/tutorials/content/sources/min_cut_segmentation/CMakeLists.txt
doc/tutorials/content/sources/moment_of_inertia/CMakeLists.txt
doc/tutorials/content/sources/narf_descriptor_visualization/CMakeLists.txt
doc/tutorials/content/sources/narf_feature_extraction/CMakeLists.txt
doc/tutorials/content/sources/narf_keypoint_extraction/CMakeLists.txt
doc/tutorials/content/sources/openni_range_image_visualization/CMakeLists.txt
doc/tutorials/content/sources/pairwise_incremental_registration/pairwise_incremental_registration.cpp
doc/tutorials/content/sources/region_growing_segmentation/CMakeLists.txt
doc/tutorials/content/sources/registration_api/example2.cpp
doc/tutorials/content/sources/rops_feature/CMakeLists.txt
doc/tutorials/content/sources/stick_segmentation/stick_segmentation.cpp
doc/tutorials/content/sources/template_alignment/template_alignment.cpp
doc/tutorials/content/sources/voxel_grid/voxel_grid.cpp
doc/tutorials/content/statistical_outlier.rst
doc/tutorials/content/template_alignment.rst
doc/tutorials/content/walkthrough.rst
examples/common/example_check_if_point_is_valid.cpp
examples/common/example_copy_point_cloud.cpp
examples/common/example_get_max_min_coordinates.cpp
examples/features/example_difference_of_normals.cpp
examples/features/example_fast_point_feature_histograms.cpp
examples/features/example_normal_estimation.cpp
examples/features/example_point_feature_histograms.cpp
examples/features/example_principal_curvatures_estimation.cpp
examples/features/example_rift_estimation.cpp
examples/features/example_shape_contexts.cpp
examples/features/example_spin_images.cpp
examples/filters/example_extract_indices.cpp
examples/filters/example_remove_nan_from_point_cloud.cpp
examples/keypoints/example_get_keypoints_indices.cpp
examples/keypoints/example_sift_keypoint_estimation.cpp
examples/keypoints/example_sift_normal_keypoint_estimation.cpp
examples/keypoints/example_sift_z_keypoint_estimation.cpp
examples/outofcore/example_outofcore.cpp
examples/outofcore/example_outofcore_with_lod.cpp
examples/segmentation/example_cpc_segmentation.cpp
examples/segmentation/example_extract_clusters_normals.cpp
examples/segmentation/example_lccp_segmentation.cpp
examples/segmentation/example_region_growing.cpp
examples/segmentation/example_supervoxels.cpp
examples/surface/example_nurbs_fitting_closed_curve.cpp
examples/surface/example_nurbs_fitting_closed_curve3d.cpp
examples/surface/example_nurbs_fitting_curve2d.cpp
examples/surface/example_nurbs_fitting_surface.cpp
examples/surface/example_nurbs_viewer_surface.cpp
examples/surface/test_nurbs_fitting_surface.cpp
features/include/pcl/features/feature.h
features/include/pcl/features/from_meshes.h
features/include/pcl/features/gasd.h
features/include/pcl/features/impl/3dsc.hpp
features/include/pcl/features/impl/board.hpp
features/include/pcl/features/impl/boundary.hpp
features/include/pcl/features/impl/brisk_2d.hpp
features/include/pcl/features/impl/cppf.hpp
features/include/pcl/features/impl/feature.hpp
features/include/pcl/features/impl/flare.hpp
features/include/pcl/features/impl/fpfh.hpp
features/include/pcl/features/impl/fpfh_omp.hpp
features/include/pcl/features/impl/integral_image2D.hpp
features/include/pcl/features/impl/intensity_gradient.hpp
features/include/pcl/features/impl/normal_3d_omp.hpp
features/include/pcl/features/impl/pfh.hpp
features/include/pcl/features/impl/principal_curvatures.hpp
features/include/pcl/features/impl/shot_lrf_omp.hpp
features/include/pcl/features/impl/shot_omp.hpp
features/include/pcl/features/impl/usc.hpp
features/include/pcl/features/integral_image2D.h
features/include/pcl/features/integral_image_normal.h
features/include/pcl/features/moment_of_inertia_estimation.h
features/include/pcl/features/narf.h
features/include/pcl/features/normal_3d.h
features/include/pcl/features/rops_estimation.h
features/include/pcl/features/rsd.h
features/src/narf.cpp
features/src/range_image_border_extractor.cpp
filters/CMakeLists.txt
filters/include/pcl/filters/boost.h
filters/include/pcl/filters/box_clipper3D.h
filters/include/pcl/filters/clipper3D.h
filters/include/pcl/filters/conditional_removal.h
filters/include/pcl/filters/convolution.h
filters/include/pcl/filters/covariance_sampling.h
filters/include/pcl/filters/crop_box.h
filters/include/pcl/filters/filter.h
filters/include/pcl/filters/filter_indices.h
filters/include/pcl/filters/frustum_culling.h
filters/include/pcl/filters/impl/conditional_removal.hpp
filters/include/pcl/filters/impl/convolution.hpp
filters/include/pcl/filters/impl/convolution_3d.hpp
filters/include/pcl/filters/impl/crop_box.hpp
filters/include/pcl/filters/impl/fast_bilateral.hpp
filters/include/pcl/filters/impl/fast_bilateral_omp.hpp
filters/include/pcl/filters/impl/filter.hpp
filters/include/pcl/filters/impl/filter_indices.hpp
filters/include/pcl/filters/impl/frustum_culling.hpp
filters/include/pcl/filters/impl/local_maximum.hpp
filters/include/pcl/filters/impl/median_filter.hpp
filters/include/pcl/filters/impl/model_outlier_removal.hpp
filters/include/pcl/filters/impl/morphological_filter.hpp
filters/include/pcl/filters/impl/normal_space.hpp
filters/include/pcl/filters/impl/passthrough.hpp
filters/include/pcl/filters/impl/plane_clipper3D.hpp
filters/include/pcl/filters/impl/pyramid.hpp
filters/include/pcl/filters/impl/radius_outlier_removal.hpp
filters/include/pcl/filters/impl/random_sample.hpp
filters/include/pcl/filters/impl/sampling_surface_normal.hpp
filters/include/pcl/filters/impl/statistical_outlier_removal.hpp
filters/include/pcl/filters/impl/voxel_grid.hpp
filters/include/pcl/filters/model_outlier_removal.h
filters/include/pcl/filters/normal_refinement.h
filters/include/pcl/filters/normal_space.h
filters/include/pcl/filters/passthrough.h
filters/include/pcl/filters/pyramid.h
filters/include/pcl/filters/radius_outlier_removal.h
filters/include/pcl/filters/random_sample.h
filters/include/pcl/filters/statistical_outlier_removal.h
filters/src/convolution.cpp [new file with mode: 0644]
filters/src/filter_indices.cpp
filters/src/radius_outlier_removal.cpp
filters/src/voxel_grid.cpp
geometry/geometry.doxy
geometry/include/pcl/geometry/boost.h
geometry/include/pcl/geometry/mesh_base.h
geometry/include/pcl/geometry/planar_polygon.h
geometry/include/pcl/geometry/polygon_mesh.h
geometry/include/pcl/geometry/polygon_operations.h
geometry/include/pcl/geometry/quad_mesh.h
geometry/include/pcl/geometry/triangle_mesh.h
gpu/CMakeLists.txt
gpu/containers/include/pcl/gpu/containers/impl/device_array.hpp
gpu/containers/include/pcl/gpu/containers/impl/device_memory.hpp
gpu/examples/octree/src/octree_search.cpp
gpu/features/include/pcl/gpu/features/features.hpp
gpu/features/src/features.cpp
gpu/kinfu/include/pcl/gpu/kinfu/color_volume.h
gpu/kinfu/include/pcl/gpu/kinfu/kinfu.h
gpu/kinfu/include/pcl/gpu/kinfu/marching_cubes.h
gpu/kinfu/include/pcl/gpu/kinfu/raycaster.h
gpu/kinfu/include/pcl/gpu/kinfu/tsdf_volume.h
gpu/kinfu/src/kinfu.cpp
gpu/kinfu/src/tsdf_volume.cpp
gpu/kinfu/tools/camera_pose.h
gpu/kinfu/tools/evaluation.h
gpu/kinfu/tools/kinfu_app.cpp
gpu/kinfu/tools/kinfu_app_sim.cpp
gpu/kinfu/tools/record_tsdfvolume.cpp
gpu/kinfu/tools/tsdf_volume.h
gpu/kinfu/tools/tsdf_volume.hpp
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/color_volume.h
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/impl/standalone_marching_cubes.hpp
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/kinfu.h
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/marching_cubes.h
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/point_intensity.h
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/raycaster.h
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/screenshot_manager.h
gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/tsdf_volume.h
gpu/kinfu_large_scale/src/screenshot_manager.cpp
gpu/kinfu_large_scale/src/tsdf_volume.cpp
gpu/kinfu_large_scale/tools/evaluation.h
gpu/kinfu_large_scale/tools/kinfuLS_app.cpp
gpu/kinfu_large_scale/tools/kinfu_app_sim.cpp
gpu/kinfu_large_scale/tools/record_maps_rgb.cpp
gpu/kinfu_large_scale/tools/record_tsdfvolume.cpp
gpu/octree/include/pcl/gpu/octree/octree.hpp
gpu/octree/src/octree.cpp
gpu/octree/test/data_source.hpp
gpu/people/include/pcl/gpu/people/bodyparts_detector.h
gpu/people/include/pcl/gpu/people/face_detector.h
gpu/people/include/pcl/gpu/people/organized_plane_detector.h
gpu/people/include/pcl/gpu/people/person_attribs.h
gpu/people/src/cuda/nvidia/NCVHaarObjectDetection.hpp
gpu/people/src/cuda/nvidia/NPP_staging.hpp
gpu/people/src/cuda/shs.cu
gpu/people/src/face_detector.cpp
gpu/people/src/people_detector.cpp
gpu/people/src/trees.cpp
gpu/people/tools/people_pcd_prob.cpp
gpu/people/tools/people_tracking.cpp
gpu/surface/src/convex_hull.cpp
gpu/surface/src/internal.h
gpu/utils/include/pcl/gpu/utils/timers_cuda.hpp
io/CMakeLists.txt
io/include/pcl/compression/color_coding.h
io/include/pcl/compression/entropy_range_coder.h
io/include/pcl/compression/organized_pointcloud_conversion.h
io/include/pcl/compression/point_coding.h
io/include/pcl/io/ascii_io.h
io/include/pcl/io/boost.h
io/include/pcl/io/ensenso_grabber.h
io/include/pcl/io/grabber.h
io/include/pcl/io/hdl_grabber.h
io/include/pcl/io/image.h
io/include/pcl/io/image_grabber.h
io/include/pcl/io/image_ir.h
io/include/pcl/io/image_metadata_wrapper.h
io/include/pcl/io/impl/ascii_io.hpp
io/include/pcl/io/impl/buffers.hpp
io/include/pcl/io/impl/lzf_image_io.hpp
io/include/pcl/io/impl/point_cloud_image_extractors.hpp
io/include/pcl/io/impl/vtk_lib_io.hpp
io/include/pcl/io/obj_io.h
io/include/pcl/io/oni_grabber.h
io/include/pcl/io/openni2/openni2_device.h
io/include/pcl/io/openni2/openni2_device_manager.h
io/include/pcl/io/openni2_grabber.h
io/include/pcl/io/openni_camera/openni_depth_image.h
io/include/pcl/io/openni_camera/openni_device.h
io/include/pcl/io/openni_camera/openni_device_kinect.h
io/include/pcl/io/openni_camera/openni_device_oni.h
io/include/pcl/io/openni_camera/openni_device_primesense.h
io/include/pcl/io/openni_camera/openni_device_xtion.h
io/include/pcl/io/openni_camera/openni_driver.h
io/include/pcl/io/openni_camera/openni_image.h
io/include/pcl/io/openni_camera/openni_image_bayer_grbg.h
io/include/pcl/io/openni_camera/openni_image_rgb24.h
io/include/pcl/io/openni_camera/openni_image_yuv_422.h
io/include/pcl/io/openni_camera/openni_ir_image.h
io/include/pcl/io/openni_grabber.h
io/include/pcl/io/pcd_grabber.h
io/include/pcl/io/pcd_io.h
io/include/pcl/io/ply/ply_parser.h
io/include/pcl/io/ply_io.h
io/include/pcl/io/pxc_grabber.h [deleted file]
io/include/pcl/io/real_sense/real_sense_device_manager.h
io/include/pcl/io/real_sense_2_grabber.h
io/include/pcl/io/real_sense_grabber.h
io/include/pcl/io/robot_eye_grabber.h
io/src/ensenso_grabber.cpp
io/src/hdl_grabber.cpp
io/src/image_grabber.cpp
io/src/lzf.cpp
io/src/lzf_image_io.cpp
io/src/obj_io.cpp
io/src/oni_grabber.cpp
io/src/openni2/openni2_convert.cpp
io/src/openni2/openni2_device_manager.cpp
io/src/openni_camera/openni_device.cpp
io/src/openni_camera/openni_device_kinect.cpp
io/src/openni_camera/openni_device_oni.cpp
io/src/openni_camera/openni_device_primesense.cpp
io/src/openni_camera/openni_device_xtion.cpp
io/src/openni_camera/openni_image_bayer_grbg.cpp
io/src/openni_camera/openni_image_rgb24.cpp
io/src/openni_camera/openni_image_yuv_422.cpp
io/src/pcd_grabber.cpp
io/src/real_sense_2_grabber.cpp
io/src/robot_eye_grabber.cpp
io/tools/converter.cpp
io/tools/openni_grabber_example.cpp
kdtree/include/pcl/kdtree/flann.h
kdtree/include/pcl/kdtree/kdtree.h
keypoints/include/pcl/keypoints/agast_2d.h
keypoints/include/pcl/keypoints/brisk_2d.h
keypoints/include/pcl/keypoints/impl/agast_2d.hpp
keypoints/include/pcl/keypoints/impl/brisk_2d.hpp
keypoints/include/pcl/keypoints/impl/harris_2d.hpp
keypoints/include/pcl/keypoints/impl/harris_3d.hpp
keypoints/include/pcl/keypoints/impl/harris_6d.hpp
keypoints/include/pcl/keypoints/impl/iss_3d.hpp
keypoints/include/pcl/keypoints/impl/keypoint.hpp
keypoints/include/pcl/keypoints/impl/susan.hpp
keypoints/include/pcl/keypoints/impl/trajkovic_2d.hpp
keypoints/include/pcl/keypoints/impl/trajkovic_3d.hpp
keypoints/include/pcl/keypoints/narf_keypoint.h
keypoints/include/pcl/keypoints/uniform_sampling.h
keypoints/src/agast_2d.cpp
keypoints/src/narf_keypoint.cpp
ml/CMakeLists.txt
ml/include/pcl/ml/densecrf.h
ml/include/pcl/ml/dt/decision_forest.h
ml/include/pcl/ml/dt/decision_forest_evaluator.h
ml/include/pcl/ml/dt/decision_forest_trainer.h
ml/include/pcl/ml/dt/decision_tree_data_provider.h
ml/include/pcl/ml/dt/decision_tree_evaluator.h
ml/include/pcl/ml/dt/decision_tree_trainer.h
ml/include/pcl/ml/ferns/fern.h
ml/include/pcl/ml/ferns/fern_evaluator.h
ml/include/pcl/ml/ferns/fern_trainer.h
ml/include/pcl/ml/impl/dt/decision_forest_evaluator.hpp
ml/include/pcl/ml/impl/dt/decision_forest_trainer.hpp
ml/include/pcl/ml/impl/dt/decision_tree_evaluator.hpp
ml/include/pcl/ml/impl/dt/decision_tree_trainer.hpp
ml/include/pcl/ml/impl/ferns/fern_evaluator.hpp
ml/include/pcl/ml/impl/ferns/fern_trainer.hpp
ml/include/pcl/ml/impl/kmeans.hpp
ml/include/pcl/ml/kmeans.h
ml/include/pcl/ml/multi_channel_2d_comparison_feature_handler.h
ml/include/pcl/ml/pairwise_potential.h
ml/include/pcl/ml/permutohedral.h
ml/include/pcl/ml/svm_wrapper.h
ml/src/densecrf.cpp
ml/src/svm.cpp
ml/src/svm_wrapper.cpp
octree/include/pcl/octree/impl/octree_base.hpp
octree/include/pcl/octree/impl/octree_pointcloud.hpp
octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp
octree/include/pcl/octree/impl/octree_search.hpp
octree/include/pcl/octree/octree.h
octree/include/pcl/octree/octree2buf_base.h
octree/include/pcl/octree/octree_base.h
octree/include/pcl/octree/octree_container.h
octree/include/pcl/octree/octree_impl.h
octree/include/pcl/octree/octree_iterator.h
octree/include/pcl/octree/octree_key.h
octree/include/pcl/octree/octree_node_pool.h
octree/include/pcl/octree/octree_nodes.h
octree/include/pcl/octree/octree_pointcloud.h
octree/include/pcl/octree/octree_pointcloud_changedetector.h
octree/include/pcl/octree/octree_search.h
outofcore/include/pcl/outofcore/impl/octree_base.hpp
outofcore/include/pcl/outofcore/impl/octree_base_node.hpp
outofcore/include/pcl/outofcore/octree_base.h
outofcore/include/pcl/outofcore/octree_base_node.h
outofcore/include/pcl/outofcore/outofcore_base_data.h
outofcore/include/pcl/outofcore/outofcore_node_data.h
outofcore/include/pcl/outofcore/visualization/camera.h
outofcore/include/pcl/outofcore/visualization/outofcore_cloud.h
outofcore/tools/outofcore_viewer.cpp
people/include/pcl/people/hog.h
people/src/hog.cpp
recognition/include/pcl/recognition/3rdparty/metslib/termination-criteria.hh
recognition/include/pcl/recognition/auxiliary.h [deleted file]
recognition/include/pcl/recognition/bvh.h [deleted file]
recognition/include/pcl/recognition/cg/hough_3d.h
recognition/include/pcl/recognition/face_detection/face_common.h
recognition/include/pcl/recognition/face_detection/face_detector_data_provider.h
recognition/include/pcl/recognition/impl/cg/correspondence_grouping.hpp
recognition/include/pcl/recognition/impl/hv/hv_go.hpp
recognition/include/pcl/recognition/impl/implicit_shape_model.hpp
recognition/include/pcl/recognition/impl/linemod/line_rgbd.hpp
recognition/include/pcl/recognition/impl/ransac_based/simple_octree.hpp
recognition/include/pcl/recognition/impl/ransac_based/voxel_structure.hpp
recognition/include/pcl/recognition/implicit_shape_model.h
recognition/include/pcl/recognition/mask_map.h
recognition/include/pcl/recognition/model_library.h [deleted file]
recognition/include/pcl/recognition/obj_rec_ransac.h [deleted file]
recognition/include/pcl/recognition/orr_graph.h [deleted file]
recognition/include/pcl/recognition/orr_octree.h [deleted file]
recognition/include/pcl/recognition/orr_octree_zprojection.h [deleted file]
recognition/include/pcl/recognition/point_types.h
recognition/include/pcl/recognition/ransac_based/bvh.h
recognition/include/pcl/recognition/ransac_based/orr_octree.h
recognition/include/pcl/recognition/ransac_based/voxel_structure.h
recognition/include/pcl/recognition/rigid_transform_space.h [deleted file]
recognition/include/pcl/recognition/simple_octree.h [deleted file]
recognition/include/pcl/recognition/sparse_quantized_multi_mod_template.h
recognition/include/pcl/recognition/trimmed_icp.h [deleted file]
recognition/include/pcl/recognition/voxel_structure.h [deleted file]
recognition/src/face_detection/face_detector_data_provider.cpp
recognition/src/face_detection/rf_face_detector_trainer.cpp
recognition/src/mask_map.cpp
recognition/src/ransac_based/orr_octree.cpp
recognition/src/ransac_based/orr_octree_zprojection.cpp
registration/include/pcl/registration/bfgs.h
registration/include/pcl/registration/boost.h
registration/include/pcl/registration/convergence_criteria.h
registration/include/pcl/registration/correspondence_estimation.h
registration/include/pcl/registration/correspondence_estimation_organized_projection.h
registration/include/pcl/registration/correspondence_rejection.h
registration/include/pcl/registration/correspondence_rejection_distance.h
registration/include/pcl/registration/correspondence_rejection_median_distance.h
registration/include/pcl/registration/correspondence_rejection_organized_boundary.h
registration/include/pcl/registration/correspondence_rejection_poly.h
registration/include/pcl/registration/correspondence_rejection_sample_consensus.h
registration/include/pcl/registration/correspondence_rejection_sample_consensus_2d.h
registration/include/pcl/registration/correspondence_rejection_surface_normal.h
registration/include/pcl/registration/correspondence_rejection_trimmed.h
registration/include/pcl/registration/correspondence_rejection_var_trimmed.h
registration/include/pcl/registration/default_convergence_criteria.h
registration/include/pcl/registration/edge_measurements.h
registration/include/pcl/registration/elch.h
registration/include/pcl/registration/gicp.h
registration/include/pcl/registration/gicp6d.h
registration/include/pcl/registration/ia_ransac.h
registration/include/pcl/registration/icp.h
registration/include/pcl/registration/impl/correspondence_estimation.hpp
registration/include/pcl/registration/impl/correspondence_estimation_backprojection.hpp
registration/include/pcl/registration/impl/correspondence_estimation_normal_shooting.hpp
registration/include/pcl/registration/impl/correspondence_estimation_organized_projection.hpp
registration/include/pcl/registration/impl/correspondence_rejection_features.hpp
registration/include/pcl/registration/impl/correspondence_rejection_poly.hpp
registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus.hpp
registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus_2d.hpp
registration/include/pcl/registration/impl/correspondence_types.hpp
registration/include/pcl/registration/impl/default_convergence_criteria.hpp
registration/include/pcl/registration/impl/gicp.hpp
registration/include/pcl/registration/impl/ia_fpcs.hpp
registration/include/pcl/registration/impl/ia_kfpcs.hpp
registration/include/pcl/registration/impl/ia_ransac.hpp
registration/include/pcl/registration/impl/icp.hpp
registration/include/pcl/registration/impl/incremental_registration.hpp
registration/include/pcl/registration/impl/joint_icp.hpp
registration/include/pcl/registration/impl/lum.hpp
registration/include/pcl/registration/impl/meta_registration.hpp
registration/include/pcl/registration/impl/ndt.hpp
registration/include/pcl/registration/impl/ndt_2d.hpp
registration/include/pcl/registration/impl/pairwise_graph_registration.hpp
registration/include/pcl/registration/impl/pyramid_feature_matching.hpp
registration/include/pcl/registration/impl/registration.hpp
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
registration/include/pcl/registration/impl/transformation_estimation_2D.hpp
registration/include/pcl/registration/impl/transformation_estimation_dq.hpp
registration/include/pcl/registration/impl/transformation_estimation_dual_quaternion.hpp
registration/include/pcl/registration/impl/transformation_estimation_point_to_plane_lls.hpp
registration/include/pcl/registration/impl/transformation_estimation_point_to_plane_lls_weighted.hpp
registration/include/pcl/registration/impl/transformation_estimation_svd.hpp
registration/include/pcl/registration/impl/transformation_estimation_svd_scale.hpp
registration/include/pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp
registration/include/pcl/registration/impl/transformation_validation_euclidean.hpp
registration/include/pcl/registration/lum.h
registration/include/pcl/registration/matching_candidate.h
registration/include/pcl/registration/meta_registration.h
registration/include/pcl/registration/ndt.h
registration/include/pcl/registration/ndt_2d.h
registration/include/pcl/registration/ppf_registration.h
registration/include/pcl/registration/registration.h
registration/include/pcl/registration/transformation_estimation_lm.h
registration/include/pcl/registration/transformation_estimation_point_to_plane_weighted.h
registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h
registration/include/pcl/registration/transformation_validation_euclidean.h
registration/include/pcl/registration/warp_point_rigid.h
registration/src/correspondence_rejection_organized_boundary.cpp
registration/src/correspondence_rejection_var_trimmed.cpp
registration/src/gicp6d.cpp
sample_consensus/include/pcl/sample_consensus/impl/lmeds.hpp
sample_consensus/include/pcl/sample_consensus/impl/mlesac.hpp
sample_consensus/include/pcl/sample_consensus/impl/msac.hpp
sample_consensus/include/pcl/sample_consensus/impl/prosac.hpp
sample_consensus/include/pcl/sample_consensus/impl/ransac.hpp
sample_consensus/include/pcl/sample_consensus/impl/rmsac.hpp
sample_consensus/include/pcl/sample_consensus/impl/rransac.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle3d.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_line.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_parallel_plane.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_plane.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_sphere.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_line.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_plane.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_perpendicular_plane.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_registration.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_registration_2d.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp
sample_consensus/include/pcl/sample_consensus/impl/sac_model_stick.hpp
sample_consensus/include/pcl/sample_consensus/sac.h
sample_consensus/include/pcl/sample_consensus/sac_model.h
sample_consensus/include/pcl/sample_consensus/sac_model_circle.h
sample_consensus/include/pcl/sample_consensus/sac_model_circle3d.h
sample_consensus/include/pcl/sample_consensus/sac_model_cone.h
sample_consensus/include/pcl/sample_consensus/sac_model_cylinder.h
sample_consensus/include/pcl/sample_consensus/sac_model_line.h
sample_consensus/include/pcl/sample_consensus/sac_model_normal_parallel_plane.h
sample_consensus/include/pcl/sample_consensus/sac_model_normal_plane.h
sample_consensus/include/pcl/sample_consensus/sac_model_normal_sphere.h
sample_consensus/include/pcl/sample_consensus/sac_model_parallel_line.h
sample_consensus/include/pcl/sample_consensus/sac_model_parallel_plane.h
sample_consensus/include/pcl/sample_consensus/sac_model_perpendicular_plane.h
sample_consensus/include/pcl/sample_consensus/sac_model_plane.h
sample_consensus/include/pcl/sample_consensus/sac_model_registration.h
sample_consensus/include/pcl/sample_consensus/sac_model_registration_2d.h
sample_consensus/include/pcl/sample_consensus/sac_model_sphere.h
sample_consensus/include/pcl/sample_consensus/sac_model_stick.h
search/include/pcl/search/brute_force.h
search/include/pcl/search/flann_search.h
search/include/pcl/search/impl/brute_force.hpp
search/include/pcl/search/impl/flann_search.hpp
search/include/pcl/search/impl/kdtree.hpp
search/include/pcl/search/impl/organized.hpp
search/include/pcl/search/impl/search.hpp
search/include/pcl/search/kdtree.h
search/include/pcl/search/octree.h
search/include/pcl/search/organized.h
search/include/pcl/search/search.h
segmentation/include/pcl/segmentation/boost.h
segmentation/include/pcl/segmentation/comparator.h
segmentation/include/pcl/segmentation/conditional_euclidean_clustering.h
segmentation/include/pcl/segmentation/cpc_segmentation.h
segmentation/include/pcl/segmentation/crf_normal_segmentation.h
segmentation/include/pcl/segmentation/crf_segmentation.h
segmentation/include/pcl/segmentation/edge_aware_plane_comparator.h
segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h
segmentation/include/pcl/segmentation/grabcut_segmentation.h
segmentation/include/pcl/segmentation/ground_plane_comparator.h
segmentation/include/pcl/segmentation/impl/approximate_progressive_morphological_filter.hpp
segmentation/include/pcl/segmentation/impl/crf_segmentation.hpp
segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp
segmentation/include/pcl/segmentation/impl/lccp_segmentation.hpp
segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp
segmentation/include/pcl/segmentation/impl/organized_multi_plane_segmentation.hpp
segmentation/include/pcl/segmentation/impl/region_growing.hpp
segmentation/include/pcl/segmentation/impl/sac_segmentation.hpp
segmentation/include/pcl/segmentation/impl/segment_differences.hpp
segmentation/include/pcl/segmentation/lccp_segmentation.h
segmentation/include/pcl/segmentation/min_cut_segmentation.h
segmentation/include/pcl/segmentation/organized_multi_plane_segmentation.h
segmentation/include/pcl/segmentation/planar_region.h
segmentation/include/pcl/segmentation/plane_coefficient_comparator.h
segmentation/include/pcl/segmentation/plane_refinement_comparator.h
segmentation/include/pcl/segmentation/region_3d.h
segmentation/include/pcl/segmentation/region_growing.h
segmentation/include/pcl/segmentation/region_growing_rgb.h
segmentation/include/pcl/segmentation/sac_segmentation.h
segmentation/include/pcl/segmentation/segment_differences.h
segmentation/include/pcl/segmentation/supervoxel_clustering.h
segmentation/include/pcl/segmentation/unary_classifier.h
simulation/include/pcl/simulation/camera.h
simulation/include/pcl/simulation/glsl_shader.h
simulation/include/pcl/simulation/model.h
simulation/include/pcl/simulation/range_likelihood.h
simulation/include/pcl/simulation/scene.h
simulation/include/pcl/simulation/sum_reduce.h
simulation/src/camera.cpp
simulation/src/glsl_shader.cpp
simulation/src/model.cpp
simulation/src/range_likelihood.cpp
simulation/tools/sim_terminal_demo.cpp
simulation/tools/sim_test_performance.cpp
simulation/tools/sim_test_simple.cpp
simulation/tools/sim_viewer.cpp
simulation/tools/simulation_io.cpp
simulation/tools/simulation_io.hpp
stereo/include/pcl/stereo/digital_elevation_map.h
stereo/include/pcl/stereo/disparity_map_converter.h
stereo/include/pcl/stereo/impl/disparity_map_converter.hpp
stereo/include/pcl/stereo/stereo_grabber.h
stereo/include/pcl/stereo/stereo_matching.h
stereo/src/digital_elevation_map.cpp
stereo/src/stereo_grabber.cpp
surface/CMakeLists.txt
surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_array_defs.h
surface/include/pcl/surface/3rdparty/poisson4/bspline_data.h
surface/include/pcl/surface/3rdparty/poisson4/bspline_data.hpp
surface/include/pcl/surface/3rdparty/poisson4/function_data.hpp
surface/include/pcl/surface/3rdparty/poisson4/geometry.hpp
surface/include/pcl/surface/3rdparty/poisson4/mat.hpp
surface/include/pcl/surface/3rdparty/poisson4/multi_grid_octree_data.hpp
surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
surface/include/pcl/surface/3rdparty/poisson4/polynomial.hpp
surface/include/pcl/surface/3rdparty/poisson4/ppolynomial.hpp
surface/include/pcl/surface/bilateral_upsampling.h
surface/include/pcl/surface/boost.h
surface/include/pcl/surface/convex_hull.h
surface/include/pcl/surface/grid_projection.h
surface/include/pcl/surface/impl/mls.hpp
surface/include/pcl/surface/impl/processing.hpp
surface/include/pcl/surface/impl/reconstruction.hpp
surface/include/pcl/surface/impl/texture_mapping.hpp
surface/include/pcl/surface/marching_cubes.h
surface/include/pcl/surface/marching_cubes_hoppe.h
surface/include/pcl/surface/marching_cubes_rbf.h
surface/include/pcl/surface/mls.h
surface/include/pcl/surface/on_nurbs/fitting_cylinder_pdm.h
surface/include/pcl/surface/on_nurbs/fitting_sphere_pdm.h
surface/include/pcl/surface/on_nurbs/fitting_surface_im.h
surface/include/pcl/surface/on_nurbs/fitting_surface_pdm.h
surface/include/pcl/surface/on_nurbs/nurbs_data.h
surface/include/pcl/surface/on_nurbs/nurbs_solve.h
surface/include/pcl/surface/on_nurbs/sequential_fitter.h
surface/include/pcl/surface/organized_fast_mesh.h
surface/include/pcl/surface/poisson.h
surface/include/pcl/surface/simplification_remove_unused_vertices.h
surface/include/pcl/surface/texture_mapping.h
surface/include/pcl/surface/vtk_smoothing/vtk_mesh_quadric_decimation.h
surface/include/pcl/surface/vtk_smoothing/vtk_mesh_smoothing_laplacian.h
surface/include/pcl/surface/vtk_smoothing/vtk_mesh_smoothing_windowed_sinc.h
surface/src/3rdparty/opennurbs/opennurbs_annotation2.cpp
surface/src/3rdparty/opennurbs/opennurbs_evaluate_nurbs.cpp
surface/src/3rdparty/poisson4/bspline_data.cpp [new file with mode: 0644]
surface/src/on_nurbs/sequential_fitter.cpp
test/2d/CMakeLists.txt
test/2d/keypoint_instantiation.cpp [new file with mode: 0644]
test/2d/test_2d.cpp
test/CMakeLists.txt
test/common/test_intensity.cpp
test/common/test_io.cpp
test/common/test_operators.cpp
test/common/test_transforms.cpp
test/common/test_type_traits.cpp
test/features/test_normal_estimation.cpp
test/filters/test_clipper.cpp
test/filters/test_filters.cpp
test/filters/test_sampling.cpp
test/geometry/test_mesh_circulators.cpp
test/geometry/test_mesh_conversion.cpp
test/io/test_io.cpp
test/io/test_octree_compression.cpp
test/io/test_ply_mesh_io.cpp
test/kdtree/test_kdtree.cpp
test/registration/test_registration.cpp
test/search/test_auto_search.cpp
test/search/test_flann_search.cpp
test/search/test_kdtree.cpp
test/search/test_octree.cpp
test/search/test_organized_index.cpp
test/search/test_search.cpp
test/test_recognition_ransac_based_ORROctree.cpp
test/visualization/test_visualization.cpp
tools/CMakeLists.txt
tools/boost.h
tools/cluster_extraction.cpp
tools/depth_sense_viewer.cpp
tools/fast_bilateral_filter.cpp
tools/normal_estimation.cpp
tools/oni_viewer_simple.cpp
tools/openni_viewer_simple.cpp
tools/organized_pcd_to_png.cpp [deleted file]
tools/real_sense_viewer.cpp
tools/virtual_scanner.cpp
tracking/include/pcl/tracking/boost.h
tracking/include/pcl/tracking/distance_coherence.h
tracking/include/pcl/tracking/impl/kld_adaptive_particle_filter_omp.hpp
tracking/include/pcl/tracking/impl/particle_filter_omp.hpp
tracking/include/pcl/tracking/impl/pyramidal_klt.hpp
tracking/include/pcl/tracking/impl/tracking.hpp
tracking/include/pcl/tracking/particle_filter.h
tracking/include/pcl/tracking/pyramidal_klt.h
tracking/include/pcl/tracking/tracker.h
tracking/include/pcl/tracking/tracking.h
visualization/CMakeLists.txt
visualization/include/pcl/visualization/boost.h
visualization/include/pcl/visualization/common/common.h
visualization/include/pcl/visualization/common/impl/common.hpp
visualization/include/pcl/visualization/common/impl/shapes.hpp
visualization/include/pcl/visualization/image_viewer.h
visualization/include/pcl/visualization/impl/histogram_visualizer.hpp
visualization/include/pcl/visualization/impl/pcl_plotter.hpp
visualization/include/pcl/visualization/impl/pcl_visualizer.hpp
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
visualization/include/pcl/visualization/impl/point_cloud_geometry_handlers.hpp
visualization/include/pcl/visualization/impl/registration_visualizer.hpp
visualization/include/pcl/visualization/pcl_painter2D.h
visualization/include/pcl/visualization/pcl_plotter.h
visualization/include/pcl/visualization/pcl_visualizer.h
visualization/include/pcl/visualization/point_cloud_color_handlers.h
visualization/include/pcl/visualization/point_picking_event.h
visualization/include/pcl/visualization/vtk/vtkVertexBufferObject.h
visualization/include/pcl/visualization/vtk/vtkVertexBufferObjectMapper.h
visualization/src/cloud_viewer.cpp
visualization/src/common/io.cpp
visualization/src/pcl_painter2D.cpp
visualization/src/pcl_plotter.cpp
visualization/src/pcl_visualizer.cpp
visualization/src/point_cloud_handlers.cpp
visualization/src/point_picking_event.cpp

diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml
new file mode 100644 (file)
index 0000000..77796e3
--- /dev/null
@@ -0,0 +1,42 @@
+resources:
+  containers:
+    - container: fmt
+      image: pointcloudlibrary/fmt
+    - container: env1604
+      image: pointcloudlibrary/env:16.04
+    - container: env2004
+      image: pointcloudlibrary/env:20.04
+    - container: doc
+      image: pointcloudlibrary/doc
+
+stages:
+  - stage: formatting
+    displayName: Formatting
+    jobs:
+      - template: formatting.yaml
+  - stage: build_ubuntu
+    displayName: Build Ubuntu
+    dependsOn: formatting
+    jobs:
+      - template: build-ubuntu.yaml
+  - stage: build_osx
+    displayName: Build macOS
+    dependsOn: formatting
+    jobs:
+      - template: build-macos.yaml
+  - stage: build_windows
+    displayName: Build Windows
+    dependsOn: formatting
+    jobs:
+      - template: build-windows.yaml
+  - stage: documentation
+    displayName: Documentation
+    dependsOn: []
+    jobs:
+      - template: documentation.yaml
+  - stage: tutorials
+    displayName: Tutorials
+    dependsOn: build_ubuntu
+    jobs:
+      - template: tutorials.yaml
+      
diff --git a/.ci/azure-pipelines/build-macos.yaml b/.ci/azure-pipelines/build-macos.yaml
new file mode 100644 (file)
index 0000000..6176b51
--- /dev/null
@@ -0,0 +1,65 @@
+jobs:
+  - job: osx
+    displayName: macOS
+    pool:
+      vmImage: '$(VMIMAGE)'
+    strategy:
+      matrix:
+        Catalina 10.15:
+          VMIMAGE: 'macOS-10.15'
+          OSX_VERSION: '10.15'
+        Mojave 10.14:
+          VMIMAGE: 'macOS-10.14'
+          OSX_VERSION: '10.14'
+    timeoutInMinutes: 0
+    variables:
+      BUILD_DIR: '$(Agent.WorkFolder)/build'
+      GOOGLE_TEST_DIR: '$(Agent.WorkFolder)/googletest'
+      CMAKE_CXX_FLAGS: '-Wall -Wextra -Werror -Wabi'
+    steps:
+      - checkout: self
+        # find the commit hash on a quick non-forced update too
+        fetchDepth: 10
+      - script: |
+          brew install pkg-config qt5 libpcap brewsci/science/openni libomp
+          brew install vtk --with-qt --without-python@2
+          brew install --only-dependencies pcl
+          git clone https://github.com/abseil/googletest.git $GOOGLE_TEST_DIR # the official endpoint changed to abseil/googletest
+          cd $GOOGLE_TEST_DIR && git checkout release-1.8.1
+        displayName: 'Install Dependencies'
+      - script: |
+          mkdir $BUILD_DIR && cd $BUILD_DIR
+          # Surface switched off due to OpenGL deprecation on Mac
+          cmake $(Build.SourcesDirectory) \
+            -DCMAKE_BUILD_TYPE="Release" \
+            -DCMAKE_OSX_SYSROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX$(OSX_VERSION).sdk" \
+            -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
+            -DGTEST_SRC_DIR="$GOOGLE_TEST_DIR/googletest" \
+            -DGTEST_INCLUDE_DIR="$GOOGLE_TEST_DIR/googletest/include" \
+            -DQt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5 \
+            -DPCL_ONLY_CORE_POINT_TYPES=ON \
+            -DBUILD_simulation=ON \
+            -DBUILD_surface=OFF \
+            -DBUILD_global_tests=ON \
+            -DBUILD_examples=ON \
+            -DBUILD_tools=ON \
+            -DBUILD_apps=ON \
+            -DBUILD_apps_3d_rec_framework=ON \
+            -DBUILD_apps_cloud_composer=ON \
+            -DBUILD_apps_in_hand_scanner=ON \
+            -DBUILD_apps_modeler=ON \
+            -DBUILD_apps_point_cloud_editor=ON
+        displayName: 'CMake Configuration'
+      - script: |
+          cd $BUILD_DIR
+          cmake --build . -- -j2
+        displayName: 'Build Library'
+      - script: cd $BUILD_DIR && cmake --build . -- tests
+        displayName: 'Run Unit Tests'
+      - task: PublishTestResults@2
+        inputs:
+          testResultsFormat: 'CTest'
+          testResultsFiles: '**/Test*.xml'
+          searchFolder: '$(Agent.WorkFolder)/build'
+        condition: succeededOrFailed()
+
diff --git a/.ci/azure-pipelines/build-macos.yml b/.ci/azure-pipelines/build-macos.yml
deleted file mode 100644 (file)
index cba9156..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-jobs:
-  - job: osx
-    strategy:
-      matrix:
-        macOS Catalina:
-          VMIMAGE: 'macOS-10.15'
-        macOS Mojave:
-          VMIMAGE: 'macOS-10.14'
-    timeoutInMinutes: 0
-    pool:
-      vmImage: '$(VMIMAGE)'
-    variables:
-      BUILD_DIR: '$(Agent.WorkFolder)/build'
-      GOOGLE_TEST_DIR: '$(Agent.WorkFolder)/googletest'
-      CMAKE_CXX_FLAGS: '-Wall -Wextra -Wabi -O2'
-    steps:
-      - script: |
-          brew install pkg-config qt5 libpcap brewsci/science/openni
-          brew install vtk --with-qt --without-python@2
-          brew install --only-dependencies pcl
-          git clone https://github.com/abseil/googletest.git $GOOGLE_TEST_DIR # the official endpoint changed to abseil/googletest
-          cd $GOOGLE_TEST_DIR && git checkout release-1.8.1
-        displayName: 'Install Dependencies'
-      - script: |
-          mkdir $BUILD_DIR && cd $BUILD_DIR
-          cmake $(Build.SourcesDirectory) \
-            -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" \
-            -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
-            -DGTEST_SRC_DIR="$GOOGLE_TEST_DIR/googletest" \
-            -DGTEST_INCLUDE_DIR="$GOOGLE_TEST_DIR/googletest/include" \
-            -DQt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5 \
-            -DPCL_ONLY_CORE_POINT_TYPES=ON \
-            -DBUILD_simulation=ON \
-            -DBUILD_surface=OFF \
-            -DBUILD_global_tests=ON \
-            -DBUILD_examples=ON \
-            -DBUILD_tools=ON \
-            -DBUILD_apps=ON \
-            -DBUILD_apps_3d_rec_framework=ON \
-            -DBUILD_apps_cloud_composer=ON \
-            -DBUILD_apps_in_hand_scanner=ON \
-            -DBUILD_apps_modeler=ON \
-            -DBUILD_apps_point_cloud_editor=ON
-        displayName: 'CMake Configuration'
-      - script: |
-          cd $BUILD_DIR
-          # Compiling some of the test targets with -j2 option leads to pipeline failures
-          # (presumably out of memory error). Thus we make them separately in a single
-          # thread mode. Their corresponding modules are built before with the -j2 mode
-          # to make the process faster.
-          cmake --build . -- -j2 pcl_filters pcl_registration
-          cmake --build . -- test_filters test_registration test_registration_api
-          cmake --build . -- -j2
-        displayName: 'Build Library'
-      - script: cd $BUILD_DIR && cmake --build . -- tests
-        displayName: 'Run Unit Tests'
-      - task: PublishTestResults@2
-        inputs:
-          testResultsFormat: 'CTest'
-          testResultsFiles: '**/Test*.xml'
-          searchFolder: '$(Agent.WorkFolder)/build'
-        condition: succeededOrFailed()
-
diff --git a/.ci/azure-pipelines/build-ubuntu-16-04.yaml b/.ci/azure-pipelines/build-ubuntu-16-04.yaml
deleted file mode 100644 (file)
index 837a8ea..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-resources:
-  containers:
-    - container: env1604
-      image: pointcloudlibrary/env:16.04
-
-jobs:
-  - job: ubuntu1604
-    displayName: Ubuntu 16.04
-    timeoutInMinutes: 0
-    pool:
-      vmImage: 'Ubuntu 16.04'
-    container: env1604
-    variables:
-      BUILD_DIR: '$(Agent.BuildDirectory)/build'
-    steps:
-      - script: |
-          mkdir $BUILD_DIR && cd $BUILD_DIR
-          cmake $(Build.SourcesDirectory) \
-            -DPCL_ONLY_CORE_POINT_TYPES=ON \
-            -DPCL_WARNINGS_ARE_ERRORS=ON \
-            -DBUILD_simulation=ON \
-            -DBUILD_surface_on_nurbs=ON \
-            -DBUILD_global_tests=ON \
-            -DBUILD_examples=ON \
-            -DBUILD_tools=ON \
-            -DBUILD_apps=ON \
-            -DBUILD_apps_3d_rec_framework=ON \
-            -DBUILD_apps_cloud_composer=ON \
-            -DBUILD_apps_in_hand_scanner=ON \
-            -DBUILD_apps_modeler=ON \
-            -DBUILD_apps_point_cloud_editor=ON
-        displayName: 'CMake Configuration'
-      - script: |
-          cd $BUILD_DIR
-          # Compiling some of the test targets with -j2 option leads to pipeline failures
-          # (presumably out of memory error). Thus we make them separately in a single
-          # thread mode. Their corresponding modules are built before with the -j2 mode
-          # to make the process faster.
-          cmake --build . -- -j2 pcl_filters pcl_registration
-          cmake --build . -- test_filters test_registration test_registration_api
-          cmake --build . -- -j2
-        displayName: 'Build Library'
-      - script: |
-          cd $BUILD_DIR && cmake --build . -- tests
-        displayName: 'Run Unit Tests'
-      - task: PublishTestResults@2
-        inputs:
-          testResultsFormat: 'CTest'
-          testResultsFiles: '**/Test*.xml'
-          searchFolder: '$(Agent.BuildDirectory)/build'
-        condition: succeededOrFailed()
diff --git a/.ci/azure-pipelines/build-ubuntu-19-10.yaml b/.ci/azure-pipelines/build-ubuntu-19-10.yaml
deleted file mode 100644 (file)
index 0dd77e0..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-resources:
-  containers:
-    - container: env1910
-      image: pointcloudlibrary/env:19.10
-
-jobs:
-  - job: ubuntu1910
-    displayName: Ubuntu 19.10
-    timeoutInMinutes: 0
-    pool:
-      vmImage: 'Ubuntu 16.04'
-    container: env1910
-    variables:
-      BUILD_DIR: '$(Agent.BuildDirectory)/build'
-      CMAKE_CXX_FLAGS: '-Wall -Wextra -O2'
-    steps:
-      - script: |
-          mkdir $BUILD_DIR && cd $BUILD_DIR
-          cmake $(Build.SourcesDirectory) \
-            -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
-            -DPCL_ONLY_CORE_POINT_TYPES=ON \
-            -DBUILD_simulation=ON \
-            -DBUILD_surface_on_nurbs=ON \
-            -DBUILD_global_tests=ON \
-            -DBUILD_examples=ON \
-            -DBUILD_tools=ON \
-            -DBUILD_apps=ON \
-            -DBUILD_apps_3d_rec_framework=ON \
-            -DBUILD_apps_cloud_composer=ON \
-            -DBUILD_apps_in_hand_scanner=ON \
-            -DBUILD_apps_modeler=ON \
-            -DBUILD_apps_point_cloud_editor=ON
-        displayName: 'CMake Configuration'
-      - script: |
-          cd $BUILD_DIR
-          # Compiling some of the test targets with -j2 option leads to pipeline failures
-          # (presumably out of memory error). Thus we make them separately in a single
-          # thread mode. Their corresponding modules are built before with the -j2 mode
-          # to make the process faster.
-          cmake --build . -- -j2 pcl_filters pcl_registration
-          cmake --build . -- test_filters test_registration test_registration_api
-          cmake --build . -- -j2
-        displayName: 'Build Library'
-      - script: |
-          cd $BUILD_DIR && cmake --build . -- tests
-        displayName: 'Run Unit Tests'
-      - task: PublishTestResults@2
-        inputs:
-          testResultsFormat: 'CTest'
-          testResultsFiles: '**/Test*.xml'
-          searchFolder: '$(Agent.BuildDirectory)/build'
-        condition: succeededOrFailed()
diff --git a/.ci/azure-pipelines/build-ubuntu.yaml b/.ci/azure-pipelines/build-ubuntu.yaml
new file mode 100644 (file)
index 0000000..aec0d86
--- /dev/null
@@ -0,0 +1,69 @@
+jobs:
+  - job: ubuntu
+    displayName: Ubuntu
+    pool:
+      vmImage: 'Ubuntu 16.04'
+    strategy:
+      matrix:
+        #        16.04 Clang:
+        #          CONTAINER: env1604
+        #          CC: clang
+        #          CXX: clang++
+        #          CMAKE_ARGS: '-DPCL_WARNINGS_ARE_ERRORS=ON'
+        #        20.04 Clang:
+        #          CONTAINER: env2004
+        #          CC: clang
+        #          CXX: clang++
+        #          CMAKE_ARGS: ''
+        16.04 GCC:
+          CONTAINER: env1604
+          CC: gcc
+          CXX: g++
+          CMAKE_ARGS: '-DPCL_WARNINGS_ARE_ERRORS=ON'
+        20.04 GCC:
+          CONTAINER: env2004
+          CC: gcc
+          CXX: g++
+          CMAKE_ARGS: ''
+    container: $[ variables['CONTAINER'] ]
+    timeoutInMinutes: 0
+    variables:
+      BUILD_DIR: '$(Agent.BuildDirectory)/build'
+      CMAKE_CXX_FLAGS: '-Wall -Wextra'
+    steps:
+      - checkout: self
+        # find the commit hash on a quick non-forced update too
+        fetchDepth: 10
+      - script: |
+          mkdir $BUILD_DIR && cd $BUILD_DIR
+          cmake $(Build.SourcesDirectory) $(CMAKE_ARGS) \
+          -DCMAKE_BUILD_TYPE="Release" \
+          -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
+          -DPCL_ONLY_CORE_POINT_TYPES=ON \
+          -DBUILD_simulation=ON \
+          -DBUILD_surface_on_nurbs=ON \
+          -DBUILD_global_tests=ON \
+          -DBUILD_examples=ON \
+          -DBUILD_tools=ON \
+          -DBUILD_apps=ON \
+          -DBUILD_apps_3d_rec_framework=ON \
+          -DBUILD_apps_cloud_composer=ON \
+          -DBUILD_apps_in_hand_scanner=ON \
+          -DBUILD_apps_modeler=ON \
+          -DBUILD_apps_point_cloud_editor=ON
+          # Temporary fix to ensure no tests are skipped
+          cmake $(Build.SourcesDirectory)
+        displayName: 'CMake Configuration'
+      - script: |
+          cd $BUILD_DIR
+          cmake --build . -- -j2
+        displayName: 'Build Library'
+      - script: |
+          cd $BUILD_DIR && cmake --build . -- tests
+        displayName: 'Run Unit Tests'
+      - task: PublishTestResults@2
+        inputs:
+          testResultsFormat: 'CTest'
+          testResultsFiles: '**/Test*.xml'
+          searchFolder: '$(Agent.BuildDirectory)/build'
+        condition: succeededOrFailed()
diff --git a/.ci/azure-pipelines/build-windows.yaml b/.ci/azure-pipelines/build-windows.yaml
new file mode 100644 (file)
index 0000000..07cc01a
--- /dev/null
@@ -0,0 +1,65 @@
+jobs:
+  - job: vs2017
+    displayName: Windows VS2017 Build
+    pool:
+      vmImage: 'vs2017-win2016'
+    strategy:
+      matrix:
+        x86:
+          PLATFORM: 'x86'
+          ARCHITECTURE: 'x86'
+          GENERATOR: 'Visual Studio 15 2017'
+        x64:
+          PLATFORM: 'x64'
+          ARCHITECTURE: 'x86_amd64'
+          GENERATOR: 'Visual Studio 15 2017 Win64'
+    timeoutInMinutes: 0
+    variables:
+      BUILD_DIR: '$(Agent.WorkFolder)\build'
+      CONFIGURATION: 'Release'
+      VCPKG_ROOT: 'C:\vcpkg'
+    steps:
+      - checkout: self
+        # find the commit hash on a quick non-forced update too
+        fetchDepth: 10
+      - script: |
+          echo ##vso[task.setvariable variable=BOOST_ROOT]%BOOST_ROOT_1_69_0%
+        displayName: 'Set BOOST_ROOT Environment Variable'
+      - script: |
+          echo ##vso[task.prependpath]%BOOST_ROOT_1_69_0%\lib
+        displayName: 'Include Boost Libraries In System PATH'
+      - script: |
+          set
+        displayName: 'Print Environment Variables'
+      - script: |
+          vcpkg.exe install eigen3 flann gtest qhull --triplet %PLATFORM%-windows && vcpkg.exe list
+        displayName: 'Install C++ Dependencies Via Vcpkg'
+      - script: |
+          rmdir %VCPKG_ROOT%\downloads /S /Q
+          rmdir %VCPKG_ROOT%\packages /S /Q
+        displayName: 'Free Up Space'
+      - script: |
+          mkdir %BUILD_DIR% && cd %BUILD_DIR%
+          cmake $(Build.SourcesDirectory) ^
+            -G"%GENERATOR%" ^
+            -DCMAKE_BUILD_TYPE="Release" ^
+            -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake ^
+            -DVCPKG_APPLOCAL_DEPS=ON ^
+            -DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=ON ^
+            -DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=ON ^
+            -DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=ON ^
+            -DBUILD_global_tests=ON ^
+            -DBUILD_tools=OFF ^
+            -DBUILD_surface_on_nurbs=ON
+        displayName: 'CMake Configuration'
+      - script: cd %BUILD_DIR% && cmake --build . --config %CONFIGURATION%
+        displayName: 'Build Library'
+      - script: cd %BUILD_DIR% && cmake --build . --target tests --config %CONFIGURATION%
+        displayName: 'Run Unit Tests'
+      - task: PublishTestResults@2
+        inputs:
+          testResultsFormat: 'CTest'
+          testResultsFiles: '**/Test*.xml'
+          searchFolder: '$(Agent.WorkFolder)\build'
+        condition: succeededOrFailed()
+
diff --git a/.ci/azure-pipelines/build-windows.yml b/.ci/azure-pipelines/build-windows.yml
deleted file mode 100644 (file)
index 7bfaa40..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-jobs:
-  - job: vs2017
-    displayName: Windows VS2017 Build
-    timeoutInMinutes: 0
-    pool:
-      vmImage: 'vs2017-win2016'
-    strategy:
-      matrix:
-        x86:
-          PLATFORM: 'x86'
-          ARCHITECTURE: 'x86'
-          GENERATOR: 'Visual Studio 15 2017'
-        x64:
-          PLATFORM: 'x64'
-          ARCHITECTURE: 'x86_amd64'
-          GENERATOR: 'Visual Studio 15 2017 Win64'
-    variables:
-      BUILD_DIR: '$(Agent.WorkFolder)\build'
-      CONFIGURATION: 'Release'
-      VCPKG_ROOT: 'C:\vcpkg'
-    steps:
-      - script: set
-        displayName: 'Print Environment Variables'
-      - script: |
-          echo ##vso[task.prependpath]%BOOST_ROOT%\lib
-        displayName: 'Update System PATH'
-      - script: |
-          vcpkg.exe install eigen3 flann gtest qhull --triplet %PLATFORM%-windows && vcpkg.exe list
-        displayName: 'Install c++ dependencies via vcpkg'
-      - script: |
-          rmdir %VCPKG_ROOT%\downloads /S /Q
-          rmdir %VCPKG_ROOT%\packages /S /Q
-        displayName: 'Free Up Space'
-      - script: |
-          mkdir %BUILD_DIR% && cd %BUILD_DIR%
-          cmake $(Build.SourcesDirectory) -G"%GENERATOR%" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DVCPKG_APPLOCAL_DEPS=ON -DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=ON -DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=ON -DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=ON -DBUILD_global_tests=ON -DBUILD_tools=OFF -DBUILD_surface_on_nurbs=ON
-        displayName: 'CMake Configuration'
-      - script: cd %BUILD_DIR% && cmake --build . --config %CONFIGURATION%
-        displayName: 'Build Library'
-      - script: cd %BUILD_DIR% && cmake --build . --target tests --config %CONFIGURATION%
-        displayName: 'Run Unit Tests'
-      - task: PublishTestResults@2
-        inputs:
-          testResultsFormat: 'CTest'
-          testResultsFiles: '**/Test*.xml'
-          searchFolder: '$(Agent.WorkFolder)\build'
-        condition: succeededOrFailed()
-
diff --git a/.ci/azure-pipelines/documentation.yaml b/.ci/azure-pipelines/documentation.yaml
new file mode 100644 (file)
index 0000000..f6f93d1
--- /dev/null
@@ -0,0 +1,56 @@
+jobs:
+  - job: documentation
+    displayName: Generate Documentation
+    pool:
+      vmImage: 'Ubuntu 16.04'
+    container: doc
+    variables:
+      BUILD_DIR: '$(Agent.BuildDirectory)/build'
+      DOC_DIR: '$(Agent.BuildDirectory)/documentation'
+      CHANGELOG: '$(Agent.TempDirectory)/changelog'
+    steps:
+      - checkout: self
+        # find the commit hash on a quick non-forced update too
+        fetchDepth: 10
+      - task: InstallSSHKey@0
+        inputs:
+          hostName: github.com
+          sshPublicKey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBh5Yrau/gguTfoNALxhVX77Pgz6y6UWoJRERMKR68ee documentation@pointclouds.org
+          sshKeySecureFile: id_ed25519
+          condition: eq(variables['Build.Repository.Name'], 'PointCloudLibrary/pcl')
+      - script: |
+          $(Build.SourcesDirectory)/.dev/scripts/generate_changelog.py --with-misc > $CHANGELOG.md
+          grip --export $CHANGELOG.md $CHANGELOG.html
+          pandoc -f markdown -t plain --wrap=none $CHANGELOG.md
+        displayName: 'Generate Changelog'
+      - script: |
+          mkdir $BUILD_DIR && cd $BUILD_DIR
+          cmake $(Build.SourcesDirectory) \
+            -DDOXYGEN_USE_SHORT_NAMES=OFF \
+            -DSPHINX_HTML_FILE_SUFFIX=php \
+            -DWITH_DOCS=ON \
+            -DWITH_TUTORIALS=ON
+        displayName: 'CMake Configuration'
+      - script: |
+          cd $BUILD_DIR
+          cmake --build . -- doc tutorials advanced
+        displayName: 'Build Documentation'
+      - script: |
+          cd $BUILD_DIR
+          sed -i -r -e 's/([0-9]+)\s\.\s([0-9]+)\s/\1.\2/' doc/doxygen/html/deprecated.html
+        displayName: 'Remove extra spaces in Doxygen''s Deprecated List'
+      - script: |
+          git config --global user.email "documentation@pointclouds.org"
+          git config --global user.name "PointCloudLibrary (via Azure Pipelines)"
+          echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
+          git clone git@github.com:PointCloudLibrary/documentation.git $DOC_DIR
+          cd $DOC_DIR
+          cp -r $BUILD_DIR/doc/tutorials/html/* tutorials
+          cp -r $BUILD_DIR/doc/advanced/html/* advanced
+          cp -r $BUILD_DIR/doc/doxygen/html/* .
+          cp $CHANGELOG.html .
+          git add --all
+          git commit --amend --reset-author -m 'Documentation for commit $(Build.SourceVersion)' -q
+          git push --force
+        displayName: 'Push Generated Documentation To GitHub'
+        condition: and(eq(variables['Build.Repository.Name'], 'PointCloudLibrary/pcl'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
diff --git a/.ci/azure-pipelines/documentation.yml b/.ci/azure-pipelines/documentation.yml
deleted file mode 100644 (file)
index 3ec71b6..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-resources:
-  containers:
-    - container: doc
-      image: pointcloudlibrary/doc
-
-jobs:
-  - job: documentation
-    displayName: Generate Documentation
-    pool:
-      vmImage: 'Ubuntu 16.04'
-    container: doc
-    variables:
-      BUILD_DIR: '$(Agent.BuildDirectory)/build'
-      DOC_DIR: '$(Agent.BuildDirectory)/documentation'
-    steps:
-      - task: InstallSSHKey@0
-        inputs:
-          hostName: github.com
-          sshPublicKey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBh5Yrau/gguTfoNALxhVX77Pgz6y6UWoJRERMKR68ee documentation@pointclouds.org
-          sshKeySecureFile: id_ed25519
-      - task: UsePythonVersion@0
-        inputs:
-          versionSpec: '3.6'
-          addToPath: true
-      - script: |
-          mkdir $BUILD_DIR && cd $BUILD_DIR
-          cmake $(Build.SourcesDirectory) \
-            -DDOXYGEN_USE_SHORT_NAMES=OFF \
-            -DSPHINX_HTML_FILE_SUFFIX=php \
-            -DWITH_DOCS=ON \
-            -DWITH_TUTORIALS=ON
-        displayName: 'CMake Configuration'
-      - script: |
-          cd $BUILD_DIR
-          cmake --build . -- doc tutorials advanced
-        displayName: 'Build Documentation'
-      - script: |
-          git config --global user.email "documentation@pointclouds.org"
-          git config --global user.name "PointCloudLibrary (via Azure Pipelines)"
-          echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
-          git clone git@github.com:PointCloudLibrary/documentation.git $DOC_DIR
-          cd $DOC_DIR
-          cp -r $BUILD_DIR/doc/tutorials/html/* tutorials
-          cp -r $BUILD_DIR/doc/advanced/html/* advanced
-          cp -r $BUILD_DIR/doc/doxygen/html/* .
-          git add --all
-          git commit --amend --reset-author -m 'Documentation for commit $(Build.SourceVersion)' -q
-          git push --force
-        displayName: 'Push Generated Documentation To GitHub'
-        condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
diff --git a/.ci/azure-pipelines/env.yml b/.ci/azure-pipelines/env.yml
new file mode 100644 (file)
index 0000000..d55079d
--- /dev/null
@@ -0,0 +1,94 @@
+# Docker
+# Build a Docker image
+# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
+
+trigger:
+  branches:
+    include:
+    - master
+  paths:
+    include:
+    - .dev/docker/env/Dockerfile
+    - .ci/azure-pipelines/env.yml
+
+pr:
+  paths:
+    include:
+    - .dev/docker/env/Dockerfile
+    - .ci/azure-pipelines/env.yml
+
+schedules:
+- cron: "0 0 * * 0"
+  displayName: "Sunday midnight build"
+  branches:
+    include:
+    - master
+
+resources:
+- repo: self
+
+variables:
+  dockerHub: 'PointCloudLibrary@hub.docker.com'
+  dockerHubID: "pointcloudlibrary"
+
+jobs:
+- job: BuildAndPush
+  timeoutInMinutes: 360
+  displayName: "Env"
+  pool:
+    vmImage: 'ubuntu-latest'
+  strategy:
+    matrix:
+      Ubuntu 16.04:
+        CUDA_VERSION: 9.2
+        UBUNTU_DISTRO: 16.04
+        USE_CUDA: true
+        VTK_VERSION: 6
+        tag: 16.04
+      Ubuntu 18.04:
+        CUDA_VERSION: 10.2
+        UBUNTU_DISTRO: 18.04
+        USE_CUDA: true
+        VTK_VERSION: 6
+        tag: 18.04
+      Ubuntu 20.04:
+        CUDA_VERSION: 11
+        UBUNTU_DISTRO: 20.04
+        VTK_VERSION: 7
+        # nvidia-cuda docker image has not been released for 20.04 yet
+        USE_CUDA: ""
+        tag: 20.04
+  steps:
+  - task: Docker@2
+    displayName: "Build docker image"
+    inputs:
+      command: build
+      arguments: |
+        --no-cache
+        --build-arg CUDA_VERSION=$(CUDA_VERSION)
+        --build-arg UBUNTU_DISTRO=$(UBUNTU_DISTRO)
+        --build-arg USE_CUDA=$(USE_CUDA)
+        --build-arg VTK_VERSION=$(VTK_VERSION)
+        -t $(dockerHubID)/env:$(tag)
+      dockerfile: '$(Build.SourcesDirectory)/.dev/docker/env/Dockerfile'
+      tags: "$(tag)"
+  - script: |
+      set -x
+      docker run --rm -v "$(Build.SourcesDirectory)":/pcl $(dockerHubID)/env:$(tag) bash -c ' \
+      mkdir /pcl/build && cd /pcl/build && \
+      cmake /pcl \
+        -DCMAKE_BUILD_TYPE="Release" \
+        -DPCL_ONLY_CORE_POINT_TYPES=ON \
+        -DBUILD_io:BOOL=OFF \
+        -DBUILD_kdtree:BOOL=OFF && \
+      cmake --build . -- -j2'
+    displayName: 'Verify Dockerimage'
+  - task: Docker@2
+    displayName: "Push docker image"
+    inputs:
+      command: push
+      containerRegistry: $(dockerHub)
+      repository: $(dockerHubID)/env
+      tags: "$(tag)"
+      condition: and(eq(variables['Build.Repository.Name'], 'PointCloudLibrary/pcl'),
+                     eq(variables['Build.SourceBranch'], 'refs/heads/master'))
diff --git a/.ci/azure-pipelines/formatting.yaml b/.ci/azure-pipelines/formatting.yaml
new file mode 100644 (file)
index 0000000..0033e72
--- /dev/null
@@ -0,0 +1,29 @@
+jobs:
+  - job: formatting
+    displayName: Check code formatting
+    pool:
+      vmImage: 'Ubuntu 16.04'
+    container: fmt
+    steps:
+      - checkout: self
+        # find the commit hash on a quick non-forced update too
+        fetchDepth: 10
+      - script: ./.dev/format.sh $(which clang-format) .
+        displayName: 'Run clang-format'
+      - script: git diff > formatting.patch
+        displayName: 'Compute diff'
+      - script: cat formatting.patch
+        displayName: 'Show diff'
+      - task: CopyFiles@2
+        inputs:
+          sourceFolder: '$(Build.SourcesDirectory)'
+          contents: 'formatting.patch'
+          targetFolder: '$(Build.ArtifactStagingDirectory)'
+        displayName: 'Copy diff to staging directory'
+      - task: PublishBuildArtifacts@1
+        inputs:
+          pathtoPublish: '$(Build.ArtifactStagingDirectory)'
+          artifactName: formatting
+        displayName: 'Publish diff'
+      - script: "[ ! -s formatting.patch ]"
+        displayName: 'Set job exit status'
diff --git a/.ci/azure-pipelines/formatting.yml b/.ci/azure-pipelines/formatting.yml
deleted file mode 100644 (file)
index 1bff15b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-resources:
-  containers:
-    - container: fmt
-      image: pointcloudlibrary/fmt
-
-jobs:
-  - job: formatting
-    displayName: Check code formatting
-    pool:
-      vmImage: 'Ubuntu 16.04'
-    container: fmt
-    steps:
-      - script: ./.dev/format.sh $(which clang-format-8) .
-        displayName: 'Run clang-format'
-      - script: git diff > formatting.patch
-        displayName: 'Compute diff'
-      - script: cat formatting.patch
-        displayName: 'Show diff'
-      - task: CopyFiles@2
-        inputs:
-          sourceFolder: '$(Build.SourcesDirectory)'
-          contents: 'formatting.patch'
-          targetFolder: '$(Build.ArtifactStagingDirectory)'
-        displayName: 'Copy diff to staging directory'
-      - task: PublishBuildArtifacts@1
-        inputs:
-          pathtoPublish: '$(Build.ArtifactStagingDirectory)'
-          artifactName: formatting
-        displayName: 'Publish diff'
-      - script: "[ ! -s formatting.patch ]"
-        displayName: 'Set job exit status'
diff --git a/.ci/azure-pipelines/tutorials.yaml b/.ci/azure-pipelines/tutorials.yaml
new file mode 100644 (file)
index 0000000..05922c4
--- /dev/null
@@ -0,0 +1,53 @@
+jobs:
+  - job: tutorials
+    displayName: Building Tutorials
+    pool:
+      vmImage: 'Ubuntu 16.04'
+    container: env1604
+    timeoutInMinutes: 0
+    variables:
+      BUILD_DIR: '$(Agent.BuildDirectory)/build'
+      INSTALL_DIR: '$(Agent.BuildDirectory)/install'
+      CMAKE_CXX_FLAGS: '-Wall -Wextra -Wabi'
+      EXCLUDE_TUTORIALS: 'davidsdk,ensenso_cameras,gpu'
+    steps:
+      - checkout: self
+        # find the commit hash on a quick non-forced update too
+        fetchDepth: 10
+      - script: |
+          mkdir $BUILD_DIR && cd $BUILD_DIR
+          cmake $(Build.SourcesDirectory) \
+            -DCMAKE_BUILD_TYPE="Release" \
+            -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
+            -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
+            -DPCL_ONLY_CORE_POINT_TYPES=ON \
+            -DPCL_NO_PRECOMPILE=ON \
+            -DBUILD_surface_on_nurbs=ON \
+            -DBUILD_global_tests=OFF \
+            -DBUILD_tools=OFF \
+            -DBUILD_examples=OFF \
+            -DBUILD_outofcore=OFF \
+            -DBUILD_stereo=OFF \
+            -DBUILD_simulation=OFF
+        displayName: 'CMake Configuration'
+      - script: |
+          cd $BUILD_DIR
+          cmake --build . -- -j2
+        displayName: 'Build Library'
+      - script: |
+          cd $BUILD_DIR
+          cmake --build . -- install
+        displayName: 'Install PCL'
+      - script: |
+          cd $BUILD_DIR
+          major=$(find . -type f -exec sed -n -e \
+              's,#define PCL_MAJOR_VERSION \([0-9]\+\),\1,p' {} \;)
+          minor=$(find . -type f -exec sed -n -e \
+              's,#define PCL_MINOR_VERSION \([0-9]\+\),\1,p' {} \;)
+          $(Build.SourcesDirectory)/.ci/scripts/build_tutorials.sh \
+              -k -s \
+              -e $EXCLUDE_TUTORIALS \
+              $INSTALL_DIR/share/pcl-${major}.${minor} \
+              $(Build.SourcesDirectory) \
+              $BUILD_DIR/tutorials
+        displayName: 'Build Tutorials'
diff --git a/.ci/azure-pipelines/tutorials.yml b/.ci/azure-pipelines/tutorials.yml
deleted file mode 100644 (file)
index 3b67566..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-resources:
-  containers:
-    - container: env1604
-      image: pointcloudlibrary/env:16.04
-
-jobs:
-  - job: tutorials
-    displayName: Tutorials
-    timeoutInMinutes: 0
-    pool:
-      vmImage: 'Ubuntu 16.04'
-    container: env1604
-    variables:
-      BUILD_DIR: '$(Agent.BuildDirectory)/build'
-      INSTALL_DIR: '$(Agent.BuildDirectory)/install'
-      CMAKE_CXX_FLAGS: '-Wall -Wextra -Wabi -O2'
-      EXCLUDE_TUTORIALS: 'davidsdk,ensenso_cameras,gpu'
-    steps:
-      - script: |
-          mkdir $BUILD_DIR && cd $BUILD_DIR
-          cmake $(Build.SourcesDirectory) \
-            -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-            -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
-            -DPCL_ONLY_CORE_POINT_TYPES=ON \
-            -DPCL_NO_PRECOMPILE=ON \
-            -DBUILD_surface_on_nurbs=ON \
-            -DBUILD_global_tests=OFF \
-            -DBUILD_tools=OFF \
-            -DBUILD_examples=OFF \
-            -DBUILD_outofcore=OFF \
-            -DBUILD_stereo=OFF \
-            -DBUILD_simulation=OFF
-        displayName: 'CMake Configuration'
-      - script: |
-          cd $BUILD_DIR
-          cmake --build . -- -j2
-        displayName: 'Build Library'
-      - script: |
-          cd $BUILD_DIR
-          cmake --build . -- install
-        displayName: 'Install PCL'
-      - script: |
-          $(Build.SourcesDirectory)/.ci/scripts/build_tutorials.sh -k -s -e $EXCLUDE_TUTORIALS $INSTALL_DIR/share/pcl-1.10 $(Build.SourcesDirectory) $BUILD_DIR/tutorials
-        displayName: 'Build Tutorials'
index 861623723f061206979857b22cc6e1b8484f4e40..3e0ebf2ffeccace311fa81471aa280e40fa6ef57 100644 (file)
@@ -1,6 +1,6 @@
 ---
 AlwaysBreakAfterReturnType: All
-AlwaysBreakTemplateDeclarations: true
+AlwaysBreakTemplateDeclarations: Yes
 BinPackArguments: false
 BinPackParameters: false
 BraceWrapping:
@@ -17,7 +17,53 @@ ColumnLimit: 88
 ConstructorInitializerAllOnOneLineOrOnePerLine: true
 ConstructorInitializerIndentWidth: 0
 Language: Cpp
+NamespaceIndentation: None
 PointerAlignment: Left
-Standard: Cpp11
+Standard: c++14
 TabWidth: 2
 UseTab: Never
+IncludeBlocks: Regroup
+IncludeCategories:
+# Main PCL includes of common module should be sorted at end of PCL includes
+  - Regex:           '^<pcl/[^/]+>$'
+    Priority:        100
+    SortPriority:    101
+# All other PCL includes, which are grouped into modules
+  - Regex:           '^<pcl/.*/.*>$'
+    Priority:        100
+    SortPriority:    100
+# Major 3rd-Party components of tests & modules
+  - Regex:           '^<gtest/'
+    Priority:        200
+  - Regex:           '^<boost/'
+    Priority:        210
+  - Regex:           '^<(unsupported/)?Eigen/'
+    Priority:        220
+  - Regex:           '^<flann/'
+    Priority:        230
+# Major 3rd-Party components of apps
+  - Regex:           '^<Q[^/]+>$'
+    Priority:        300
+  - Regex:           '^<ui_[^/]+\.h>$'
+    Priority:        300
+  - Regex:           '^<vtk[^/]+\.h>$'
+    Priority:        310
+# Minor 3rd-Party components
+  - Regex:           '^<librealsense2/'
+    Priority:        400
+  - Regex:           '^<(ros|message_filters)/'
+    Priority:        410
+  - Regex:           '^<opencv(2)?/'
+    Priority:        420
+  - Regex:           '^<tide/'
+    Priority:        430
+  - Regex:           '^<thrust/'
+    Priority:        440
+  - Regex:           '^<(OpenGL|(GL(UT)?/))'
+    Priority:        450
+# Matches all std includes. Match them before any unknown include, so we can order them behind.
+  - Regex:           '^<[a-z]+>$'
+    Priority:        900
+# Any unknown include
+  - Regex:           '.*'
+    Priority:        500
index 5d4f95e6a5bb98271f47884a2d0ea59b77a27821..43800b490e0d4f4d55cfa75232d9a4575c3749f3 100644 (file)
@@ -1,4 +1,4 @@
-FROM pointcloudlibrary/env:19.04
+FROM pointcloudlibrary/env:20.04
 
 ENV DEBIAN_FRONTEND=noninteractive
 
@@ -8,6 +8,7 @@ RUN apt-get update \
       dvipng \
       git \
       python3-pip \
+      pandoc \
  && rm -rf /var/lib/apt/lists/*
 
-RUN pip3 install Jinja2==2.8.1 sphinx sphinxcontrib-doxylink
+RUN pip3 install Jinja2 sphinx sphinxcontrib-doxylink sphinx_rtd_theme requests grip
index b133937d8f4f3b2ca092f33b5ecbfecb2c92cf8d..9c8320483b11620890756f1ddeb6051d4fb25aca 100644 (file)
@@ -18,6 +18,7 @@ RUN apt-get update \
  && apt-get install -y \
       cmake \
       g++ \
+      clang \
       wget \
       libboost-date-time-dev \
       libboost-filesystem-dev \
index b3fc3d9876101ed711c422cf2f2a8985e42a3713..4535cb937d1355c3ac33f1a035e4b31dd16a7ace 100644 (file)
@@ -1,11 +1,12 @@
-FROM ubuntu:19.04
+# Azure needs node shadow, sudo and the label
+FROM node:lts-alpine
 
-ENV DEBIAN_FRONTEND=noninteractive
-ARG CLANG_FORMAT_VERSION=8
+# clang-10 needed alpine edge as of 2020-Apr-28
+RUN apk add \
+        --no-cache \
+        --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \
+        bash clang git shadow sudo
 
-RUN apt-get update \
- && apt-get install -y \
-      clang-format-${CLANG_FORMAT_VERSION} \
-      bash \
-      git \
- && rm -rf /var/lib/apt/lists/*
+LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/local/bin/node"
+
+CMD [ "bash" ]
index 7b7c1d13c970e2ad13e6c3ae1a770c5d97b795bc..c3ccba700dcd02756cc5cfc51592a1edda217d98 100755 (executable)
@@ -8,7 +8,7 @@
 
 format() {
     # don't use a directory with whitespace
-    local whitelist="2d ml octree simulation stereo"
+    local whitelist="apps/modeler 2d ml octree simulation stereo"
 
     local PCL_DIR="${2}"
     local formatter="${1}"
diff --git a/.dev/scripts/generate_changelog.py b/.dev/scripts/generate_changelog.py
new file mode 100755 (executable)
index 0000000..11390a3
--- /dev/null
@@ -0,0 +1,253 @@
+#! /usr/bin/env python3
+
+"""
+Software License Agreement (BSD License)
+
+ Point Cloud Library (PCL) - www.pointclouds.org
+ Copyright (c) 2018-, Open Perception, Inc.
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above
+    copyright notice, this list of conditions and the following
+    disclaimer in the documentation and/or other materials provided
+    with the distribution.
+  * Neither the name of the copyright holder(s) nor the names of its
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+"""
+
+import json
+import argparse
+from pathlib import Path
+
+import requests
+import re
+
+
+CATEGORIES = {
+    "new feature": ("New features", ""),
+    "deprecation": (
+        "Deprecation",
+        "of public APIs, scheduled to be removed after two minor releases",
+    ),
+    "removal": ("Removal", "of the public APIs deprecated in previous releases"),
+    "behavior change": ("Behavior changes", "in classes, apps, or tools",),
+    "API break": (
+        "API changes",
+        "that did not go through the proper deprecation and removal cycle",
+    ),
+    "ABI break": ("ABI changes", "that are still API compatible",),
+    "fix": (None, None),
+    "enhancement": (None, None),
+}
+
+
+MODULES = {
+    "cmake": "CMake",
+    "2d": "libpcl_2d",
+    "common": "libpcl_common",
+    "cuda": "libpcl_cuda",
+    "features": "libpcl_features",
+    "filters": "libpcl_filters",
+    "geometry": "libpcl_geometry",
+    "gpu": "libpcl_gpu",
+    "io": "libpcl_io",
+    "kdtree": "libpcl_kdtree",
+    "keypoints": "libpcl_keypoints",
+    "ml": "libpcl_ml",
+    "octree": "libpcl_octree",
+    "outofcore": "libpcl_outofcore",
+    "people": "libpcl_people",
+    "recognition": "libpcl_recognition",
+    "registration": "libpcl_registration",
+    "sample_consensus": "libpcl_sample_consensus",
+    "search": "libpcl_search",
+    "segmentation": "libpcl_segmentation",
+    "simulation": "libpcl_simulation",
+    "stereo": "libpcl_stereo",
+    "surface": "libpcl_surface",
+    "visualization": "libpcl_visualization",
+    "apps": "PCL Apps",
+    "docs": "PCL Docs",
+    "tutorials": "PCL Tutorials",
+    "examples": "PCL Examples",
+    "tests": "PCL Tests",
+    "tools": "PCL Tools",
+    "ci": "CI",
+    None: "Uncategorized",
+}
+
+
+def fetch_latest_release_date():
+    """
+    Fetch the date when the latest release was created.
+    """
+    url = "https://api.github.com/repos/PointCloudLibrary/pcl/releases/latest"
+    response = requests.get(url)
+    response.raise_for_status()
+    return response.json()["created_at"]
+
+
+def fetch_pr_since(start_date):
+    """
+    Fetch data of PRs merged after a given start date.
+    """
+    url = f"https://api.github.com/search/issues?q=is:pr+repo:PointCloudLibrary/pcl+merged:>={start_date}"
+    pr_data = list()
+    page = 1
+    while True:
+        response = requests.get(f"{url}&page={page}&per_page=100")
+        response.raise_for_status()
+        data = response.json()
+        total_count = data["total_count"]
+        pr_data.extend(data["items"])
+        page += 1
+        if len(pr_data) == total_count:
+            break
+    return pr_data
+
+
+def filter_labels(labels, prefix):
+    """
+    Filter a given list of PR labels, keeping only those starting with a given prefix.
+    The prefix is stripped from the labels.
+    """
+    return [
+        label["name"][len(prefix) :]
+        for label in labels
+        if label["name"].startswith(prefix)
+    ]
+
+
+def strip_leading_tag(text):
+    """
+    >>> strip_leading_tag("[text] larger text")
+    'larger text'
+    >>> strip_leading_tag("no tag text")
+    'no tag text'
+    """
+    if len(text) == 0 or text[0] != '[':
+        return text
+    pattern = re.compile('\[.*\]\s*')
+    match = pattern.match(text)
+    return text[match.end():] if match else text
+
+
+def make_pr_bullet_point(pr, prefix=None):
+    ref = "[#{0}](https://github.com/PointCloudLibrary/pcl/pull/{0})".format(
+        pr["number"]
+    )
+
+    tags = ""
+    if prefix in ("modules", "categories"):
+        tags = "".join(["[" + k + "]" for k in pr[prefix]])
+    if tags:
+        tags = "**" + tags + "** "
+
+    return f"* {tags}{pr['title']} [{ref}]"
+
+
+def generate_category_section(key, prs):
+    section = list()
+    filtered_prs = [pr for pr in prs if key in pr["categories"]]
+    title, description = CATEGORIES[key]
+    if filtered_prs and title:
+        section += [f"\n**{title}** *{description}*\n"]
+        section += [make_pr_bullet_point(pr, "modules") for pr in filtered_prs]
+    return section
+
+
+def generate_module_section(key, prs):
+    section = list()
+    filtered_prs = [pr for pr in prs if key in pr["modules"]]
+    title = MODULES[key]
+    if filtered_prs and title:
+        section += [f"\n#### {title}:\n"]
+        section += [make_pr_bullet_point(pr, "categories") for pr in filtered_prs]
+    return section
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(
+        description="""
+    Generate changelog from pull requests merged after the latest release.
+    """,
+        formatter_class=argparse.RawDescriptionHelpFormatter,
+    )
+    cache_grp = parser.add_mutually_exclusive_group()
+    cache_grp.add_argument("--save", type=Path, help="Save PR data fetched from GitHub")
+    cache_grp.add_argument("--load", type=Path, help="Load PR data from a file")
+    parser.add_argument(
+        "--with-misc",
+        "-m",
+        action="store_true",
+        help=(
+            "Add section with miscellaneous PRs that are not important enough to be "
+            "included in the official changelog"
+        ),
+    )
+    args = parser.parse_args()
+
+    if args.load:
+        with open(args.load) as fp:
+            pr_data = json.loads(fp.read())
+    else:
+        date = fetch_latest_release_date()
+        pr_data = fetch_pr_since(date)
+        if args.save:
+            with open(args.save, "w") as fp:
+                fp.write(json.dumps(pr_data))
+
+    selected_prs = list()
+    excluded_prs = list()
+    for pr in sorted(pr_data, key=lambda d: d["closed_at"]):
+        categories = filter_labels(pr["labels"], "changelog: ")
+        title = strip_leading_tag(pr["title"])
+        pr_info = {
+            "number": pr["number"],
+            "title": title,
+            "modules": filter_labels(pr["labels"], "module: "),
+            "categories": [g for g in categories if g not in ["fix", "enhancement"]],
+        }
+        if categories:
+            selected_prs.append(pr_info)
+        else:  # exclude PRs not tagged with any changelog label
+            excluded_prs.append(pr_info)
+
+    clog = list()
+
+    clog += ["\n### Notable changes"]
+    for k in CATEGORIES.keys():
+        clog.extend(generate_category_section(k, selected_prs))
+
+    clog += ["\n### Changes grouped by module"]
+    for k in MODULES.keys():
+        clog.extend(generate_module_section(k, selected_prs))
+
+    if args.with_misc:
+        clog += ["\n### Miscellaneous PRs excluded from changelog\n"]
+        for pr in excluded_prs:
+            clog += [make_pr_bullet_point(pr)]
+
+    print("\n".join(clog))
diff --git a/.github/change_log.py b/.github/change_log.py
deleted file mode 100755 (executable)
index 44453f5..0000000
+++ /dev/null
@@ -1,449 +0,0 @@
-#! /usr/bin/env python3
-
-"""
-Software License Agreement (BSD License)
-
- Point Cloud Library (PCL) - www.pointclouds.org
- Copyright (c) 2018-, Open Perception, Inc.
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-  * Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
-  * Redistributions in binary form must reproduce the above
-    copyright notice, this list of conditions and the following
-    disclaimer in the documentation and/or other materials provided
-    with the distribution.
-  * Neither the name of the copyright holder(s) nor the names of its
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-"""
-
-import argparse
-from argparse import ArgumentParser
-from collections import defaultdict
-import getpass
-import json
-import os
-import pathlib
-import re
-import subprocess
-import sys
-
-import requests
-
-
-def find_pcl_folder():
-    folder = os.path.dirname(os.path.abspath(__file__))
-    folder = pathlib.Path(folder).parent
-    return str(folder)
-
-
-def find_pr_list(start: str, end: str):
-    """Returns all PR ids from a certain commit range. Inspired in
-    http://joey.aghion.com/find-the-github-pull-request-for-a-commit/
-    https://stackoverflow.com/questions/36433572/how-does-ancestry-path-work-with-git-log#36437843
-    """
-
-    # Let git generate the proper pr history
-    cmd = "git log --oneline " + start + ".." + end
-    cmd = cmd.split()
-    output = subprocess.run(cmd, cwd=FOLDER, stdout=subprocess.PIPE)
-    pr_commits = output.stdout.split(b"\n")
-
-    # Fetch ids for all merge requests from PRS
-    merge_re = re.compile("\S+ Merge pull request #(\d+) from \S+")
-    squash_re = re.compile("\(#(\d+)\)")
-
-    ids = []
-    for pr in pr_commits:
-
-        pr_s = str(pr)
-
-        # Match agains usual pattern
-        uid = None
-        match = merge_re.fullmatch(pr_s)
-
-        # Match agains squash pattern
-        if not match:
-            match = squash_re.search(pr_s)
-
-            # Abort
-            if not match:
-                continue
-
-        # Extract PR uid
-        uid = int(match.group(1))
-        ids.append(uid)
-
-    return ids
-
-
-def fetch_pr_info(pr_ids, auth):
-
-    prs_url = "https://api.github.com/repos/PointCloudLibrary/pcl/pulls/"
-    pr_info = []
-
-    sys.stdout.write("Fetching PR Info: {}%".format(0))
-    sys.stdout.flush()
-
-    for i, pr_id in enumerate(pr_ids):
-
-        # Fetch GitHub info
-        response = requests.get(prs_url + str(pr_id), auth=auth)
-        data = response.json()
-
-        if response.status_code != 200:
-            print(
-                "\nError: Failed to fetch PR info. Server reported '"
-                + data["message"]
-                + "'",
-                file=sys.stderr,
-            )
-            exit(code=1)
-
-        d = {"id": pr_id, "title": data["title"], "labels": data["labels"]}
-        pr_info.append(d)
-
-        # import pdb; pdb.set_trace()
-        sys.stdout.write(
-            "\rFetching PR Info: {:0.2f}%".format(100 * (i + 1) / len(pr_ids))
-        )
-        sys.stdout.flush()
-
-    print("")
-    return pr_info
-
-
-def extract_version(tag):
-    """Finds the corresponding version from a provided tag.
-    If the tag does not correspond to a suitable version tag, the original tag
-    is returned
-    """
-    version_re = re.compile("pcl-\S+")
-    res = version_re.fullmatch(tag)
-
-    # Not a usual version tag
-    if not res:
-        return tag
-
-    return tag[4:]
-
-
-def generate_text_content(tag, pr_info):
-
-    module_order = (
-        None,
-        "cmake",
-        "2d",
-        "common",
-        "cuda",
-        "features",
-        "filters",
-        "geometry",
-        "gpu",
-        "io",
-        "kdtree",
-        "keypoints",
-        "ml",
-        "octree",
-        "outofcore",
-        "people",
-        "recognition",
-        "registration",
-        "sample_consensus",
-        "search",
-        "segmentation",
-        "simulation",
-        "stereo",
-        "surface",
-        "visualization",
-        "apps",
-        "docs",
-        "tutorials",
-        "examples",
-        "tests",
-        "tools",
-        "ci",
-    )
-
-    module_titles = {
-        None: "Uncategorized",
-        "2d": "libpcl_2d",
-        "apps": "PCL Apps",
-        "cmake": "CMake",
-        "ci": "CI",
-        "common": "libpcl_common",
-        "cuda": "libpcl_cuda",
-        "docs": "PCL Docs",
-        "examples": "PCL Examples",
-        "features": "libpcl_features",
-        "filters": "libpcl_filters",
-        "gpu": "libpcl_gpu",
-        "io": "libpcl_io",
-        "kdtree": "libpcl_kdtree",
-        "keypoints": "libpcl_keypoints",
-        "ml": "libpcl_ml",
-        "octree": "libpcl_octree",
-        "outofcore": "libpcl_outofcore",
-        "people": "libpcl_people",
-        "recognition": "libpcl_recognition",
-        "registration": "libpcl_registration",
-        "sample_consensus": "libpcl_sample_consensus",
-        "search": "libpcl_search",
-        "segmentation": "libpcl_segmentation",
-        "simulation": "libpcl_simulation",
-        "stereo": "libpcl_stereo",
-        "surface": "libpcl_surface",
-        "tests": "PCL Tests",
-        "tools": "PCL Tools",
-        "tutorials": "PCL Tutorials",
-        "visualization": "libpcl_visualization",
-    }
-
-    changes_order = ("new-feature", "deprecation", "removal", "behavior", "api", "abi")
-
-    changes_titles = {
-        "new-feature": "New Features",
-        "deprecation": "Deprecated",
-        "removal": "Removed",
-        "behavior": "Behavioral changes",
-        "api": "API changes",
-        "abi": "ABI changes",
-    }
-
-    changes_description = {
-        "new-feature": "Newly added functionalities.",
-        "deprecation": "Deprecated code scheduled to be removed after two minor releases.",
-        "removal": "Removal of deprecated code.",
-        "behavior": "Changes in the expected default behavior.",
-        "api": "Changes to the API which didn't went through the proper deprecation and removal cycle.",
-        "abi": "Changes that cause ABI incompatibility but are still API compatible.",
-    }
-
-    changes_labels = {
-        "breaks API": "api",
-        "breaks ABI": "abi",
-        "behavior": "behavior",
-        "deprecation": "deprecation",
-        "removal": "removal",
-    }
-
-    # change_log content
-    clog = []
-
-    # Infer version from tag
-    version = extract_version(tag)
-
-    # Find the commit date for writting the Title
-    cmd = ("git log -1 --format=%ai " + tag).split()
-    output = subprocess.run(cmd, cwd=FOLDER, stdout=subprocess.PIPE)
-    date = output.stdout.split()[0].decode()
-    tokens = date.split("-")
-    clog += [
-        "## *= "
-        + version
-        + " ("
-        + tokens[2]
-        + "."
-        + tokens[1]
-        + "."
-        + tokens[0]
-        + ") =*"
-    ]
-
-    # Map each PR into the approriate module and changes
-    modules = defaultdict(list)
-    changes = defaultdict(list)
-    module_re = re.compile("module: \S+")
-    changes_re = re.compile("changes: ")
-    feature_re = re.compile("new feature")
-
-    for pr in pr_info:
-
-        pr["modules"] = []
-        pr["changes"] = []
-
-        for label in pr["labels"]:
-            if module_re.fullmatch(label["name"]):
-                module = label["name"][8:]
-                pr["modules"].append(module)
-                modules[module].append(pr)
-
-            elif changes_re.match(label["name"]):
-                key = changes_labels[label["name"][9:]]
-                pr["changes"].append(key)
-                changes[key].append(pr)
-
-            elif feature_re.fullmatch(label["name"]):
-                pr["changes"].append("new-feature")
-                changes["new-feature"].append(pr)
-
-        # No labels defaults to section None
-        if not pr["modules"]:
-            modules[None].append(pr)
-            continue
-
-    # Generate Changes Summary
-    for key in changes_order:
-
-        # Skip empty sections
-        if not changes[key]:
-            continue
-
-        clog += ["\n### `" + changes_titles[key] + ":`\n"]
-
-        clog += ["*" + changes_description[key] + "*\n"]
-
-        for pr in changes[key]:
-            prefix = "".join(["[" + k + "]" for k in pr["modules"]])
-            if prefix:
-                prefix = "**" + prefix + "** "
-            clog += [
-                "* "
-                + prefix
-                + pr["title"]
-                + " [[#"
-                + str(pr["id"])
-                + "]]"
-                + "(https://github.com/PointCloudLibrary/pcl/pull/"
-                + str(pr["id"])
-                + ")"
-            ]
-
-    # Traverse Modules and generate each section's content
-    clog += ["\n### `Modules:`"]
-    for key in module_order:
-
-        # Skip empty sections
-        if not modules[key]:
-            continue
-
-        # if key:
-        clog += ["\n#### `" + module_titles[key] + ":`\n"]
-
-        for pr in modules[key]:
-            prefix = "".join(["[" + k + "]" for k in pr["changes"]])
-            if prefix:
-                prefix = "**" + prefix + "** "
-            clog += [
-                "* "
-                + prefix
-                + pr["title"]
-                + " [[#"
-                + str(pr["id"])
-                + "]]"
-                + "(https://github.com/PointCloudLibrary/pcl/pull/"
-                + str(pr["id"])
-                + ")"
-            ]
-
-    return clog
-
-
-def parse_arguments():
-
-    parser = ArgumentParser(
-        description="Generate a change log between two "
-        "revisions.\n\nCheck https://github.com/PointCloudLibrary/pcl/wiki/Preparing-Releases#creating-the-change-log "
-        "for some additional examples on how to use the tool."
-    )
-    parser.add_argument(
-        "start",
-        help="The start (exclusive) " "revision/commit/tag to generate the log.",
-    )
-    parser.add_argument(
-        "end",
-        nargs="?",
-        default="HEAD",
-        help="The end "
-        "(inclusive) revision/commit/tag to generate the log. "
-        "(Defaults to HEAD)",
-    )
-    parser.add_argument(
-        "--username",
-        help="GitHub Account user name. If "
-        "specified it will perform requests with the provided credentials. "
-        "This is often required in order to overcome GitHub API's request "
-        "limits.",
-    )
-    meg = parser.add_mutually_exclusive_group()
-    meg.add_argument(
-        "--cache",
-        nargs="?",
-        const="pr_info.json",
-        metavar="FILE",
-        help="Caches the PR info extracted from GitHub into a JSON file. "
-        "(Defaults to 'pr_info.json')",
-    )
-    meg.add_argument(
-        "--from-cache",
-        nargs="?",
-        const="pr_info.json",
-        metavar="FILE",
-        help="Uses a previously generated PR info JSON cache "
-        "file to generate the change log. (Defaults to 'pr_info.json')",
-    )
-
-    # Parse arguments
-    args = parser.parse_args()
-    args.auth = None
-
-    if args.username:
-        password = getpass.getpass(prompt="Password for " + args.username + ": ")
-        args.auth = (args.username, password)
-
-    return args
-
-
-##
-##  'main'
-##
-
-FOLDER = find_pcl_folder()
-
-# Parse arguments
-args = parse_arguments()
-
-pr_info = None
-if not args.from_cache:
-
-    # Find all PRs since tag
-    prs = find_pr_list(start=args.start, end=args.end)
-
-    # Generate pr objects with title, labels from ids
-    pr_info = fetch_pr_info(prs, auth=args.auth)
-    if args.cache:
-        with open(args.cache, "w") as fp:
-            d = {"start": args.start, "end": args.end, "pr_info": pr_info}
-            fp.write(json.dumps(d))
-else:
-    # Load previously cached info
-    with open(args.from_cache) as fp:
-        d = json.loads(fp.read())
-        pr_info = d["pr_info"]
-        args.start = d["start"]
-        args.end = d["start"]
-
-
-# Generate text content based on changes
-clog = generate_text_content(tag=args.end, pr_info=pr_info)
-print("\n".join(clog))
index 3ee3c8e19545d5d0caa8ff2dba70d7cea2d32e06..9b5f827f81bf1dcfb3c1bba8a7ce96f4f6796c58 100644 (file)
@@ -38,6 +38,7 @@
 #pragma once
 
 #include <pcl/filters/filter.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
index 504e31e905d6345351c9352536009b7074abeac8..d606d91242a8f0cc3537e6573d650cacb75ef87a 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <pcl/2d/convolution.h>
 #include <pcl/2d/kernel.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 
index 33198406a73d95ddd887874b0175bb9f0d9d4976..22794b336b9f5ca0b0ea093c1e2b4eb4082a6d0f 100644 (file)
  *
  */
 
-#ifndef PCL_2D_CONVOLUTION_IMPL_HPP
-#define PCL_2D_CONVOLUTION_IMPL_HPP
+#pragma once
+
+#include <pcl/2d/convolution.h>
+
+namespace pcl {
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Convolution<PointT>::filter(pcl::PointCloud<PointT>& output)
+Convolution<PointT>::filter(pcl::PointCloud<PointT>& output)
 {
   int input_row = 0;
   int input_col = 0;
@@ -133,5 +135,4 @@ pcl::Convolution<PointT>::filter(pcl::PointCloud<PointT>& output)
   }
   } // switch
 }
-
-#endif
+} // namespace pcl
index ded9f6980e2170106905711d96a49e96a3ec856b..6bbe9ef66806f4c6a8ac71c6753f280c9393363b 100644 (file)
  *
  */
 
-#ifndef PCL_2D_EDGE_IMPL_HPP
-#define PCL_2D_EDGE_IMPL_HPP
+#pragma once
 
 #include <pcl/2d/convolution.h>
+#include <pcl/2d/edge.h>
 #include <pcl/common/common_headers.h> // rad2deg()
 
-//////////////////////////////////////////////////////////////////////////////
+namespace pcl {
+
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::detectEdgeSobel(pcl::PointCloud<PointOutT>& output)
+Edge<PointInT, PointOutT>::detectEdgeSobel(pcl::PointCloud<PointOutT>& output)
 {
   convolution_.setInputCloud(input_);
   pcl::PointCloud<PointXYZI>::Ptr kernel_x(new pcl::PointCloud<PointXYZI>);
@@ -79,10 +80,9 @@ pcl::Edge<PointInT, PointOutT>::detectEdgeSobel(pcl::PointCloud<PointOutT>& outp
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::sobelMagnitudeDirection(
+Edge<PointInT, PointOutT>::sobelMagnitudeDirection(
     const pcl::PointCloud<PointInT>& input_x,
     const pcl::PointCloud<PointInT>& input_y,
     pcl::PointCloud<PointOutT>& output)
@@ -121,10 +121,9 @@ pcl::Edge<PointInT, PointOutT>::sobelMagnitudeDirection(
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::detectEdgePrewitt(pcl::PointCloud<PointOutT>& output)
+Edge<PointInT, PointOutT>::detectEdgePrewitt(pcl::PointCloud<PointOutT>& output)
 {
   convolution_.setInputCloud(input_);
 
@@ -160,10 +159,9 @@ pcl::Edge<PointInT, PointOutT>::detectEdgePrewitt(pcl::PointCloud<PointOutT>& ou
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::detectEdgeRoberts(pcl::PointCloud<PointOutT>& output)
+Edge<PointInT, PointOutT>::detectEdgeRoberts(pcl::PointCloud<PointOutT>& output)
 {
   convolution_.setInputCloud(input_);
 
@@ -199,10 +197,9 @@ pcl::Edge<PointInT, PointOutT>::detectEdgeRoberts(pcl::PointCloud<PointOutT>& ou
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::cannyTraceEdge(
+Edge<PointInT, PointOutT>::cannyTraceEdge(
     int rowOffset, int colOffset, int row, int col, pcl::PointCloud<PointXYZI>& maxima)
 {
   int newRow = row + rowOffset;
@@ -226,10 +223,9 @@ pcl::Edge<PointInT, PointOutT>::cannyTraceEdge(
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::discretizeAngles(pcl::PointCloud<PointOutT>& thet)
+Edge<PointInT, PointOutT>::discretizeAngles(pcl::PointCloud<PointOutT>& thet)
 {
   const int height = thet.height;
   const int width = thet.width;
@@ -253,10 +249,9 @@ pcl::Edge<PointInT, PointOutT>::discretizeAngles(pcl::PointCloud<PointOutT>& the
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::suppressNonMaxima(
+Edge<PointInT, PointOutT>::suppressNonMaxima(
     const pcl::PointCloud<PointXYZIEdge>& edges,
     pcl::PointCloud<PointXYZI>& maxima,
     float tLow)
@@ -312,10 +307,9 @@ pcl::Edge<PointInT, PointOutT>::suppressNonMaxima(
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::detectEdgeCanny(pcl::PointCloud<PointOutT>& output)
+Edge<PointInT, PointOutT>::detectEdgeCanny(pcl::PointCloud<PointOutT>& output)
 {
   float tHigh = hysteresis_threshold_high_;
   float tLow = hysteresis_threshold_low_;
@@ -377,12 +371,11 @@ pcl::Edge<PointInT, PointOutT>::detectEdgeCanny(pcl::PointCloud<PointOutT>& outp
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::canny(const pcl::PointCloud<PointInT>& input_x,
-                                      const pcl::PointCloud<PointInT>& input_y,
-                                      pcl::PointCloud<PointOutT>& output)
+Edge<PointInT, PointOutT>::canny(const pcl::PointCloud<PointInT>& input_x,
+                                 const pcl::PointCloud<PointInT>& input_y,
+                                 pcl::PointCloud<PointOutT>& output)
 {
   float tHigh = hysteresis_threshold_high_;
   float tLow = hysteresis_threshold_low_;
@@ -452,12 +445,11 @@ pcl::Edge<PointInT, PointOutT>::canny(const pcl::PointCloud<PointInT>& input_x,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT>
 void
-pcl::Edge<PointInT, PointOutT>::detectEdgeLoG(const float kernel_sigma,
-                                              const float kernel_size,
-                                              pcl::PointCloud<PointOutT>& output)
+Edge<PointInT, PointOutT>::detectEdgeLoG(const float kernel_sigma,
+                                         const float kernel_size,
+                                         pcl::PointCloud<PointOutT>& output)
 {
   convolution_.setInputCloud(input_);
 
@@ -470,4 +462,4 @@ pcl::Edge<PointInT, PointOutT>::detectEdgeLoG(const float kernel_sigma,
   convolution_.filter(output);
 }
 
-#endif
+} // namespace pcl
index d85de7e6913d38c2868292f1202e0bb55350fb8c..0be57ff4302c2e5ed6b5eb680d2e1924fe9bed18 100644 (file)
  *
  */
 
-#ifndef PCL_2D_KERNEL_IMPL_HPP
-#define PCL_2D_KERNEL_IMPL_HPP
+#pragma once
+
+#include <pcl/2d/kernel.h>
+
+namespace pcl {
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::fetchKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::fetchKernel(pcl::PointCloud<PointT>& kernel)
 {
   switch (kernel_type_) {
   case SOBEL_X:
@@ -89,10 +91,9 @@ pcl::kernel<PointT>::fetchKernel(pcl::PointCloud<PointT>& kernel)
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::gaussianKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::gaussianKernel(pcl::PointCloud<PointT>& kernel)
 {
   float sum = 0;
   kernel.resize(kernel_size_ * kernel_size_);
@@ -116,13 +117,11 @@ pcl::kernel<PointT>::gaussianKernel(pcl::PointCloud<PointT>& kernel)
     kernel[i].intensity /= sum;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::loGKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::loGKernel(pcl::PointCloud<PointT>& kernel)
 {
   float sum = 0;
-  float temp = 0;
   kernel.resize(kernel_size_ * kernel_size_);
   kernel.height = kernel_size_;
   kernel.width = kernel_size_;
@@ -133,7 +132,7 @@ pcl::kernel<PointT>::loGKernel(pcl::PointCloud<PointT>& kernel)
     for (int j = 0; j < kernel_size_; j++) {
       int iks = (i - kernel_size_ / 2);
       int jks = (j - kernel_size_ / 2);
-      temp = float(double(iks * iks + jks * jks) / sigma_sqr);
+      float temp = float(double(iks * iks + jks * jks) / sigma_sqr);
       kernel(j, i).intensity = (1.0f - temp) * std::exp(-temp);
       sum += kernel(j, i).intensity;
     }
@@ -144,10 +143,9 @@ pcl::kernel<PointT>::loGKernel(pcl::PointCloud<PointT>& kernel)
     kernel[i].intensity /= sum;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::sobelKernelX(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::sobelKernelX(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(9);
   kernel.height = 3;
@@ -163,10 +161,9 @@ pcl::kernel<PointT>::sobelKernelX(pcl::PointCloud<PointT>& kernel)
   kernel(2, 2).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::prewittKernelX(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::prewittKernelX(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(9);
   kernel.height = 3;
@@ -182,10 +179,9 @@ pcl::kernel<PointT>::prewittKernelX(pcl::PointCloud<PointT>& kernel)
   kernel(2, 2).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::robertsKernelX(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::robertsKernelX(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(4);
   kernel.height = 2;
@@ -196,10 +192,9 @@ pcl::kernel<PointT>::robertsKernelX(pcl::PointCloud<PointT>& kernel)
   kernel(1, 1).intensity = -1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::sobelKernelY(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::sobelKernelY(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(9);
   kernel.height = 3;
@@ -215,10 +210,9 @@ pcl::kernel<PointT>::sobelKernelY(pcl::PointCloud<PointT>& kernel)
   kernel(2, 2).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::prewittKernelY(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::prewittKernelY(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(9);
   kernel.height = 3;
@@ -236,7 +230,7 @@ pcl::kernel<PointT>::prewittKernelY(pcl::PointCloud<PointT>& kernel)
 
 template <typename PointT>
 void
-pcl::kernel<PointT>::robertsKernelY(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::robertsKernelY(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(4);
   kernel.height = 2;
@@ -247,10 +241,9 @@ pcl::kernel<PointT>::robertsKernelY(pcl::PointCloud<PointT>& kernel)
   kernel(1, 1).intensity = 0;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::derivativeXCentralKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::derivativeXCentralKernel(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(3);
   kernel.height = 1;
@@ -260,10 +253,9 @@ pcl::kernel<PointT>::derivativeXCentralKernel(pcl::PointCloud<PointT>& kernel)
   kernel(2, 0).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::derivativeXForwardKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::derivativeXForwardKernel(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(3);
   kernel.height = 1;
@@ -273,10 +265,9 @@ pcl::kernel<PointT>::derivativeXForwardKernel(pcl::PointCloud<PointT>& kernel)
   kernel(2, 0).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::derivativeXBackwardKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::derivativeXBackwardKernel(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(3);
   kernel.height = 1;
@@ -286,10 +277,9 @@ pcl::kernel<PointT>::derivativeXBackwardKernel(pcl::PointCloud<PointT>& kernel)
   kernel(2, 0).intensity = 0;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::derivativeYCentralKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::derivativeYCentralKernel(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(3);
   kernel.height = 3;
@@ -299,10 +289,9 @@ pcl::kernel<PointT>::derivativeYCentralKernel(pcl::PointCloud<PointT>& kernel)
   kernel(0, 2).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::derivativeYForwardKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::derivativeYForwardKernel(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(3);
   kernel.height = 3;
@@ -312,10 +301,9 @@ pcl::kernel<PointT>::derivativeYForwardKernel(pcl::PointCloud<PointT>& kernel)
   kernel(0, 2).intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::derivativeYBackwardKernel(pcl::PointCloud<PointT>& kernel)
+kernel<PointT>::derivativeYBackwardKernel(pcl::PointCloud<PointT>& kernel)
 {
   kernel.resize(3);
   kernel.height = 3;
@@ -325,29 +313,25 @@ pcl::kernel<PointT>::derivativeYBackwardKernel(pcl::PointCloud<PointT>& kernel)
   kernel(0, 2).intensity = 0;
 }
 
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::setKernelType(KERNEL_ENUM kernel_type)
+kernel<PointT>::setKernelType(KERNEL_ENUM kernel_type)
 {
   kernel_type_ = kernel_type;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::setKernelSize(int kernel_size)
+kernel<PointT>::setKernelSize(int kernel_size)
 {
   kernel_size_ = kernel_size;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::kernel<PointT>::setKernelSigma(float kernel_sigma)
+kernel<PointT>::setKernelSigma(float kernel_sigma)
 {
   sigma_ = kernel_sigma;
 }
 
-#endif
+} // namespace pcl
index fd8235d7d34e57bd2afeb57b0b6845879421e9d3..a89596761be16418f324f05efe30265a214ed78e 100644 (file)
  *      Author: somani
  */
 
-#ifndef PCL_2D_KEYPOINT_HPP_
-#define PCL_2D_KEYPOINT_HPP_
+#pragma once
 
-#include <limits>
 #include <pcl/2d/convolution.h>
 #include <pcl/2d/edge.h>
+#include <pcl/2d/keypoint.h> // for pcl::Keypoint
+
+#include <limits>
 
-//////////////////////////////////////////////////////////////////////////////
+namespace pcl {
+
+template <typename ImageType>
 void
-pcl::keypoint::harrisCorner(ImageType& output,
-                            ImageType& input,
-                            const float sigma_d,
-                            const float sigma_i,
-                            const float alpha,
-                            const float thresh)
+Keypoint<ImageType>::harrisCorner(ImageType& output,
+                                  ImageType& input,
+                                  const float sigma_d,
+                                  const float sigma_i,
+                                  const float alpha,
+                                  const float thresh)
 {
-
   /*creating the gaussian kernels*/
   ImageType kernel_d;
   ImageType kernel_i;
@@ -115,12 +117,12 @@ pcl::keypoint::harrisCorner(ImageType& output,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
+template <typename ImageType>
 void
-pcl::keypoint::hessianBlob(ImageType& output,
-                           ImageType& input,
-                           const float sigma,
-                           bool SCALED)
+Keypoint<ImageType>::hessianBlob(ImageType& output,
+                                 ImageType& input,
+                                 const float sigma,
+                                 bool SCALED)
 {
   /*creating the gaussian kernels*/
   ImageType kernel, cornerness;
@@ -175,13 +177,13 @@ pcl::keypoint::hessianBlob(ImageType& output,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
+template <typename ImageType>
 void
-pcl::keypoint::hessianBlob(ImageType& output,
-                           ImageType& input,
-                           const float start_scale,
-                           const float scaling_factor,
-                           const int num_scales)
+Keypoint<ImageType>::hessianBlob(ImageType& output,
+                                 ImageType& input,
+                                 const float start_scale,
+                                 const float scaling_factor,
+                                 const int num_scales)
 {
   const std::size_t height = input.size();
   const std::size_t width = input[0].size();
@@ -193,17 +195,15 @@ pcl::keypoint::hessianBlob(ImageType& output,
     hessianBlob(cornerness[i], input, scale, false);
     scale *= scaling_factor;
   }
-  bool non_max_flag = false;
-  float scale_max, local_max;
   for (std::size_t i = 0; i < height; i++) {
     for (std::size_t j = 0; j < width; j++) {
-      scale_max = std::numeric_limits<float>::min();
+      float scale_max = std::numeric_limits<float>::min();
       /*default output in case of no blob at the current point is 0*/
       output[i][j] = 0;
       for (int k = 0; k < num_scales; k++) {
         /*check if the current point (k,i,j) is a maximum in the defined search radius*/
-        non_max_flag = false;
-        local_max = cornerness[k][i][j];
+        bool non_max_flag = false;
+        const float local_max = cornerness[k][i][j];
         for (int n = -local_search_radius; n <= local_search_radius; n++) {
           if (n + k < 0 || n + k >= num_scales)
             continue;
@@ -231,7 +231,7 @@ pcl::keypoint::hessianBlob(ImageType& output,
             scale_max = cornerness[k][i][j];
             /*output indicates the scale at which the blob is found at the current
              * location in the image*/
-            output[i][i] = start_scale * pow(scaling_factor, k);
+            output[i][j] = start_scale * pow(scaling_factor, k);
           }
         }
       }
@@ -239,11 +239,11 @@ pcl::keypoint::hessianBlob(ImageType& output,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
+template <typename ImageType>
 void
-pcl::keypoint::imageElementMultiply(ImageType& output,
-                                    ImageType& input1,
-                                    ImageType& input2)
+Keypoint<ImageType>::imageElementMultiply(ImageType& output,
+                                          ImageType& input1,
+                                          ImageType& input2)
 {
   const std::size_t height = input1.size();
   const std::size_t width = input1[0].size();
@@ -255,5 +255,4 @@ pcl::keypoint::imageElementMultiply(ImageType& output,
     }
   }
 }
-
-#endif // PCL_2D_KEYPOINT_HPP_
+} // namespace pcl
index 4def02de4a2f1acb3f26f45586ce628a4640f604..126c93293bf5d0fd2de52cf93e34f82ee1f2a742 100644 (file)
  *
  */
 
-#ifndef PCL_2D_MORPHOLOGY_HPP_
-#define PCL_2D_MORPHOLOGY_HPP_
+#pragma once
+
+#include <pcl/2d/morphology.h>
+
+namespace pcl {
 
-//////////////////////////////////////////////////////////////////////////////
 // Assumes input, kernel and output images have 0's and 1's only
 template <typename PointT>
 void
-pcl::Morphology<PointT>::erosionBinary(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::erosionBinary(pcl::PointCloud<PointT>& output)
 {
   const int height = input_->height;
   const int width = input_->width;
@@ -90,11 +92,10 @@ pcl::Morphology<PointT>::erosionBinary(pcl::PointCloud<PointT>& output)
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 // Assumes input, kernel and output images have 0's and 1's only
 template <typename PointT>
 void
-pcl::Morphology<PointT>::dilationBinary(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::dilationBinary(pcl::PointCloud<PointT>& output)
 {
   const int height = input_->height;
   const int width = input_->width;
@@ -136,11 +137,10 @@ pcl::Morphology<PointT>::dilationBinary(pcl::PointCloud<PointT>& output)
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 // Assumes input, kernel and output images have 0's and 1's only
 template <typename PointT>
 void
-pcl::Morphology<PointT>::openingBinary(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::openingBinary(pcl::PointCloud<PointT>& output)
 {
   PointCloudInPtr intermediate_output(new PointCloudIn);
   erosionBinary(*intermediate_output);
@@ -148,11 +148,10 @@ pcl::Morphology<PointT>::openingBinary(pcl::PointCloud<PointT>& output)
   dilationBinary(output);
 }
 
-//////////////////////////////////////////////////////////////////////////////
 // Assumes input, kernel and output images have 0's and 1's only
 template <typename PointT>
 void
-pcl::Morphology<PointT>::closingBinary(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::closingBinary(pcl::PointCloud<PointT>& output)
 {
   PointCloudInPtr intermediate_output(new PointCloudIn);
   dilationBinary(*intermediate_output);
@@ -160,10 +159,9 @@ pcl::Morphology<PointT>::closingBinary(pcl::PointCloud<PointT>& output)
   erosionBinary(output);
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::erosionGray(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::erosionGray(pcl::PointCloud<PointT>& output)
 {
   const int height = input_->height;
   const int width = input_->width;
@@ -203,10 +201,9 @@ pcl::Morphology<PointT>::erosionGray(pcl::PointCloud<PointT>& output)
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::dilationGray(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::dilationGray(pcl::PointCloud<PointT>& output)
 {
   const int height = input_->height;
   const int width = input_->width;
@@ -247,10 +244,9 @@ pcl::Morphology<PointT>::dilationGray(pcl::PointCloud<PointT>& output)
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::openingGray(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::openingGray(pcl::PointCloud<PointT>& output)
 {
   PointCloudInPtr intermediate_output(new PointCloudIn);
   erosionGray(*intermediate_output);
@@ -258,10 +254,9 @@ pcl::Morphology<PointT>::openingGray(pcl::PointCloud<PointT>& output)
   dilationGray(output);
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::closingGray(pcl::PointCloud<PointT>& output)
+Morphology<PointT>::closingGray(pcl::PointCloud<PointT>& output)
 {
   PointCloudInPtr intermediate_output(new PointCloudIn);
   dilationGray(*intermediate_output);
@@ -269,12 +264,11 @@ pcl::Morphology<PointT>::closingGray(pcl::PointCloud<PointT>& output)
   erosionGray(output);
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::subtractionBinary(pcl::PointCloud<PointT>& output,
-                                           const pcl::PointCloud<PointT>& input1,
-                                           const pcl::PointCloud<PointT>& input2)
+Morphology<PointT>::subtractionBinary(pcl::PointCloud<PointT>& output,
+                                      const pcl::PointCloud<PointT>& input1,
+                                      const pcl::PointCloud<PointT>& input2)
 {
   const int height = (input1.height < input2.height) ? input1.height : input2.height;
   const int width = (input1.width < input2.width) ? input1.width : input2.width;
@@ -290,12 +284,11 @@ pcl::Morphology<PointT>::subtractionBinary(pcl::PointCloud<PointT>& output,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::unionBinary(pcl::PointCloud<PointT>& output,
-                                     const pcl::PointCloud<PointT>& input1,
-                                     const pcl::PointCloud<PointT>& input2)
+Morphology<PointT>::unionBinary(pcl::PointCloud<PointT>& output,
+                                const pcl::PointCloud<PointT>& input1,
+                                const pcl::PointCloud<PointT>& input2)
 {
   const int height = (input1.height < input2.height) ? input1.height : input2.height;
   const int width = (input1.width < input2.width) ? input1.width : input2.width;
@@ -311,12 +304,11 @@ pcl::Morphology<PointT>::unionBinary(pcl::PointCloud<PointT>& output,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::intersectionBinary(pcl::PointCloud<PointT>& output,
-                                            const pcl::PointCloud<PointT>& input1,
-                                            const pcl::PointCloud<PointT>& input2)
+Morphology<PointT>::intersectionBinary(pcl::PointCloud<PointT>& output,
+                                       const pcl::PointCloud<PointT>& input1,
+                                       const pcl::PointCloud<PointT>& input2)
 {
   const int height = (input1.height < input2.height) ? input1.height : input2.height;
   const int width = (input1.width < input2.width) ? input1.width : input2.width;
@@ -332,11 +324,10 @@ pcl::Morphology<PointT>::intersectionBinary(pcl::PointCloud<PointT>& output,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::structuringElementCircular(pcl::PointCloud<PointT>& kernel,
-                                                    const int radius)
+Morphology<PointT>::structuringElementCircular(pcl::PointCloud<PointT>& kernel,
+                                               const int radius)
 {
   const int dim = 2 * radius;
   kernel.height = dim;
@@ -353,12 +344,11 @@ pcl::Morphology<PointT>::structuringElementCircular(pcl::PointCloud<PointT>& ker
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::structuringElementRectangle(pcl::PointCloud<PointT>& kernel,
-                                                     const int height,
-                                                     const int width)
+Morphology<PointT>::structuringElementRectangle(pcl::PointCloud<PointT>& kernel,
+                                                const int height,
+                                                const int width)
 {
   kernel.height = height;
   kernel.width = width;
@@ -367,13 +357,11 @@ pcl::Morphology<PointT>::structuringElementRectangle(pcl::PointCloud<PointT>& ke
     kernel[i].intensity = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 void
-pcl::Morphology<PointT>::setStructuringElement(
-    const PointCloudInPtr& structuring_element)
+Morphology<PointT>::setStructuringElement(const PointCloudInPtr& structuring_element)
 {
   structuring_element_ = structuring_element;
 }
 
-#endif // PCL_2D_MORPHOLOGY_HPP_
+} // namespace pcl
index a7c454d97b21bc236314c3fd48b890003cf418e4..ca889e06f64a93a7f9ff1d59813d671b9e552c65 100644 (file)
 
 namespace pcl {
 
+template <typename ImageType>
 class Keypoint {
 private:
-  Edge edge_detection;
-  Convolution conv_2d;
+  Edge<ImageType, ImageType> edge_detection;
+  Convolution<ImageType> conv_2d;
 
 public:
   Keypoint() {}
index 8135ba582d87b73648ea44b5372d0bf92c75ac2b..c5851b4ee3b174c6188a84c826e3e1e5782020cb 100644 (file)
  *  $Id$
  */
 
-#include <pcl/point_types.h>
-
 #include <pcl/2d/convolution.h>
 #include <pcl/2d/edge.h>
 #include <pcl/2d/kernel.h>
 #include <pcl/2d/morphology.h>
 #include <pcl/pcl_base.h>
+#include <pcl/point_types.h>
 
 using namespace pcl;
 
index bed9a7b5788caf20c3656ecb021f7ac5c03cda53..d8dfde37634b5fe237a5709d4207ec7e42279fed 100644 (file)
@@ -1,3 +1,2 @@
 PCL is a large collaborative effort, and it would not exist without the contributions of several people.
  Please see https://github.com/PointCloudLibrary/pcl/graphs/contributors for a complete list of developers.
-
index af5ec2aaa20c0358658d23ab607bd5c57547d4f9..01a7ad91e8701f349cab534b5b142c2bae4913b5 100644 (file)
@@ -1,5 +1,187 @@
 # ChangeList
 
+## = 1.11.0 (11.05.2020) =
+
+Starting with PCL 1.11, PCL uses `std::shared_ptr` and `std::weak_ptr` instead of the
+boost smart pointers. The change leverages type aliases included with the 1.10.0
+release. PCL 1.11 also introduces `pcl::index_t` which should be used for the size
+of point types instead of `int`, `std::size_t`, etc. EOL for deprecated features
+is also explicitly mentioned in the deprecation compile time warnings
+
+### Notable changes
+
+**New features** *added to PCL*
+
+* **[common]** Provide dynamic and static pointer casts in namespace pcl to allow easy migration in future [[#3770](https://github.com/PointCloudLibrary/pcl/pull/3770)]
+* **[common]** Add `ignore` function to remove Doxygen warnings for unused arguments [[#3942](https://github.com/PointCloudLibrary/pcl/pull/3942)]
+* **[docs]** Generate TODO list [[#3937](https://github.com/PointCloudLibrary/pcl/pull/3937)]
+* Force include order via clang-format [[#3909](https://github.com/PointCloudLibrary/pcl/pull/3909)]
+* Change PCL smart pointers from `boost` to `std` [[#3750](https://github.com/PointCloudLibrary/pcl/pull/3750)]
+* **[ci]** Add pipeline for building PCL's environment docker image [[#3843](https://github.com/PointCloudLibrary/pcl/pull/3843)]
+
+**Deprecation** *of public APIs, scheduled to be removed after two minor releases*
+
+* **[common]** Remove `#undef Success` in pcl_macros.h by extracting `PCL_MAKE_ALIGNED_OPERATOR_NEW` into memory.h [[#3654](https://github.com/PointCloudLibrary/pcl/pull/3654)]
+* **[common]** Rename `point_traits.h` into `type_traits.h` [[#3698](https://github.com/PointCloudLibrary/pcl/pull/3698)]
+* **[filters]** Deprecating functions in non-speclialized Passthrough filter [[#3888](https://github.com/PointCloudLibrary/pcl/pull/3888)]
+* **[outofcore][registration]** Homogenize deprecation with PCL_DEPRECATED [[#3925](https://github.com/PointCloudLibrary/pcl/pull/3925)]
+* **[cmake][visualization]** Deprecate legacy OpenGL backend of VTK [[#4065](https://github.com/PointCloudLibrary/pcl/pull/4065)]
+
+**Removal** *of the public APIs deprecated in previous releases*
+
+* **[io][recognition][tools]** Remove very old deprecated headers [[#3906](https://github.com/PointCloudLibrary/pcl/pull/3906)]
+* **[docs]** Remove backup (and defunct) `CMakeLists.txt` [[#3915](https://github.com/PointCloudLibrary/pcl/pull/3915)]
+* Remove use of VTK_EXCLUDE_STRSTREAM_HEADERS (unavailable since VTK 6.0.0) [[#3939](https://github.com/PointCloudLibrary/pcl/pull/3939)]
+
+**Behavior changes** *in classes, apps, or tools*
+
+* **[io]** Make grabbers move-only using `unique_ptr` [[#3626](https://github.com/PointCloudLibrary/pcl/pull/3626)]
+
+**API changes** *that did not go through the proper deprecation and removal cycle*
+
+* **[io]** Make grabbers move-only using `unique_ptr` [[#3626](https://github.com/PointCloudLibrary/pcl/pull/3626)]
+* **[common]** Add `pcl::index_t`; move some type declarations from `pcl/pcl_macros.h` to `pcl/types.h` [[#3651](https://github.com/PointCloudLibrary/pcl/pull/3651)]
+* **[filters]** Clean up `Filter` and `FilterIndices`, move `indices_`/`input_` from public to protected section [[#3726](https://github.com/PointCloudLibrary/pcl/pull/3726)]
+* **[registration]** Better Generalized ICP optimizer gradient check management [[#3854](https://github.com/PointCloudLibrary/pcl/pull/3854)]
+* Change PCL smart pointers from `boost` to `std` [[#3750](https://github.com/PointCloudLibrary/pcl/pull/3750)]
+* **[registration]** Removing deprecated method `setInputCloud`  from public API [[#4026](https://github.com/PointCloudLibrary/pcl/pull/4026)]
+
+**ABI changes** *that are still API compatible*
+
+* **[filters]** NormalSpaceSampling - fix bucket assignment, remove use of raw distribution pointer, unit-test rewriting [[#3862](https://github.com/PointCloudLibrary/pcl/pull/3862)]
+* **[io]** Add pcl::weak_ptr to have a single-switch move from boost:: to std:: weak pointers [[#3753](https://github.com/PointCloudLibrary/pcl/pull/3753)]
+
+### Changes grouped by module
+
+#### CMake:
+
+* Add a stamp file to build documentation once [[#3819](https://github.com/PointCloudLibrary/pcl/pull/3819)]
+* Fix compilation in OSX Catalina with OMP enabled [[#3721](https://github.com/PointCloudLibrary/pcl/pull/3721)]
+* Show proper message in CMake config for default-off modules [[#3927](https://github.com/PointCloudLibrary/pcl/pull/3927)]
+* **[deprecation]** Deprecate legacy OpenGL backend of VTK [[#4065](https://github.com/PointCloudLibrary/pcl/pull/4065)]
+
+#### libpcl_2d:
+
+* variable assigned a value which is never used [[#3857](https://github.com/PointCloudLibrary/pcl/pull/3857)]
+* Fix issue with missing templating of `Keypoint`. Fixes coming from clang-doxy [[#3898](https://github.com/PointCloudLibrary/pcl/pull/3898)]
+
+#### libpcl_common:
+
+* **[deprecation]** Remove `#undef Success` in pcl_macros.h by extracting `PCL_MAKE_ALIGNED_OPERATOR_NEW` into memory.h [[#3654](https://github.com/PointCloudLibrary/pcl/pull/3654)]
+* Fix issues with math defines on mingw-w64. [[#3756](https://github.com/PointCloudLibrary/pcl/pull/3756)]
+* **[API break]** Add `pcl::index_t`; move some type declarations from `pcl/pcl_macros.h` to `pcl/types.h` [[#3651](https://github.com/PointCloudLibrary/pcl/pull/3651)]
+* **[deprecation]** Rename `point_traits.h` into `type_traits.h` [[#3698](https://github.com/PointCloudLibrary/pcl/pull/3698)]
+* Improve `PCL_DEPRECATED` macro to include scheduled removal version [[#3808](https://github.com/PointCloudLibrary/pcl/pull/3808)]
+* Fix erroneous PCL version in deprecated message [[#3824](https://github.com/PointCloudLibrary/pcl/pull/3824)]
+* Select OpenMP data sharing mode based on specific GCC versions [[#3823](https://github.com/PointCloudLibrary/pcl/pull/3823)]
+* Define `PointIndices` based on the global `Indices` type alias [[#3822](https://github.com/PointCloudLibrary/pcl/pull/3822)]
+* Fix warning C4067: unexpected tokens following preprocessor directive- expected a newline [[#3871](https://github.com/PointCloudLibrary/pcl/pull/3871)]
+* **[new feature]** Provide dynamic and static pointer casts in namespace pcl to allow easy migration in future [[#3770](https://github.com/PointCloudLibrary/pcl/pull/3770)]
+* **[new feature]** Add `ignore` function to remove Doxygen warnings for unused arguments [[#3942](https://github.com/PointCloudLibrary/pcl/pull/3942)]
+* Fix excessive warnings on MSVC [[#3964](https://github.com/PointCloudLibrary/pcl/pull/3964)]
+* Refactoring `PCL_DEPRECATED` macro [[#3945](https://github.com/PointCloudLibrary/pcl/pull/3945)]
+* Correcting type mismatch [[#3967](https://github.com/PointCloudLibrary/pcl/pull/3967)]
+* Removed empty file [[#4019](https://github.com/PointCloudLibrary/pcl/pull/4019)]
+
+#### libpcl_filters:
+
+* Clean up code duplication in `FilterIndices` derived classes [[#3807](https://github.com/PointCloudLibrary/pcl/pull/3807)]
+* **[API break]** Clean up `Filter` and `FilterIndices`, move `indices_`/`input_` from public to protected section [[#3726](https://github.com/PointCloudLibrary/pcl/pull/3726)]
+* **[deprecation]** Deprecating functions in non-speclialized Passthrough filter [[#3888](https://github.com/PointCloudLibrary/pcl/pull/3888)]
+* **[ABI break]** NormalSpaceSampling - fix bucket assignment, remove use of raw distribution pointer, unit-test rewriting [[#3862](https://github.com/PointCloudLibrary/pcl/pull/3862)]
+* Optimize VoxelGrid Filter [[#3853](https://github.com/PointCloudLibrary/pcl/pull/3853)]
+* Fix error due to multiple declarations of template member function specializations in convolution [[#3971](https://github.com/PointCloudLibrary/pcl/pull/3971)]
+
+#### libpcl_io:
+
+* **[ABI break][API break][behavior change]** Make grabbers move-only using `unique_ptr` [[#3626](https://github.com/PointCloudLibrary/pcl/pull/3626)]
+* **[removal]** Remove very old deprecated headers [[#3906](https://github.com/PointCloudLibrary/pcl/pull/3906)]
+* **[ABI break]** Add pcl::weak_ptr to have a single-switch move from boost:: to std:: weak pointers [[#3753](https://github.com/PointCloudLibrary/pcl/pull/3753)]
+* Use pcl::io::raw_read instead of direct call to POSIX function read [[#4062](https://github.com/PointCloudLibrary/pcl/pull/4062)]
+
+#### libpcl_octree:
+
+* Fix a memory leak in `OctreeBase::operator=` [[#3787](https://github.com/PointCloudLibrary/pcl/pull/3787)]
+
+#### libpcl_outofcore:
+
+* **[deprecation]** Homogenize deprecation with PCL_DEPRECATED [[#3925](https://github.com/PointCloudLibrary/pcl/pull/3925)]
+
+#### libpcl_people:
+
+* Missing include on windows [[#3791](https://github.com/PointCloudLibrary/pcl/pull/3791)]
+
+#### libpcl_recognition:
+
+* **[removal]** Remove very old deprecated headers [[#3906](https://github.com/PointCloudLibrary/pcl/pull/3906)]
+
+#### libpcl_registration:
+
+* **[API break]** Better Generalized ICP optimizer gradient check management [[#3854](https://github.com/PointCloudLibrary/pcl/pull/3854)]
+* **[deprecation]** Homogenize deprecation with PCL_DEPRECATED [[#3925](https://github.com/PointCloudLibrary/pcl/pull/3925)]
+* **[API break]** Removing deprecated method `setInputCloud`  from public API [[#4026](https://github.com/PointCloudLibrary/pcl/pull/4026)]
+
+#### libpcl_sample_consensus:
+
+* Better performance, error handling and other improvements in SAC classes [[#3642](https://github.com/PointCloudLibrary/pcl/pull/3642)]
+* Use better types for indices: `int` -> `index_t`, `std::vector<int>` ->`Indices` [[#3835](https://github.com/PointCloudLibrary/pcl/pull/3835)]
+
+#### libpcl_search:
+
+* Use better types for indices: `int` -> `index_t`, `std::vector<int>` ->`Indices` [[#3840](https://github.com/PointCloudLibrary/pcl/pull/3840)]
+* Add include for `pcl::isFinite` for compilation on VS2019 [[#4056](https://github.com/PointCloudLibrary/pcl/pull/4056)]
+
+#### libpcl_segmentation:
+
+* Check and warn user about missing normals in `OrganizedMultiPlaneSegmentation` [[#3861](https://github.com/PointCloudLibrary/pcl/pull/3861)]
+
+#### libpcl_surface:
+
+* Fix error due to multiple declarations of template member function specializations in Poisson4 [[#3972](https://github.com/PointCloudLibrary/pcl/pull/3972)]
+* Reduce time taken in `TextureMapping::sortFacesByCamera` from `O(faces*points)` to `O(faces)` [[#3981](https://github.com/PointCloudLibrary/pcl/pull/3981)]
+
+#### libpcl_visualization:
+
+* Minor fix for converting unorganized PointClouds to VTK data [[#3988](https://github.com/PointCloudLibrary/pcl/pull/3988)]
+* Fixes #4001 and #3452. [[#4017](https://github.com/PointCloudLibrary/pcl/pull/4017)]
+* **[deprecation]** Deprecate legacy OpenGL backend of VTK [[#4065](https://github.com/PointCloudLibrary/pcl/pull/4065)]
+* Fix rendering of points. [[#4067](https://github.com/PointCloudLibrary/pcl/pull/4067)]
+
+#### PCL Docs:
+
+* Fix Doxygen warnings unrelated to documentation -- Part 1 [[#3701](https://github.com/PointCloudLibrary/pcl/pull/3701)]
+* update automatic code formatting info to clang-format [[#3845](https://github.com/PointCloudLibrary/pcl/pull/3845)]
+* replace formula with math [[#3846](https://github.com/PointCloudLibrary/pcl/pull/3846)]
+* Fix PCL_DEPRECATED usage in doxygen for a proper Deprecation List in documentation [[#3905](https://github.com/PointCloudLibrary/pcl/pull/3905)]
+* **[removal]** Remove backup (and defunct) `CMakeLists.txt` [[#3915](https://github.com/PointCloudLibrary/pcl/pull/3915)]
+* **[new feature]** Generate TODO list [[#3937](https://github.com/PointCloudLibrary/pcl/pull/3937)]
+* Improve output to match the text in tutorial by adding a newline [[#4029](https://github.com/PointCloudLibrary/pcl/pull/4029)]
+* Fix typo in region growing tutorial [[#4052](https://github.com/PointCloudLibrary/pcl/pull/4052)]
+* Add information regarding header include order [[#4020](https://github.com/PointCloudLibrary/pcl/pull/4020)]
+
+#### PCL Tutorials:
+
+* Add a unit test for ICP and modernize tutorial code [[#3628](https://github.com/PointCloudLibrary/pcl/pull/3628)]
+
+#### PCL Examples:
+
+* Remove unnecessary includes in examples [[#4071](https://github.com/PointCloudLibrary/pcl/pull/4071)]
+
+#### PCL Tools:
+
+* **[removal]** Remove very old deprecated headers [[#3906](https://github.com/PointCloudLibrary/pcl/pull/3906)]
+
+#### CI:
+
+* Temporary fix for skipping of certain tests [[#3789](https://github.com/PointCloudLibrary/pcl/pull/3789)]
+* Simplify Ubuntu CI using matrix strategy [[#3783](https://github.com/PointCloudLibrary/pcl/pull/3783)]
+* Strip leading tag in commit message from changelog [[#3847](https://github.com/PointCloudLibrary/pcl/pull/3847)]
+* Shift to clang-format-10 to resolve bug in clang-format-{7-9} [[#3895](https://github.com/PointCloudLibrary/pcl/pull/3895)]
+* **[new feature]** Add pipeline for building PCL's environment docker image [[#3843](https://github.com/PointCloudLibrary/pcl/pull/3843)]
+* Improve docker ci for other PRs [[#4051](https://github.com/PointCloudLibrary/pcl/pull/4051)]
+* Remove unused variables from exceptions [[#4064](https://github.com/PointCloudLibrary/pcl/pull/4064)]
+* Removing hardcoded version number from tutorial CI [[#4058](https://github.com/PointCloudLibrary/pcl/pull/4058)]
+
 ## *= 1.10.1 (18.03.2020) =*
 
 ### Notable changes
index f0bc23967b5cfc278888a3672ae8070ce4482fdb..aa59b760239c10db37a727f59c71f97a550f5499 100644 (file)
@@ -26,7 +26,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "")
   set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "build type default to RelWithDebInfo, set to Release to improve performance" FORCE)
 endif()
 
-project(PCL VERSION 1.10.1)
+project(PCL VERSION 1.11.0)
 string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
 
 ### ---[ Find universal dependencies
@@ -42,29 +42,9 @@ if(WIN32 AND NOT MINGW)
   set(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "Add postfix to target for MinSizeRel build")
 endif()
 
-# ---[ special maintainer mode
-set(CMAKE_CXX_FLAGS_MAINTAINER "-pedantic -Wno-variadic-macros -Weffc++ -Wno-long-long" CACHE STRING
-    "Flags used by the C++ compiler during maintainer builds."
-    FORCE)
-set(CMAKE_C_FLAGS_MAINTAINER "-pedantic -Wno-variadic-macros -Weffc++ -Wno-long-long" CACHE STRING
-    "Flags used by the C compiler during maintainer builds."
-    FORCE)
-set(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
-    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
-    "Flags used for linking binaries during maintainer builds."
-    FORCE)
-set(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
-    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
-    "Flags used by the shared libraries linker during maintainer builds."
-    FORCE)
-mark_as_advanced(
-    CMAKE_CXX_FLAGS_MAINTAINER
-    CMAKE_C_FLAGS_MAINTAINER
-    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
-    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER)
 # Update the documentation string of CMAKE_BUILD_TYPE for GUIs
 set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
-    "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Maintainer."
+    "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
     FORCE)
 
 # Compiler identification
@@ -274,11 +254,19 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
 endif()
 
 ### ---[ Find universal dependencies
-find_package(OpenMP)
-if(OPENMP_FOUND)
+
+# OpenMP (optional)
+find_package(OpenMP COMPONENTS C CXX)
+if(OpenMP_FOUND)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-  message(STATUS "Found OpenMP")
+  if(${CMAKE_VERSION} VERSION_LESS "3.7")
+    message(STATUS "Found OpenMP")
+  else()
+    # We could use OpenMP_CXX_VERSION starting from CMake 3.9, but this value is only available on first run of CMake (see https://gitlab.kitware.com/cmake/cmake/issues/19150),
+    # so we use always OpenMP_CXX_SPEC_DATE, which is available since CMake 3.7.
+    message(STATUS "Found OpenMP, spec date ${OpenMP_CXX_SPEC_DATE}")
+  endif()
   if(MSVC)
     if(MSVC_VERSION EQUAL 1900)
       set(OPENMP_DLL VCOMP140)
@@ -436,6 +424,9 @@ if(WITH_VTK AND NOT ANDROID)
       endif()
       if(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL")
         set(VTK_RENDERING_BACKEND_OPENGL_VERSION "1")
+        message(DEPRECATION "The rendering backend OpenGL is deprecated and not available anymore since VTK 8.2."
+                            "Please switch to the OpenGL2 backend instead, which is available since VTK 6.2."
+                            "Support of the deprecated backend will be dropped with PCL 1.13.")
       elseif(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL2")
         set(VTK_RENDERING_BACKEND_OPENGL_VERSION "2")
       endif()
@@ -472,9 +463,6 @@ configure_file("${pcl_config_h_in}" "${pcl_config_h}")
 PCL_ADD_INCLUDES(common "" "${pcl_config_h}")
 include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
 
-### ---[ Add the libraries subdirectories
-include("${PCL_SOURCE_DIR}/cmake/pcl_targets.cmake")
-
 collect_subproject_directory_names("${PCL_SOURCE_DIR}" "CMakeLists.txt" PCL_MODULES_NAMES PCL_MODULES_DIRS doc)
 set(PCL_MODULES_NAMES_UNSORTED ${PCL_MODULES_NAMES})
 topological_sort(PCL_MODULES_NAMES PCL_ _DEPENDS)
index 0004aa5f7c21c229b0515c0cc161785609897a78..16e64b7aae1c1192e8f144174a0a9d2d84f26983 100644 (file)
@@ -21,7 +21,7 @@ restrictions:
   * [Stack Overflow](https://stackoverflow.com/questions/tagged/point-cloud-library)
   for Q&A as well as support for troubleshooting, installation and debugging. Do
   remember to tag your questions with the tag `point-cloud-library`.
-  * [Gitter channel](https://gitter.im/PointCloudLibrary/pcl) for live chat with
+  * [Discord Server](https://discord.gg/JFFMAXS) for live chat with
   other members of the PCL community and casual discussions
 
 <!-- 
index 54b0cec44c73449ca8f59e6ec7e112c76eba8794..26de07d43d685feccbad942c0f602c9f5eb0fa81 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,38 +1,50 @@
 # Point Cloud Library
 
-<img src="pcl.png" align="center" height="100">
+<p align="center"><img src="pcl.png" height="100"></p>
 
 [![Release][release-image]][releases]
 [![License][license-image]][license]
 
-[release-image]: https://img.shields.io/badge/release-1.10.1-green.svg?style=flat
+[release-image]: https://img.shields.io/badge/release-1.11.0-green.svg?style=flat
 [releases]: https://github.com/PointCloudLibrary/pcl/releases
 
 [license-image]: https://img.shields.io/badge/license-BSD-green.svg?style=flat
 [license]: https://github.com/PointCloudLibrary/pcl/blob/master/LICENSE.txt
 
-Continuous integration
-----------------------
+:bangbang:Website:bangbang:
+-------
 
-[![Ubuntu Build Status][ci-ubuntu-image]][ci-ubuntu] [![Windows Build Status][ci-windows-image]][ci-windows] [![MacOS Build Status][ci-macos-image]][ci-macos]
+The original website (http://pointclouds.org) is down currently :broken_heart:, but a new one is back up https://pointcloudlibrary.github.io/ :heart: and open to [contributions](https://github.com/PointCloudLibrary/PointCloudLibrary.github.io) :hammer_and_wrench:.
 
-[ci-ubuntu]: https://dev.azure.com/PointCloudLibrary/pcl/_build/latest?definitionId=4
-[ci-ubuntu-image]: https://img.shields.io/azure-devops/build/PointCloudLibrary/0fc52e87-00b9-420e-acbc-c842c4f2d9cc/4.svg?label=Ubuntu&logo=azure%20pipelines
-[ci-windows]: https://dev.azure.com/PointCloudLibrary/pcl/_build/latest?definitionId=3
-[ci-windows-image]: https://img.shields.io/azure-devops/build/PointCloudLibrary/0fc52e87-00b9-420e-acbc-c842c4f2d9cc/3.svg?label=Windows&logo=azure%20pipelines
-[ci-macos]: https://dev.azure.com/PointCloudLibrary/pcl/_build/latest?definitionId=2
-[ci-macos-image]: https://img.shields.io/azure-devops/build/PointCloudLibrary/0fc52e87-00b9-420e-acbc-c842c4f2d9cc/2.svg?label=MacOS&logo=azure%20pipelines
+If you really need access to the old website, please use [the copy made by the internet archive](https://web.archive.org/web/20191017164724/http://www.pointclouds.org/). Please be aware that the website was hacked before and could still be hosting some malicious code.
+
+Continuous integration
+----------------------
+[ci-latest-build]: https://dev.azure.com/PointCloudLibrary/pcl/_build/latest?definitionId=9&branchName=master
+[ci-ubuntu-16.04]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20Ubuntu&jobName=Ubuntu&configuration=Ubuntu%2016.04%20GCC&label=Ubuntu%2016.04
+[ci-ubuntu-20.04]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20Ubuntu&jobName=Ubuntu&configuration=Ubuntu%2020.04%20GCC&label=Ubuntu%2020.04
+[ci-windows-x86]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20Windows&jobName=Windows%20VS2017%20Build&configuration=Windows%20VS2017%20Build%20x86&label=Windows%20VS2017%20x86
+[ci-windows-x64]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20Windows&jobName=Windows%20VS2017%20Build&configuration=Windows%20VS2017%20Build%20x64&label=Windows%20VS2017%20x64
+[ci-macos-10.14]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20macOS&jobName=macOS&configuration=macOS%20Mojave%2010.14&label=macOS%20Mojave%2010.14
+[ci-macos-10.15]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20macOS&jobName=macOS&configuration=macOS%20Catalina%2010.15&label=macOS%20Catalina%2010.15
+
+Build Platform           | Status
+------------------------ | ------------------------------------------------------------------------------------------------- |
+Ubuntu                   | [![Status][ci-ubuntu-16.04]][ci-latest-build] <br> [![Status][ci-ubuntu-20.04]][ci-latest-build]  |
+Windows                  | [![Status][ci-windows-x86]][ci-latest-build]  <br> [![Status][ci-windows-x64]][ci-latest-build]   |
+macOS                    | [![Status][ci-macos-10.14]][ci-latest-build]  <br> [![Status][ci-macos-10.15]][ci-latest-build]   |
 
 Community
 ---------
-[![Gitter][gitter-image]][gitter-channel]
+[![Discord][discord-image]][discord-server]
 [![StackOverflow][so-question-count]][stackoverflow]
 [![Website][website-status]][website]
 
-[gitter-image]: https://img.shields.io/gitter/room/PointCloudLibrary/pcl.svg?label=community%20chat&logo=gitter&logoColor=%23ED1965
-[gitter-channel]: https://gitter.im/PointCloudLibrary/pcl
-[website-status]: https://img.shields.io/website/http/www.pointclouds.org.svg?down_color=red&down_message=is%20down&up_color=yellow&up_message=is%20outdated
-[website]: http://www.pointclouds.org
+
+[discord-image]: https://img.shields.io/discord/694824801977630762?color=7289da&label=community%20chat&logo=discord&style=plastic
+[discord-server]: https://discord.gg/JFFMAXS
+[website-status]: https://img.shields.io/website/https/pointcloudlibrary.github.io.svg?down_color=red&down_message=is%20down&up_color=green&up_message=is%20new
+[website]: https://pointcloudlibrary.github.io/
 
 [so-question-count]: https://img.shields.io/stackexchange/stackoverflow/t/point-cloud-library.svg?logo=stackoverflow
 [stackoverflow]: https://stackoverflow.com/questions/tagged/point-cloud-library
@@ -40,10 +52,15 @@ Community
 Distribution
 ---------
 [![Packaging status](https://repology.org/badge/tiny-repos/pcl-pointclouds.svg)](https://repology.org/project/pcl-pointclouds/badges)
+[![latest packaged version(s)](https://repology.org/badge/latest-versions/pcl-pointclouds.svg)](https://repology.org/project/pcl-pointclouds/versions)
+
 <details>
 <summary>Click to see all</summary>
 <p>
-<a href="https://repology.org/project/pcl-pointclouds/versions"><img src="https://repology.org/badge/vertical-allrepos/pcl-pointclouds.svg?header=pcl-pointclouds"></a>
+<a href="https://repology.org/project/pcl-pointclouds/packages">
+    <img src="https://repology.org/badge/vertical-allrepos/pcl-pointclouds.svg?columns=3"
+         alt="Packaging status">
+</a>
 </p>
 </details>
 
@@ -77,7 +94,7 @@ For general questions on how to use the PCL, please consider one of the followin
 * [Stack Overflow](https://stackoverflow.com/questions/tagged/point-cloud-library)
 for Q&A as well as support for troubleshooting, installation and debugging. Do
 remember to tag your questions with the tag `point-cloud-library`.
-* [Gitter channel](https://gitter.im/PointCloudLibrary/pcl) for live chat with
+* [Discord Server](https://discord.gg/JFFMAXS) for live chat with
 other members of the PCL community and casual discussions
 
 <!-- 
index 775e668d8f92d856a2133b57523d086edda938fe..49ddcc5d5a00442193caea6c439d8391af7e5f16 100644 (file)
@@ -12,6 +12,7 @@
 #include <pcl/features/normal_3d.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/common/time.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 
 namespace pcl
 {
@@ -27,7 +28,7 @@ namespace pcl
         computeMeshResolution (PointInTPtr & input)
         {
           using KdTreeInPtr = typename pcl::KdTree<PointInT>::Ptr;
-          KdTreeInPtr tree = boost::make_shared<pcl::KdTreeFLANN<PointInT> > (false);
+          KdTreeInPtr tree = pcl::make_shared<pcl::KdTreeFLANN<PointInT> > (false);
           tree->setInputCloud (input);
 
           std::vector<int> nn_indices (9);
index f44ea72bd367747ed08196b66f5dea22bd7f73f4..013dd1e3c76086898d83ba19210f5220a23d9a96 100644 (file)
@@ -320,7 +320,10 @@ template<template<class > class Distance, typename PointInT, typename FeatureT>
         voxel_grid_icp.filter (*cloud_voxelized_icp);
         source_->voxelizeAllModels (VOXEL_SIZE_ICP_);
 
-#pragma omp parallel for num_threads(omp_get_num_procs())
+#pragma omp parallel for \
+  default(none) \
+  shared(VOXEL_SIZE_ICP_, cloud_voxelized_icp) \
+  num_threads(omp_get_num_procs())
         for (int i = 0; i < static_cast<int> (models_->size ()); i++)
         {
 
index aa000b70cfeccefdeee84d0e8ed610741abb4431..72d6162ddd0819c10bc39bd9dc9df59e89366589 100644 (file)
@@ -506,7 +506,10 @@ template<template<class > class Distance, typename PointInT, typename FeatureT>
           source_->voxelizeAllModels (VOXEL_SIZE_ICP_);
         }
 
-#pragma omp parallel for num_threads(omp_get_num_procs())
+#pragma omp parallel for \
+  default(none) \
+  shared(cloud_voxelized_icp, VOXEL_SIZE_ICP_) \
+  num_threads(omp_get_num_procs())
         for (int i = 0; i < static_cast<int> (models_->size ()); i++)
         {
 
index 77452f6e43710e6fd91c98e167e72e5b52a68e43..d85593ea32e3fd2e42e2f570a79ad345786165e4 100644 (file)
@@ -110,7 +110,6 @@ template<template<class > class Distance, typename PointInT, typename FeatureT>
     } else {
       models = source_->getModels (search_model_);
       //reset cache and flann structures
-      if(flann_index_ != nullptr)
         delete flann_index_;
 
       flann_models_.clear();
@@ -366,7 +365,11 @@ template<template<class > class Distance, typename PointInT, typename FeatureT>
       voxel_grid_icp.filter (*cloud_voxelized_icp);
       source_->voxelizeAllModels (VOXEL_SIZE_ICP_);
 
-#pragma omp parallel for schedule(dynamic,1) num_threads(omp_get_num_procs())
+#pragma omp parallel for \
+  default(none) \
+  shared(cloud_voxelized_icp) \
+  schedule(dynamic,1) \
+  num_threads(omp_get_num_procs())
       for (int i = 0; i < static_cast<int>(models_->size ()); i++)
       {
 
index e8d54009da4da2b9a82cc4ffdac43c4aa861acc5..c44f8d8ff34f1f96ece2ca0d1e4cbb7678f03b45 100644 (file)
@@ -23,7 +23,7 @@ namespace OpenNIFrameSource
     const PointCloudPtr
     snap ();
     bool
-    isActive ();
+    isActive () const;
     void
     onKeyboardEvent (const pcl::visualization::KeyboardEvent & event);
 
index 0e2dde6ecfbf1ef832c1b0ebab9875f7cb5f1ef5..7748fab75c37c3710d9e851fa6970b0074fcb6cf 100644 (file)
@@ -1,6 +1,6 @@
 #include "pcl/apps/3d_rec_framework/tools/openni_frame_source.h"
 #include <pcl/io/pcd_io.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 namespace OpenNIFrameSource
 {
@@ -21,7 +21,7 @@ namespace OpenNIFrameSource
   }
 
   bool
-  OpenNIFrameSource::isActive ()
+  OpenNIFrameSource::isActive () const
   {
     return active_;
   }
index ce5a6ea25651c5d66cb3adf5f3d6bb21d7c41421..c4ef60c6f928cdeadbc10ced6eff0bb47970a504 100644 (file)
@@ -3,6 +3,7 @@ set(SUBSYS_DESC "Application examples/samples that show how PCL works")
 set(SUBSYS_DEPS common geometry io filters sample_consensus segmentation visualization kdtree features surface octree registration keypoints tracking search recognition ml stereo 2d)
 
 set(DEFAULT FALSE)
+set(REASON "Disabled by default")
 PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ${DEFAULT} "${REASON}")
 PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS openni vtk)
 
@@ -51,7 +52,7 @@ if(VTK_FOUND)
   target_link_libraries(pcl_feature_matching pcl_common pcl_io pcl_registration pcl_keypoints pcl_sample_consensus pcl_visualization pcl_search pcl_features pcl_kdtree pcl_surface pcl_segmentation)
 
   PCL_ADD_EXECUTABLE(pcl_convolve COMPONENT ${SUBSYS_NAME} SOURCES src/convolve.cpp)
-  target_link_libraries(pcl_convolve pcl_common pcl_io pcl_visualization)
+  target_link_libraries(pcl_convolve pcl_common pcl_filters pcl_io pcl_visualization)
 
   PCL_ADD_EXECUTABLE(pcl_pcd_organized_multi_plane_segmentation COMPONENT ${SUBSYS_NAME} SOURCES src/pcd_organized_multi_plane_segmentation.cpp)
   target_link_libraries(pcl_pcd_organized_multi_plane_segmentation pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_features)
@@ -227,4 +228,3 @@ else()
 endif()
 add_custom_target(${SUBSYS_TARGET_NAME} DEPENDS ${PCL_APPS_ALL_TARGETS})
 set_target_properties(${SUBSYS_TARGET_NAME} PROPERTIES FOLDER "Apps")
-
index 4af174bd5de30b0df823386c1edad35c8afc85ba..6689967c0658875baa300988855030251af92f39 100644 (file)
@@ -39,6 +39,7 @@
 #define IMPL_CLOUD_ITEM_H_
 
 #include <pcl/apps/cloud_composer/items/cloud_item.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_cloud.h>
 #include <pcl/impl/instantiate.hpp>
 
@@ -66,7 +67,7 @@ pcl::cloud_composer::CloudItem::printNumPoints () const
 template <typename PointT> pcl::cloud_composer::CloudItem* 
 pcl::cloud_composer::CloudItem::createCloudItemFromTemplate (const QString& name, typename PointCloud<PointT>::Ptr cloud_ptr)
 {
-  pcl::PCLPointCloud2::Ptr cloud_blob = boost::make_shared <pcl::PCLPointCloud2> ();
+  pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared <pcl::PCLPointCloud2> ();
   toPCLPointCloud2 (*cloud_ptr, *cloud_blob);
   CloudItem* cloud_item = new CloudItem ( name, cloud_blob,  Eigen::Vector4f (), Eigen::Quaternionf (), false);
   cloud_item->setData (QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED);
index fd27319eca711e02693371d6d1da0c53754583e4..debc9a32c69db20507ee707ee387777030f9921d 100644 (file)
@@ -40,6 +40,7 @@
 #include <QDebug>
 
 #include <pcl/apps/cloud_composer/items/cloud_composer_item.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/search/kdtree.h>
index 5833c72b7a13191286ee8ba55bfff23c3b379c1e..1b32f201fe0127acee68acbb0ad5b07a6d595839 100644 (file)
-  /*
 * Software License Agreement  (BSD License)
 *
 *  Point Cloud Library  (PCL) - www.pointclouds.org
 *  Copyright  (c) 2012, Jeremie Papon.
 *
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of Willow Garage, Inc. nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 */
- #ifndef IMPL_ORGANIZED_SEGMENTATION_HPP_
- #define IMPL_ORGANIZED_SEGMENTATION_HPP_
- #include <pcl/apps/cloud_composer/tools/organized_segmentation.h>
- #include <pcl/apps/cloud_composer/impl/cloud_item.hpp>
- #include <pcl/apps/cloud_composer/items/normals_item.h>
- #include <pcl/point_cloud.h>
- #include <pcl/segmentation/organized_multi_plane_segmentation.h>
- #include <pcl/segmentation/plane_coefficient_comparator.h>
- #include <pcl/segmentation/euclidean_plane_coefficient_comparator.h>
- #include <pcl/segmentation/rgb_plane_coefficient_comparator.h>
- #include <pcl/segmentation/edge_aware_plane_comparator.h>
- #include <pcl/segmentation/euclidean_cluster_comparator.h>
- #include <pcl/segmentation/organized_connected_component_segmentation.h>
- template <typename PointT> QList <pcl::cloud_composer::CloudComposerItem*>
- pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (const QList <const CloudComposerItem*>& input_data)
- {
-   QList <CloudComposerItem*> output;  
-   
-   foreach (const CloudComposerItem* input_item, input_data)
-   {
-     QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED);
-     if ( ! variant.canConvert <typename PointCloud<PointT>::Ptr> () )
-     {  
-       qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)";
-       return output;
-     }
-     typename PointCloud <PointT>::Ptr input_cloud = variant.value <typename PointCloud<PointT>::Ptr> ();
-     if ( ! input_cloud->isOrganized ())
-     {
-       qCritical () << "Organized Segmentation requires an organized cloud!";
-       return output;
-     }
-   }
-   
-   int min_inliers = parameter_model_->getProperty ("Min Inliers").toInt ();
-   int min_plane_size = parameter_model_->getProperty ("Min Plane Size").toInt ();
-   double angular_threshold = parameter_model_->getProperty ("Angular Threshold").toDouble ();
-   double distance_threshold = parameter_model_->getProperty ("Distance Threshold").toDouble ();
-   double cluster_distance_threshold = parameter_model_->getProperty ("Cluster Dist. Thresh.").toDouble ();
-   int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt ();
-   
-   foreach (const CloudComposerItem* input_item, input_data)
-   {
-     QList <CloudComposerItem*> normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM);
-     //Get the normals cloud, we just use the first normals that were found if there are more than one
-     pcl::PointCloud<pcl::Normal>::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value <pcl::PointCloud<pcl::Normal>::ConstPtr> ();
-     
-     QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED);
-     typename PointCloud <PointT>::Ptr input_cloud = variant.value <typename PointCloud<PointT>::Ptr> ();
-     
-     pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
-     mps.setMinInliers (min_inliers);
-     mps.setAngularThreshold (pcl::deg2rad (angular_threshold)); // convert to radians
-     mps.setDistanceThreshold (distance_threshold); 
-     mps.setInputNormals (input_normals);
-     mps.setInputCloud (input_cloud);
-     std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > regions;
-     std::vector<pcl::ModelCoefficients> model_coefficients;
-     std::vector<pcl::PointIndices> inlier_indices;  
-     pcl::PointCloud<pcl::Label>::Ptr labels (new pcl::PointCloud<pcl::Label>);
-     std::vector<pcl::PointIndices> label_indices;
-     std::vector<pcl::PointIndices> boundary_indices;
-     mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);
-     
-     auto plane_labels = boost::make_shared<std::set<std::uint32_t> > ();
-     for (std::size_t i = 0; i < label_indices.size (); ++i)
-      if (label_indices[i].indices.size () > (std::size_t) min_plane_size)
-        plane_labels->insert (i);
-     typename PointCloud<PointT>::CloudVectorType clusters;
-     
-     typename EuclideanClusterComparator<PointT, pcl::Label>::Ptr euclidean_cluster_comparator(new EuclideanClusterComparator<PointT, pcl::Label>);
-     euclidean_cluster_comparator->setInputCloud (input_cloud);
-     euclidean_cluster_comparator->setLabels (labels);
-     euclidean_cluster_comparator->setExcludeLabels (plane_labels);
-     euclidean_cluster_comparator->setDistanceThreshold (cluster_distance_threshold, false);
-     
-     pcl::PointCloud<pcl::Label> euclidean_labels;
-     std::vector<pcl::PointIndices> euclidean_label_indices;
-     pcl::OrganizedConnectedComponentSegmentation<PointT,pcl::Label> euclidean_segmentation (euclidean_cluster_comparator);
-     euclidean_segmentation.setInputCloud (input_cloud);
-     euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices);
-     
-     pcl::IndicesPtr extracted_indices (new std::vector<int> ());
-     for (std::size_t i = 0; i < euclidean_label_indices.size (); i++)
-     {
-       if (euclidean_label_indices[i].indices.size () >= (std::size_t) min_cluster_size)
-       {
-         typename PointCloud<PointT>::Ptr cluster (new PointCloud<PointT>);
-         pcl::copyPointCloud (*input_cloud,euclidean_label_indices[i].indices,*cluster);
-         qDebug () << "Found cluster with size " << cluster->width;
-         QString name = input_item->text () + tr ("- Clstr %1").arg (i);
-         CloudItem*  new_cloud_item = CloudItem::createCloudItemFromTemplate<PointT>(name,cluster);
-         output.append (new_cloud_item);
-         extracted_indices->insert (extracted_indices->end (), euclidean_label_indices[i].indices.begin (), euclidean_label_indices[i].indices.end ());
-         
-       }    
-     }
-     
-     for (std::size_t i = 0; i < label_indices.size (); i++)
-     {
-       if (label_indices[i].indices.size () >= (std::size_t) min_plane_size)
-       {
-         typename PointCloud<PointT>::Ptr plane (new PointCloud<PointT>);
-         pcl::copyPointCloud (*input_cloud,label_indices[i].indices,*plane);
-         qDebug () << "Found plane with size " << plane->width;
-         QString name = input_item->text () + tr ("- Plane %1").arg (i);
-         CloudItem*  new_cloud_item = CloudItem::createCloudItemFromTemplate<PointT>(name,plane);
-         output.append (new_cloud_item);
-         extracted_indices->insert (extracted_indices->end (), label_indices[i].indices.begin (), label_indices[i].indices.end ());
-         
-       }    
-     }
-     typename PointCloud<PointT>::Ptr leftovers (new PointCloud<PointT>);
-     if (extracted_indices->empty ())
-       pcl::copyPointCloud (*input_cloud,*leftovers);
-     else
-     {
-       pcl::ExtractIndices<PointT> filter;
-       filter.setInputCloud (input_cloud);
-       filter.setIndices (extracted_indices);
-       filter.setNegative (true);
-       filter.filter (*leftovers);
-     }
-     CloudItem*  leftover_cloud_item = CloudItem::createCloudItemFromTemplate<PointT>(input_item->text(),leftovers);
-     output.append (leftover_cloud_item);
-   }
-   
-   
-   
-   
-   return output;
-   
- }
- #define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction<T> (QList <const CloudComposerItem*>);
- #endif //IMPL_TRANSFORM_CLOUDS_HPP_
+/*
+ * Software License Agreement  (BSD License)
+ *
+ *  Point Cloud Library  (PCL) - www.pointclouds.org
+ *  Copyright  (c) 2012, Jeremie Papon.
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Willow Garage, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef IMPL_ORGANIZED_SEGMENTATION_HPP_
+#define IMPL_ORGANIZED_SEGMENTATION_HPP_
+
+#include <pcl/apps/cloud_composer/tools/organized_segmentation.h>
+#include <pcl/apps/cloud_composer/impl/cloud_item.hpp>
+#include <pcl/apps/cloud_composer/items/normals_item.h>
+#include <pcl/memory.h>  // for pcl::make_shared
+#include <pcl/point_cloud.h>
+
+#include <pcl/segmentation/organized_multi_plane_segmentation.h>
+#include <pcl/segmentation/plane_coefficient_comparator.h>
+#include <pcl/segmentation/euclidean_plane_coefficient_comparator.h>
+#include <pcl/segmentation/rgb_plane_coefficient_comparator.h>
+#include <pcl/segmentation/edge_aware_plane_comparator.h>
+#include <pcl/segmentation/euclidean_cluster_comparator.h>
+#include <pcl/segmentation/organized_connected_component_segmentation.h>
+
+
+template <typename PointT> QList <pcl::cloud_composer::CloudComposerItem*>
+pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (const QList <const CloudComposerItem*>& input_data)
+{
+  QList <CloudComposerItem*> output;
+
+  foreach (const CloudComposerItem* input_item, input_data)
+  {
+    QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED);
+    if ( ! variant.canConvert <typename PointCloud<PointT>::Ptr> () )
+    {
+      qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)";
+      return output;
+    }
+    typename PointCloud <PointT>::Ptr input_cloud = variant.value <typename PointCloud<PointT>::Ptr> ();
+    if ( ! input_cloud->isOrganized ())
+    {
+      qCritical () << "Organized Segmentation requires an organized cloud!";
+      return output;
+    }
+  }
+
+  int min_inliers = parameter_model_->getProperty ("Min Inliers").toInt ();
+  int min_plane_size = parameter_model_->getProperty ("Min Plane Size").toInt ();
+  double angular_threshold = parameter_model_->getProperty ("Angular Threshold").toDouble ();
+  double distance_threshold = parameter_model_->getProperty ("Distance Threshold").toDouble ();
+  double cluster_distance_threshold = parameter_model_->getProperty ("Cluster Dist. Thresh.").toDouble ();
+  int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt ();
+
+  foreach (const CloudComposerItem* input_item, input_data)
+  {
+    QList <CloudComposerItem*> normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM);
+    //Get the normals cloud, we just use the first normals that were found if there are more than one
+    pcl::PointCloud<pcl::Normal>::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value <pcl::PointCloud<pcl::Normal>::ConstPtr> ();
+
+    QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED);
+    typename PointCloud <PointT>::Ptr input_cloud = variant.value <typename PointCloud<PointT>::Ptr> ();
+
+    pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
+    mps.setMinInliers (min_inliers);
+    mps.setAngularThreshold (pcl::deg2rad (angular_threshold)); // convert to radians
+    mps.setDistanceThreshold (distance_threshold);
+    mps.setInputNormals (input_normals);
+    mps.setInputCloud (input_cloud);
+    std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > regions;
+    std::vector<pcl::ModelCoefficients> model_coefficients;
+    std::vector<pcl::PointIndices> inlier_indices;
+    pcl::PointCloud<pcl::Label>::Ptr labels (new pcl::PointCloud<pcl::Label>);
+    std::vector<pcl::PointIndices> label_indices;
+    std::vector<pcl::PointIndices> boundary_indices;
+    mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);
+
+    auto plane_labels = pcl::make_shared<std::set<std::uint32_t> > ();
+    for (std::size_t i = 0; i < label_indices.size (); ++i)
+     if (label_indices[i].indices.size () > (std::size_t) min_plane_size)
+       plane_labels->insert (i);
+    typename PointCloud<PointT>::CloudVectorType clusters;
+
+    typename EuclideanClusterComparator<PointT, pcl::Label>::Ptr euclidean_cluster_comparator(new EuclideanClusterComparator<PointT, pcl::Label>);
+    euclidean_cluster_comparator->setInputCloud (input_cloud);
+    euclidean_cluster_comparator->setLabels (labels);
+    euclidean_cluster_comparator->setExcludeLabels (plane_labels);
+    euclidean_cluster_comparator->setDistanceThreshold (cluster_distance_threshold, false);
+
+    pcl::PointCloud<pcl::Label> euclidean_labels;
+    std::vector<pcl::PointIndices> euclidean_label_indices;
+    pcl::OrganizedConnectedComponentSegmentation<PointT,pcl::Label> euclidean_segmentation (euclidean_cluster_comparator);
+    euclidean_segmentation.setInputCloud (input_cloud);
+    euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices);
+
+    pcl::IndicesPtr extracted_indices (new std::vector<int> ());
+    for (std::size_t i = 0; i < euclidean_label_indices.size (); i++)
+    {
+      if (euclidean_label_indices[i].indices.size () >= (std::size_t) min_cluster_size)
+      {
+        typename PointCloud<PointT>::Ptr cluster (new PointCloud<PointT>);
+        pcl::copyPointCloud (*input_cloud,euclidean_label_indices[i].indices,*cluster);
+        qDebug () << "Found cluster with size " << cluster->width;
+        QString name = input_item->text () + tr ("- Clstr %1").arg (i);
+        CloudItem*  new_cloud_item = CloudItem::createCloudItemFromTemplate<PointT>(name,cluster);
+        output.append (new_cloud_item);
+        extracted_indices->insert (extracted_indices->end (), euclidean_label_indices[i].indices.begin (), euclidean_label_indices[i].indices.end ());
+      }
+    }
+
+    for (std::size_t i = 0; i < label_indices.size (); i++)
+    {
+      if (label_indices[i].indices.size () >= (std::size_t) min_plane_size)
+      {
+        typename PointCloud<PointT>::Ptr plane (new PointCloud<PointT>);
+        pcl::copyPointCloud (*input_cloud,label_indices[i].indices,*plane);
+        qDebug () << "Found plane with size " << plane->width;
+        QString name = input_item->text () + tr ("- Plane %1").arg (i);
+        CloudItem*  new_cloud_item = CloudItem::createCloudItemFromTemplate<PointT>(name,plane);
+        output.append (new_cloud_item);
+        extracted_indices->insert (extracted_indices->end (), label_indices[i].indices.begin (), label_indices[i].indices.end ());
+
+      }
+    }
+    typename PointCloud<PointT>::Ptr leftovers (new PointCloud<PointT>);
+    if (extracted_indices->empty ())
+      pcl::copyPointCloud (*input_cloud,*leftovers);
+    else
+    {
+      pcl::ExtractIndices<PointT> filter;
+      filter.setInputCloud (input_cloud);
+      filter.setIndices (extracted_indices);
+      filter.setNegative (true);
+      filter.filter (*leftovers);
+    }
+    CloudItem*  leftover_cloud_item = CloudItem::createCloudItemFromTemplate<PointT>(input_item->text(),leftovers);
+    output.append (leftover_cloud_item);
+  }
+
+
+
+
+  return output;
+
+}
+
+
+#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction<T> (QList <const CloudComposerItem*>);
+
+
+
+#endif //IMPL_TRANSFORM_CLOUDS_HPP_
index e3754f669ddc98bb789c9cd39a04134324428bbd..2d83912fdc27032c71b3000ad98eb597f31121ff 100644 (file)
@@ -41,7 +41,7 @@
 #include <pcl/apps/cloud_composer/tools/supervoxels.h>
 #include <pcl/apps/cloud_composer/impl/cloud_item.hpp>
 #include <pcl/apps/cloud_composer/items/normals_item.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <pcl/point_cloud.h>
 #include <pcl/segmentation/supervoxel_clustering.h>
 
index d2237203085a5b05b7fe0110891c67d73bc5f857..4b0e53396c869309832d50edd197594564bd7ee4 100644 (file)
@@ -22,7 +22,6 @@ pcl::cloud_composer::CloudCommand::~CloudCommand ()
     QList <QStandardItem*> items_to_remove = removed_to_parent_map_.keys ();
     foreach (QStandardItem* to_remove, items_to_remove)
     {
-      if (to_remove)
         delete to_remove;
     }
   }
@@ -33,10 +32,10 @@ pcl::cloud_composer::CloudCommand::~CloudCommand ()
     {
       QList <CloudComposerItem*> new_items = output_pair.output_items_;
       foreach (CloudComposerItem* item, new_items)
-        if (item)
-          delete item;
+      {
+        delete item;
+      }
     }
-    
   }
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
index 91cd3f79fb5fec2ee102ebd178038f4089ea77be..d7b1d83f0393e63645205332bb2537074fd6ad55 100644 (file)
@@ -1,6 +1,7 @@
 #include <pcl/apps/cloud_composer/items/cloud_item.h>
 #include <pcl/filters/passthrough.h>
 
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_types.h>
 #include <pcl/impl/instantiate.hpp>
 #include <pcl/apps/cloud_composer/impl/cloud_item.hpp>
@@ -145,7 +146,7 @@ pcl::cloud_composer::CloudItem::setTemplateCloudFromBlob ()
         pcl::fromPCLPointCloud2 (*cloud_blob_ptr_, *cloud_ptr);
         cloud_pointer_variant = QVariant::fromValue (cloud_ptr);
         //Initialize the search kd-tree for this cloud
-        pcl::search::KdTree<PointXYZ>::Ptr kd_search = boost::make_shared<search::KdTree<PointXYZ> >();
+        pcl::search::KdTree<PointXYZ>::Ptr kd_search = pcl::make_shared<search::KdTree<PointXYZ> >();
         kd_search->setInputCloud (cloud_ptr);
         kd_tree_variant = QVariant::fromValue (kd_search);
         break;
@@ -155,7 +156,7 @@ pcl::cloud_composer::CloudItem::setTemplateCloudFromBlob ()
         pcl::PointCloud <PointXYZRGB>::Ptr cloud_ptr (new pcl::PointCloud <PointXYZRGB>);
         pcl::fromPCLPointCloud2 (*cloud_blob_ptr_, *cloud_ptr);
         cloud_pointer_variant = QVariant::fromValue (cloud_ptr);
-        pcl::search::KdTree<PointXYZRGB>::Ptr kd_search = boost::make_shared<search::KdTree<PointXYZRGB> >();
+        pcl::search::KdTree<PointXYZRGB>::Ptr kd_search = pcl::make_shared<search::KdTree<PointXYZRGB> >();
         kd_search->setInputCloud (cloud_ptr);
         kd_tree_variant = QVariant::fromValue (kd_search);
         break;
@@ -165,7 +166,7 @@ pcl::cloud_composer::CloudItem::setTemplateCloudFromBlob ()
         pcl::PointCloud <PointXYZRGBA>::Ptr cloud_ptr (new pcl::PointCloud <PointXYZRGBA>);
         pcl::fromPCLPointCloud2 (*cloud_blob_ptr_, *cloud_ptr);
         cloud_pointer_variant = QVariant::fromValue (cloud_ptr);
-        pcl::search::KdTree<PointXYZRGBA>::Ptr kd_search = boost::make_shared<search::KdTree<PointXYZRGBA> >();
+        pcl::search::KdTree<PointXYZRGBA>::Ptr kd_search = pcl::make_shared<search::KdTree<PointXYZRGBA> >();
         kd_search->setInputCloud (cloud_ptr);
         kd_tree_variant = QVariant::fromValue (kd_search);
         break;
@@ -191,7 +192,7 @@ pcl::cloud_composer::CloudItem::checkIfFinite ()
   if (! cloud_blob_ptr_)
     return false;
   
-  pcl::PCLPointCloud2::Ptr cloud_filtered = boost::make_shared<pcl::PCLPointCloud2> ();
+  pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared<pcl::PCLPointCloud2> ();
   pcl::PassThrough<pcl::PCLPointCloud2> pass_filter;
   pass_filter.setInputCloud (cloud_blob_ptr_);
   pass_filter.setKeepOrganized (false);
index 13e4c79b7a560b0ffeb32df2f719af1b3ab8108f..f8aadecae1dd20bc1d7783a831681a2e12e13131 100644 (file)
@@ -2,6 +2,7 @@
 #include <pcl/apps/cloud_composer/items/cloud_item.h>
 
 #include <pcl/filters/extract_indices.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_types.h>
 #include <pcl/impl/instantiate.hpp>
 #include <pcl/apps/cloud_composer/impl/merge_selection.hpp>
@@ -10,12 +11,12 @@ pcl::cloud_composer::MergeSelection::MergeSelection (QMap <const CloudItem*, pcl
   : MergeCloudTool (nullptr, parent)
   , selected_item_index_map_ (std::move(selected_item_index_map))
 {
-  
+
 }
 
 pcl::cloud_composer::MergeSelection::~MergeSelection ()
 {
-  
+
 }
 
 QList <pcl::cloud_composer::CloudComposerItem*>
@@ -33,7 +34,7 @@ pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, Po
         return this->performTemplatedAction<pcl::PointXYZRGBA> (input_data);
     }
   }
-  
+
   QList <CloudComposerItem*> output;
 
   // Check input data length
@@ -61,20 +62,20 @@ pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, Po
   bool pose_found = false;
   foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ())
   {
-    //If this cloud hasn't been completely selected 
+    //If this cloud hasn't been completely selected
     if (!input_data.contains (input_cloud_item))
     {
       pcl::PCLPointCloud2::ConstPtr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_BLOB).value <pcl::PCLPointCloud2::ConstPtr> ();
       qDebug () << "Extracting "<<selected_item_index_map_.value(input_cloud_item)->indices.size() << " points out of "<<input_cloud->width;
       filter.setInputCloud (input_cloud);
       filter.setIndices (selected_item_index_map_.value (input_cloud_item));
-      pcl::PCLPointCloud2::Ptr original_minus_indices = boost::make_shared <pcl::PCLPointCloud2> ();
+      pcl::PCLPointCloud2::Ptr original_minus_indices = pcl::make_shared <pcl::PCLPointCloud2> ();
       filter.setNegative (true);
       filter.filter (*original_minus_indices);
       filter.setNegative (false);
       pcl::PCLPointCloud2::Ptr selected_points (new pcl::PCLPointCloud2);
       filter.filter (*selected_points);
-      
+
       qDebug () << "Original minus indices is "<<original_minus_indices->width;
 
       if (!pose_found)
@@ -88,7 +89,7 @@ pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, Po
                                              , source_origin
                                              , source_orientation);
       output.append (new_cloud_item);
-      pcl::PCLPointCloud2::Ptr temp_cloud = boost::make_shared <pcl::PCLPointCloud2> ();
+      pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared <pcl::PCLPointCloud2> ();
       concatenate (*merged_cloud, *selected_points, *temp_cloud);
       merged_cloud = temp_cloud;
     }
@@ -99,8 +100,8 @@ pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, Po
   foreach (const CloudComposerItem* input_item, input_data)
   {
     pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value <pcl::PCLPointCloud2::ConstPtr> ();
-    
-    pcl::PCLPointCloud2::Ptr temp_cloud = boost::make_shared <pcl::PCLPointCloud2> ();
+
+    pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared <pcl::PCLPointCloud2> ();
     concatenate (*merged_cloud, *input_cloud, *temp_cloud);
     merged_cloud = temp_cloud;
   }
@@ -111,6 +112,6 @@ pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, Po
                                          , source_orientation);
 
   output.append (cloud_item);
-    
+
   return output;
 }
index 91e115147cc3d379e80e25bca865efe3759a6426..0f1575bd0d82909f6b896652c52b0d6495a23ca6 100644 (file)
@@ -6,7 +6,7 @@
 #include <pcl/apps/cloud_composer/cloud_view.h>
 #include <pcl/apps/cloud_composer/merge_selection.h>
 #include <pcl/apps/cloud_composer/transform_clouds.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include <QAction>
 #include <QFileDialog>
index c54a9c3c89804d940f54d3e8257ac42588b1333c..4a52dd75c1e94863946b975f1337db04e6d1199f 100644 (file)
@@ -1,6 +1,7 @@
 #include <pcl/apps/cloud_composer/tools/euclidean_clustering.h>
 #include <pcl/apps/cloud_composer/items/cloud_item.h>
 
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_types.h>
 #include <pcl/filters/extract_indices.h>
 #include <pcl/kdtree/kdtree.h>
@@ -11,12 +12,12 @@ Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0")
 pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent)
   : SplitItemTool (parameter_model, parent)
 {
-  
+
 }
 
 pcl::cloud_composer::EuclideanClusteringTool::~EuclideanClusteringTool ()
 {
-  
+
 }
 
 QList <pcl::cloud_composer::CloudComposerItem*>
@@ -35,7 +36,7 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input
     qWarning () << "Input vector has more than one item in Euclidean Clustering!";
   }
   input_item = input_data.value (0);
-  
+
   if (input_item->type () == CloudComposerItem::CLOUD_ITEM)
   {
     const CloudItem* cloud_item = dynamic_cast <const CloudItem*> (input_item);
@@ -44,17 +45,17 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input
       double cluster_tolerance = parameter_model_->getProperty ("Cluster Tolerance").toDouble();
       int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt();
       int max_cluster_size = parameter_model_->getProperty ("Max Cluster Size").toInt();
-    
+
       pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value <pcl::PCLPointCloud2::ConstPtr> ();
       //Get the cloud in template form
       pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
       pcl::fromPCLPointCloud2 (*input_cloud, *cloud);
-      
+
       //////////////// THE WORK - COMPUTING CLUSTERS ///////////////////
       // Creating the KdTree object for the search method of the extraction
       pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
       tree->setInputCloud (cloud);
-    
+
       std::vector<pcl::PointIndices> cluster_indices;
       pcl::EuclideanClusterExtraction<pcl::PointXYZ> ec;
       ec.setClusterTolerance (cluster_tolerance); 
@@ -77,14 +78,14 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input
       {
         filter.setInputCloud (input_cloud);
         // It's annoying that I have to do this, but Euclidean returns a PointIndices struct
-        pcl::PointIndices::ConstPtr indices_ptr = boost::make_shared<pcl::PointIndices>(*it);
+        pcl::PointIndices::ConstPtr indices_ptr = pcl::make_shared<pcl::PointIndices>(*it);
         filter.setIndices (indices_ptr);
         extracted_indices->insert (extracted_indices->end (), it->indices.begin (), it->indices.end ());
         //This means remove the other points
         filter.setKeepOrganized (false);
         pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2);
         filter.filter (*cloud_filtered);
-      
+
         qDebug() << "Cluster has " << cloud_filtered->width << " data points.";
         CloudItem* cloud_item = new CloudItem (input_item->text ()+tr("-Clstr %1").arg(cluster_count)
                                               , cloud_filtered
@@ -92,7 +93,7 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input
                                               , source_orientation);
         output.append (cloud_item);
         ++cluster_count;
-      } 
+      }
       //We copy input cloud over for special case that no clusters found, since ExtractIndices doesn't work for 0 length vectors
       pcl::PCLPointCloud2::Ptr remainder_cloud (new pcl::PCLPointCloud2(*input_cloud));
       if (!cluster_indices.empty ())
@@ -116,8 +117,8 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input
   {
     qCritical () << "Input item in Clustering is not a cloud!!!";
   }
-  
-  
+
+
   return output;
 }
 
@@ -126,11 +127,10 @@ pcl::cloud_composer::PropertiesModel*
 pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel (QObject* parent)
 {
   PropertiesModel* parameter_model = new PropertiesModel(parent);
-  
+
   parameter_model->addProperty ("Cluster Tolerance", 0.02,  Qt::ItemIsEditable | Qt::ItemIsEnabled);
   parameter_model->addProperty ("Min Cluster Size", 100,  Qt::ItemIsEditable | Qt::ItemIsEnabled);
   parameter_model->addProperty ("Max Cluster Size", 25000,  Qt::ItemIsEditable | Qt::ItemIsEnabled);
-    
 
   return parameter_model;
 }
index f606ff4fdd218dbb5fd0d93a983168116809a450..ea22f4ad7c1091f928f1a8c8b871694f4fdb483f 100644 (file)
@@ -1,19 +1,17 @@
 #include <pcl/apps/cloud_composer/tools/sanitize_cloud.h>
 #include <pcl/apps/cloud_composer/items/cloud_item.h>
 #include <pcl/filters/passthrough.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 
 Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0")
 
 pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent)
 : ModifyItemTool (parameter_model, parent)
 {
-  
-  
 }
 
 pcl::cloud_composer::SanitizeCloudTool::~SanitizeCloudTool ()
 {
-  
 }
 
 QList <pcl::cloud_composer::CloudComposerItem*>
@@ -42,7 +40,7 @@ pcl::cloud_composer::SanitizeCloudTool::performAction (ConstItemList input_data,
     pass_filter.setKeepOrganized (keep_organized);
         
     //Create output cloud
-    pcl::PCLPointCloud2::Ptr cloud_filtered = boost::make_shared<pcl::PCLPointCloud2> ();
+    pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared<pcl::PCLPointCloud2> ();
     //Filter!  
     pass_filter.filter (*cloud_filtered);
     
index 63d5d06de92a657869e9df123f94e1e672252a01..76f82bc3036476ba929fcd72d851ca623d2ccddd 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <limits>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
index 0999e1ac9376881abe867525312528cff7c4dc2d..b972e66893e53e94e3079b68c5dd99e1f7acdc91 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/apps/in_hand_scanner/boost.h>
index 90ccb982df4126e4536d4710e633208b2657ff8c..cff11995d4bd3ea6faf7b59f4328b640c9aeb804 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/common/time.h>
index f658af83a4091cf7b90598e7375affeec48cbf65..a684650c55af0a82828adf21af85a1133e91aecc 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/common/time.h>
index abc7327f8d79cb8a816f2cc11787e07827212160..086baacbf86038265f51543ff2c056eefd5dee2d 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <cstdint>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/apps/in_hand_scanner/eigen.h>
index 76471466b0f0f561948f72f2b431ae1342256aec..0688595ed46a78b19e74544ef75c7e1b364d165e 100644 (file)
@@ -178,7 +178,6 @@ pcl::ihs::ICP::findTransformation (const MeshConstPtr&              mesh_model,
 
   // Convergence and registration failure
   float current_fitness  = 0.f;
-  float previous_fitness = std::numeric_limits <float>::max ();
   float delta_fitness    = std::numeric_limits <float>::max ();
   float overlap          = std::numeric_limits <float>::quiet_NaN ();
 
@@ -274,7 +273,7 @@ pcl::ihs::ICP::findTransformation (const MeshConstPtr&              mesh_model,
     }
 
     // NOTE: The fitness is calculated with the transformation from the previous iteration (I don't re-calculate it after the transformation estimation). This means that the actual fitness will be one iteration "better" than the calculated fitness suggests. This should be no problem because the difference is small at the state of convergence.
-    previous_fitness           = current_fitness;
+    float previous_fitness = current_fitness;
     current_fitness            = squared_distance_sum / static_cast <float> (n_corr);
     delta_fitness              = std::abs (previous_fitness - current_fitness);
     squared_distance_threshold = factor_ * current_fitness;
index 3bc7fb62aaa8694b577e4503149456da07170602..174b6f78188695732604f76d5cdf33aad9841d95 100644 (file)
 #pragma once
 
 #include <pcl/common/common.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/console/parse.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/filters/passthrough.h>
-#include <pcl/filters/extract_indices.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/search/pcl_search.h>
+#include <pcl/filters/extract_indices.h>
+#include <pcl/filters/passthrough.h>
+#include <pcl/filters/project_inliers.h>
+#include <pcl/filters/voxel_grid.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
+#include <pcl/search/pcl_search.h>
+#include <pcl/segmentation/extract_clusters.h>
+#include <pcl/segmentation/extract_polygonal_prism_data.h>
 #include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/filters/project_inliers.h>
 #include <pcl/surface/convex_hull.h>
-#include <pcl/segmentation/extract_polygonal_prism_data.h>
-#include <pcl/segmentation/extract_clusters.h>
-
-namespace pcl
-{
-  namespace apps
-  {
-    /** \brief @b DominantPlaneSegmentation performs euclidean segmentation on a scene assuming that a dominant plane exists.
-       * \author Aitor Aldoma
-       * \ingroup apps
-       */
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
-    template<typename PointType>
-      class PCL_EXPORTS DominantPlaneSegmentation
-      {
-      public:
-        using Cloud = pcl::PointCloud<PointType>;
-        using CloudPtr = typename Cloud::Ptr;
-        using CloudConstPtr = typename Cloud::ConstPtr;
-        using KdTreePtr = typename pcl::search::KdTree<PointType>::Ptr;
+namespace pcl {
+namespace apps {
 
-        DominantPlaneSegmentation ()
-        {
-          min_z_bounds_ = 0;
-          max_z_bounds_ = 1.5;
-          object_min_height_ = 0.01;
-          object_max_height_ = 0.7;
-          object_cluster_tolerance_ = 0.05f;
-          object_cluster_min_size_ = 500;
-          k_ = 50;
-          sac_distance_threshold_ = 0.01;
-          downsample_leaf_ = 0.005f;
-          wsize_ = 5;
-        }
+/**
+ * \brief @b DominantPlaneSegmentation performs euclidean segmentation on a scene
+ * assuming that a dominant plane exists.
+ * \author Aitor Aldoma
+ * \ingroup apps
+ */
+template <typename PointType>
+class PCL_EXPORTS DominantPlaneSegmentation {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+  using KdTreePtr = typename pcl::search::KdTree<PointType>::Ptr;
 
-        /* \brief Extract the clusters.
-         * \param clusters Clusters extracted from the initial point cloud at the resolution size
-         * specified by downsample_leaf_
-         */
-        void
-        compute (std::vector<CloudPtr> & clusters);
+  DominantPlaneSegmentation()
+  {
+    min_z_bounds_ = 0;
+    max_z_bounds_ = 1.5;
+    object_min_height_ = 0.01;
+    object_max_height_ = 0.7;
+    object_cluster_tolerance_ = 0.05f;
+    object_cluster_min_size_ = 500;
+    k_ = 50;
+    sac_distance_threshold_ = 0.01;
+    downsample_leaf_ = 0.005f;
+    wsize_ = 5;
+  }
 
-        /* \brief Extract the clusters.
-         * \param clusters Clusters extracted from the initial point cloud. The returned
-         * clusters are not downsampled.
-         */
-        void
-        compute_full (std::vector<CloudPtr> & clusters);
+  /**
+   * \brief Extract the clusters.
+   * \param clusters Clusters extracted from the initial point cloud at the resolution
+   * size specified by downsample_leaf_
+   */
+  void
+  compute(std::vector<CloudPtr>& clusters);
 
-        /* \brief Extract clusters on a plane using connected components on an organized pointcloud.
-         * The method expects a the input cloud to have the is_dense attribute set to false.
-          * \param clusters Clusters extracted from the initial point cloud. The returned
-          * clusters are not downsampled.
-          */
-        void
-        compute_fast (std::vector<CloudPtr> & clusters);
+  /**
+   * \brief Extract the clusters.
+   * \param clusters Clusters extracted from the initial point cloud. The returned
+   * clusters are not downsampled.
+   */
+  void
+  compute_full(std::vector<CloudPtr>& clusters);
 
-        /* \brief Computes the table plane.
-         */
-        void
-        compute_table_plane();
+  /**
+   * \brief Extract clusters on a plane using connected components on an organized
+   * pointcloud. The method expects a the input cloud to have the is_dense attribute set
+   * to false.
+   * \param clusters Clusters extracted from the initial point cloud. The returned
+   * clusters are not downsampled.
+   */
+  void
+  compute_fast(std::vector<CloudPtr>& clusters);
 
-        /* \brief Sets the input point cloud.
-         * \param cloud_in The input point cloud.
-         */
-        void
-        setInputCloud (CloudPtr & cloud_in)
-        {
-          input_ = cloud_in;
-        }
+  /**
+   * \brief Computes the table plane.
+   */
+  void
+  compute_table_plane();
 
-        /* \brief Returns the table coefficients after computation
-         * \param model represents the normal and the position of the plane (a,b,c,d)
-         */
-        void
-        getTableCoefficients (Eigen::Vector4f & model)
-        {
-          model = table_coeffs_;
-        }
+  /**
+   * \brief Sets the input point cloud.
+   * \param cloud_in The input point cloud.
+   */
+  void
+  setInputCloud(CloudPtr& cloud_in)
+  {
+    input_ = cloud_in;
+  }
 
-        /* \brief Sets minimum distance between clusters
-         * \param d distance (in meters)
-         */
-        void
-        setDistanceBetweenClusters (float d) 
-        {
-          object_cluster_tolerance_ = d;
-        }
+  /**
+   * \brief Returns the table coefficients after computation
+   * \param model represents the normal and the position of the plane (a,b,c,d)
+   */
+  void
+  getTableCoefficients(Eigen::Vector4f& model)
+  {
+    model = table_coeffs_;
+  }
 
-        /* \brief Sets minimum size of the clusters.
-         * \param size number of points
-         */
-        void 
-        setMinClusterSize (int size) 
-        {
-          object_cluster_min_size_ = size;
-        }
+  /**
+   * \brief Sets minimum distance between clusters
+   * \param d distance (in meters)
+   */
+  void
+  setDistanceBetweenClusters(float d)
+  {
+    object_cluster_tolerance_ = d;
+  }
 
-        /* \brief Sets the min height of the clusters in order to be considered.
-         * \param h minimum height (in meters)
-         */
-        void
-        setObjectMinHeight (double h)
-        {
-          object_min_height_ = h;
-        }
+  /**
+   * \brief Sets minimum size of the clusters.
+   * \param size number of points
+   */
+  void
+  setMinClusterSize(int size)
+  {
+    object_cluster_min_size_ = size;
+  }
 
-        /* \brief Sets the max height of the clusters in order to be considered.
-         * \param h max height (in meters)
-         */
-        void
-        setObjectMaxHeight (double h)
-        {
-          object_max_height_ = h;
-        }
+  /**
+   * \brief Sets the min height of the clusters in order to be considered.
+   * \param h minimum height (in meters)
+   */
+  void
+  setObjectMinHeight(double h)
+  {
+    object_min_height_ = h;
+  }
 
-        /* \brief Sets minimum distance from the camera for a point to be considered.
-         * \param z distance (in meters)
-         */
-        void
-        setMinZBounds (double z)
-        {
-          min_z_bounds_ = z;
-        }
-        /* \brief Sets maximum distance from the camera for a point to be considered.
-         * \param z distance (in meters)
-         */
-        void
-        setMaxZBounds (double z)
-        {
-          max_z_bounds_ = z;
-        }
+  /**
+   * \brief Sets the max height of the clusters in order to be considered.
+   * \param h max height (in meters)
+   */
+  void
+  setObjectMaxHeight(double h)
+  {
+    object_max_height_ = h;
+  }
 
-        /* \brief Sets the number of neighbors used for normal estimation.
-         * \param k number of neighbors
-         */
-        void setKNeighbors(int k) {
-          k_ = k;
-        }
+  /**
+   * \brief Sets minimum distance from the camera for a point to be considered.
+   * \param z distance (in meters)
+   */
+  void
+  setMinZBounds(double z)
+  {
+    min_z_bounds_ = z;
+  }
+  /**
+   * \brief Sets maximum distance from the camera for a point to be considered.
+   * \param z distance (in meters)
+   */
+  void
+  setMaxZBounds(double z)
+  {
+    max_z_bounds_ = z;
+  }
 
-        /* \brief Set threshold for SAC plane segmentation
-         * \param d threshold (in meters)
-         */
-        void setSACThreshold(double d) {
-          sac_distance_threshold_ = d;
-        }
+  /**
+   * \brief Sets the number of neighbors used for normal estimation.
+   * \param k number of neighbors
+   */
+  void
+  setKNeighbors(int k)
+  {
+    k_ = k;
+  }
 
-        /* \brief Set downsampling resolution.
-         * \param d resolution (in meters)
-         */
-        void 
-        setDownsamplingSize (float d) 
-        {
-          downsample_leaf_ = d;
-        }
+  /**
+   * \brief Set threshold for SAC plane segmentation
+   * \param d threshold (in meters)
+   */
+  void
+  setSACThreshold(double d)
+  {
+    sac_distance_threshold_ = d;
+  }
 
-        /* \brief Set window size in pixels for CC used in compute_fast method
-         * \param w window size (in pixels)
-         */
-        void setWSize(int w) {
-         wsize_ = w;
-        }
+  /**
+   * \brief Set downsampling resolution.
+   * \param d resolution (in meters)
+   */
+  void
+  setDownsamplingSize(float d)
+  {
+    downsample_leaf_ = d;
+  }
 
-        /* \brief Returns the indices of the clusters found by the segmentation
-         * NOTE: This function returns only valid indices if the compute_fast method is used
-         * \param indices indices of the clusters
-         */
-        void getIndicesClusters(std::vector<pcl::PointIndices> & indices) {
-          indices = indices_clusters_;
-        }
+  /**
+   * \brief Set window size in pixels for CC used in compute_fast method
+   * \param w window size (in pixels)
+   */
+  void
+  setWSize(int w)
+  {
+    wsize_ = w;
+  }
 
-      private:
+  /**
+   * \brief Returns the indices of the clusters found by the segmentation
+   * NOTE: This function returns only valid indices if the compute_fast method is used
+   * \param indices indices of the clusters
+   */
+  void
+  getIndicesClusters(std::vector<pcl::PointIndices>& indices)
+  {
+    indices = indices_clusters_;
+  }
 
-        int
-        check (pcl::PointXYZI & p1, pcl::PointXYZI & p2, float, float max_dist)
-        {
-          if (p1.intensity == 0) //new label
-            return 1;
-          //compute distance and check against max_dist
-          if ((p1.getVector3fMap () - p2.getVector3fMap ()).norm () <= max_dist)
-          {
-            p2.intensity = p1.intensity;
-            return 0;
-          }
-          //new label
-          return 1;
-        }
+private:
+  int
+  check(pcl::PointXYZI& p1, pcl::PointXYZI& p2, float, float max_dist)
+  {
+    if (p1.intensity == 0) // new label
+      return 1;
+    // compute distance and check against max_dist
+    if ((p1.getVector3fMap() - p2.getVector3fMap()).norm() <= max_dist) {
+      p2.intensity = p1.intensity;
+      return 0;
+    }
+    // new label
+    return 1;
+  }
 
-        //components needed for cluster segmentation and plane extraction
-        pcl::PassThrough<PointType> pass_;
-        pcl::VoxelGrid<PointType> grid_;
-        pcl::NormalEstimation<PointType, pcl::Normal> n3d_;
-        pcl::SACSegmentationFromNormals<PointType, pcl::Normal> seg_;
-        pcl::ProjectInliers<PointType> proj_;
-        pcl::ProjectInliers<PointType> bb_cluster_proj_;
-        pcl::ConvexHull<PointType> hull_;
-        pcl::ExtractPolygonalPrismData<PointType> prism_;
-        pcl::EuclideanClusterExtraction<PointType> cluster_;
+  // components needed for cluster segmentation and plane extraction
+  pcl::PassThrough<PointType> pass_;
+  pcl::VoxelGrid<PointType> grid_;
+  pcl::NormalEstimation<PointType, pcl::Normal> n3d_;
+  pcl::SACSegmentationFromNormals<PointType, pcl::Normal> seg_;
+  pcl::ProjectInliers<PointType> proj_;
+  pcl::ProjectInliers<PointType> bb_cluster_proj_;
+  pcl::ConvexHull<PointType> hull_;
+  pcl::ExtractPolygonalPrismData<PointType> prism_;
+  pcl::EuclideanClusterExtraction<PointType> cluster_;
 
-        /** \brief Input cloud from which to extract clusters */
-        CloudPtr input_;
-        /** \brief Table coefficients (a,b,c,d) */
-        Eigen::Vector4f table_coeffs_;
-        /** \brief Downsampling resolution. */
-        float downsample_leaf_;
-        /** \brief Number of neighbors for normal estimation */
-        int k_;
-        /** \brief Keep points farther away than min_z_bounds */
-        double min_z_bounds_;
-        /** \brief Keep points closer than max_z_bounds */
-        double max_z_bounds_;
-        /** \brief Threshold for SAC plane segmentation */
-        double sac_distance_threshold_;
-        /** \brief Min height from the table plane object points will be considered from */
-        double object_min_height_;
-        /** \brief Max height from the table plane */
-        double object_max_height_;
-        /** \brief Tolerance between different clusters */
-        float object_cluster_tolerance_;
-        /** \brief Minimum size for a cluster, clusters smaller than this won't be returned */
-        int object_cluster_min_size_;
-        /** \brief Window size in pixels for CC in compute_fast method */
-        int wsize_;
-        /** \brief Indices of the clusters to the main cloud found by the segmentation */
-        std::vector<pcl::PointIndices> indices_clusters_;
+  /** \brief Input cloud from which to extract clusters */
+  CloudPtr input_;
+  /** \brief Table coefficients (a,b,c,d) */
+  Eigen::Vector4f table_coeffs_;
+  /** \brief Downsampling resolution. */
+  float downsample_leaf_;
+  /** \brief Number of neighbors for normal estimation */
+  int k_;
+  /** \brief Keep points farther away than min_z_bounds */
+  double min_z_bounds_;
+  /** \brief Keep points closer than max_z_bounds */
+  double max_z_bounds_;
+  /** \brief Threshold for SAC plane segmentation */
+  double sac_distance_threshold_;
+  /** \brief Min height from the table plane object points will be considered from */
+  double object_min_height_;
+  /** \brief Max height from the table plane */
+  double object_max_height_;
+  /** \brief Tolerance between different clusters */
+  float object_cluster_tolerance_;
+  /** \brief Minimum size for a cluster, clusters smaller than this won't be returned */
+  int object_cluster_min_size_;
+  /** \brief Window size in pixels for CC in compute_fast method */
+  int wsize_;
+  /** \brief Indices of the clusters to the main cloud found by the segmentation */
+  std::vector<pcl::PointIndices> indices_clusters_;
+};
 
-      };
-  }
-}
+} // namespace apps
+} // namespace pcl
 
 #ifdef PCL_NO_PRECOMPILE
 #include <pcl/apps/impl/dominant_plane_segmentation.hpp>
index 549e05bee86aad0cfa71370d7247dba953b81123..ee7ab84e17cce3056a2778d92c367e8f2d9f71cc 100644 (file)
 
 #pragma once
 
-namespace face_detection_apps_utils
-{
-  inline bool readMatrixFromFile(const std::string& file, Eigen::Matrix4f & matrix)
-  {
+namespace face_detection_apps_utils {
 
-    std::ifstream in;
-    in.open (file.c_str (), std::ifstream::in);
-    if (!in.is_open ())
-    {
-      return false;
-    }
+inline bool
+readMatrixFromFile(const std::string& file, Eigen::Matrix4f& matrix)
+{
 
-    char linebuf[1024];
-    in.getline (linebuf, 1024);
-    std::string line (linebuf);
-    std::vector < std::string > strs_2;
-    boost::split (strs_2, line, boost::is_any_of (" "));
+  std::ifstream in;
+  in.open(file.c_str(), std::ifstream::in);
+  if (!in.is_open()) {
+    return false;
+  }
 
-    for (int i = 0; i < 16; i++)
-    {
-      matrix (i / 4, i % 4) = static_cast<float> (atof (strs_2[i].c_str ()));
-    }
+  char linebuf[1024];
+  in.getline(linebuf, 1024);
+  std::string line(linebuf);
+  std::vector<std::string> strs_2;
+  boost::split(strs_2, line, boost::is_any_of(" "));
 
-    return true;
+  for (int i = 0; i < 16; i++) {
+    matrix(i / 4, i % 4) = static_cast<float>(atof(strs_2[i].c_str()));
   }
 
-  inline bool sortFiles(const std::string & file1, const std::string & file2)
-  {
-    std::vector < std::string > strs1;
-    boost::split (strs1, file1, boost::is_any_of ("/"));
+  return true;
+}
 
-    std::vector < std::string > strs2;
-    boost::split (strs2, file2, boost::is_any_of ("/"));
+inline bool
+sortFiles(const std::string& file1, const std::string& file2)
+{
+  std::vector<std::string> strs1;
+  boost::split(strs1, file1, boost::is_any_of("/"));
 
-    std::string id_1 = strs1[strs1.size () - 1];
-    std::string id_2 = strs2[strs2.size () - 1];
+  std::vector<std::string> strs2;
+  boost::split(strs2, file2, boost::is_any_of("/"));
 
-    {
-      std::vector < std::string > strs1;
-      boost::split (strs1, id_1, boost::is_any_of ("_"));
+  std::string id_1 = strs1[strs1.size() - 1];
+  std::string id_2 = strs2[strs2.size() - 1];
 
-      std::vector < std::string > strs2;
-      boost::split (strs2, id_2, boost::is_any_of ("_"));
+  {
+    std::vector<std::string> strs1;
+    boost::split(strs1, id_1, boost::is_any_of("_"));
 
-      std::string id_1 = strs1[strs1.size () - 1];
-      std::string id_2 = strs2[strs2.size () - 1];
+    std::vector<std::string> strs2;
+    boost::split(strs2, id_2, boost::is_any_of("_"));
 
-      std::size_t pos1 = id_1.find (".pcd");
-      std::size_t pos2 = id_2.find (".pcd");
+    std::string id_1 = strs1[strs1.size() - 1];
+    std::string id_2 = strs2[strs2.size() - 1];
 
-      id_1 = id_1.substr (0, pos1);
-      id_2 = id_2.substr (0, pos2);
+    std::size_t pos1 = id_1.find(".pcd");
+    std::size_t pos2 = id_2.find(".pcd");
 
-      return atoi (id_1.c_str ()) < atoi (id_2.c_str ());
-    }
+    id_1 = id_1.substr(0, pos1);
+    id_2 = id_2.substr(0, pos2);
+
+    return atoi(id_1.c_str()) < atoi(id_2.c_str());
   }
+}
 
-  inline
-  void getFilesInDirectory(bf::path & dir, std::string & rel_path_so_far, std::vector<std::string> & relative_paths, std::string & ext)
-  {
-    for (const auto& dir_entry : bf::directory_iterator(dir))
-    {
-      //check if its a directory, then get models in it
-      if (bf::is_directory (dir_entry))
-      {
-        std::string so_far = rel_path_so_far + (dir_entry.path().filename()).string() + "/";
-
-        bf::path curr_path = dir_entry.path ();
-        getFilesInDirectory (curr_path, so_far, relative_paths, ext);
-      } else
-      {
-        //check that it is a ply file and then add, otherwise ignore..
-        std::vector < std::string > strs;
-        std::string file = (dir_entry.path().filename()).string();
-        boost::split (strs, file, boost::is_any_of ("."));
-        std::string extension = strs[strs.size () - 1];
-
-        if (extension == ext)
-        {
-          std::string path = rel_path_so_far + (dir_entry.path().filename()).string();
-          relative_paths.push_back (path);
-        }
+inline void
+getFilesInDirectory(bf::path& dir,
+                    std::string& rel_path_so_far,
+                    std::vector<std::string>& relative_paths,
+                    std::string& ext)
+{
+  for (const auto& dir_entry : bf::directory_iterator(dir)) {
+    // check if its a directory, then get models in it
+    if (bf::is_directory(dir_entry)) {
+      std::string so_far =
+          rel_path_so_far + (dir_entry.path().filename()).string() + "/";
+
+      bf::path curr_path = dir_entry.path();
+      getFilesInDirectory(curr_path, so_far, relative_paths, ext);
+    }
+    else {
+      // check that it is a ply file and then add, otherwise ignore..
+      std::vector<std::string> strs;
+      std::string file = (dir_entry.path().filename()).string();
+      boost::split(strs, file, boost::is_any_of("."));
+      std::string extension = strs[strs.size() - 1];
+
+      if (extension == ext) {
+        std::string path = rel_path_so_far + (dir_entry.path().filename()).string();
+        relative_paths.push_back(path);
       }
     }
   }
+}
 
-  void displayHeads(std::vector<Eigen::VectorXf> & heads, pcl::visualization::PCLVisualizer & vis)
-  {
-    for (std::size_t i = 0; i < heads.size (); i++)
-    {
-      std::stringstream name;
-      name << "sphere" << i;
-      pcl::PointXYZ center_point;
-      center_point.x = heads[i][0];
-      center_point.y = heads[i][1];
-      center_point.z = heads[i][2];
-      vis.addSphere (center_point, 0.02, 0, 255, 0, name.str ());
-
-      pcl::ModelCoefficients cylinder_coeff;
-      cylinder_coeff.values.resize (7); // We need 7 values
-      cylinder_coeff.values[0] = center_point.x;
-      cylinder_coeff.values[1] = center_point.y;
-      cylinder_coeff.values[2] = center_point.z;
-
-      Eigen::Vector3f vec = Eigen::Vector3f::UnitZ () * -1.f;
-      Eigen::Matrix3f matrixxx;
-
-      matrixxx = Eigen::AngleAxisf (heads[i][3], Eigen::Vector3f::UnitX ()) * Eigen::AngleAxisf (heads[i][4], Eigen::Vector3f::UnitY ())
-          * Eigen::AngleAxisf (heads[i][5], Eigen::Vector3f::UnitZ ());
-
-      vec = matrixxx * vec;
-
-      cylinder_coeff.values[3] = vec[0];
-      cylinder_coeff.values[4] = vec[1];
-      cylinder_coeff.values[5] = vec[2];
-
-      cylinder_coeff.values[6] = 0.01f;
-      name << "cylinder";
-      vis.addCylinder (cylinder_coeff, name.str ());
-    }
+void
+displayHeads(std::vector<Eigen::VectorXf>& heads,
+             pcl::visualization::PCLVisualizer& vis)
+{
+  for (std::size_t i = 0; i < heads.size(); i++) {
+    std::stringstream name;
+    name << "sphere" << i;
+    pcl::PointXYZ center_point;
+    center_point.x = heads[i][0];
+    center_point.y = heads[i][1];
+    center_point.z = heads[i][2];
+    vis.addSphere(center_point, 0.02, 0, 255, 0, name.str());
+
+    pcl::ModelCoefficients cylinder_coeff;
+    cylinder_coeff.values.resize(7); // We need 7 values
+    cylinder_coeff.values[0] = center_point.x;
+    cylinder_coeff.values[1] = center_point.y;
+    cylinder_coeff.values[2] = center_point.z;
+
+    Eigen::Vector3f vec = Eigen::Vector3f::UnitZ() * -1.f;
+    Eigen::Matrix3f matrixxx;
+
+    matrixxx = Eigen::AngleAxisf(heads[i][3], Eigen::Vector3f::UnitX()) *
+               Eigen::AngleAxisf(heads[i][4], Eigen::Vector3f::UnitY()) *
+               Eigen::AngleAxisf(heads[i][5], Eigen::Vector3f::UnitZ());
+
+    vec = matrixxx * vec;
+
+    cylinder_coeff.values[3] = vec[0];
+    cylinder_coeff.values[4] = vec[1];
+    cylinder_coeff.values[5] = vec[2];
+
+    cylinder_coeff.values[6] = 0.01f;
+    name << "cylinder";
+    vis.addCylinder(cylinder_coeff, name.str());
   }
 }
+
+} // namespace face_detection_apps_utils
index e8d54009da4da2b9a82cc4ffdac43c4aa861acc5..1fe6f4aacfb40653aa665d1651eede1c2d092581 100644 (file)
@@ -5,37 +5,35 @@
 
 #include <mutex>
 
-namespace OpenNIFrameSource
-{
-
-  using PointT = pcl::PointXYZRGBA;
-  using PointCloud = pcl::PointCloud<PointT>;
-  using PointCloudPtr = pcl::PointCloud<PointT>::Ptr;
-  using PointCloudConstPtr = pcl::PointCloud<PointT>::ConstPtr;
-
-  /* A simple class for capturing data from an OpenNI camera */
-  class PCL_EXPORTS OpenNIFrameSource
-  {
-  public:
-    OpenNIFrameSource (const std::string& device_id = "");
-    ~OpenNIFrameSource ();
-
-    const PointCloudPtr
-    snap ();
-    bool
-    isActive ();
-    void
-    onKeyboardEvent (const pcl::visualization::KeyboardEvent & event);
-
-  protected:
-    void
-    onNewFrame (const PointCloudConstPtr &cloud);
-
-    pcl::OpenNIGrabber grabber_;
-    PointCloudPtr most_recent_frame_;
-    int frame_counter_;
-    std::mutex mutex_;
-    bool active_;
-  };
-
-}
+namespace OpenNIFrameSource {
+
+using PointT = pcl::PointXYZRGBA;
+using PointCloud = pcl::PointCloud<PointT>;
+using PointCloudPtr = pcl::PointCloud<PointT>::Ptr;
+using PointCloudConstPtr = pcl::PointCloud<PointT>::ConstPtr;
+
+/* A simple class for capturing data from an OpenNI camera */
+class PCL_EXPORTS OpenNIFrameSource {
+public:
+  OpenNIFrameSource(const std::string& device_id = "");
+  ~OpenNIFrameSource();
+
+  const PointCloudPtr
+  snap();
+  bool
+  isActive() const;
+  void
+  onKeyboardEvent(const pcl::visualization::KeyboardEvent& event);
+
+protected:
+  void
+  onNewFrame(const PointCloudConstPtr& cloud);
+
+  pcl::OpenNIGrabber grabber_;
+  PointCloudPtr most_recent_frame_;
+  int frame_counter_;
+  std::mutex mutex_;
+  bool active_;
+};
+
+} // namespace OpenNIFrameSource
index e01d057c78d09ae10c6f4356420e3aef811d5198..18e5e005b3b3778a57008d861566b2532cb90226 100644 (file)
  *
  */
 
-#include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/features/integral_image_normal.h>
 #include <pcl/common/time.h>
+#include <pcl/features/integral_image_normal.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/memory.h> // for pcl::make_shared
 
-template<typename PointType> void
-pcl::apps::DominantPlaneSegmentation<PointType>::compute_table_plane ()
+template <typename PointType>
+void
+pcl::apps::DominantPlaneSegmentation<PointType>::compute_table_plane()
 {
   // Has the input dataset been set already?
-  if (!input_)
-  {
-    PCL_WARN ("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
+  if (!input_) {
+    PCL_WARN("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
     return;
   }
 
   CloudConstPtr cloud_;
-  CloudPtr cloud_filtered_ (new Cloud ());
-  CloudPtr cloud_downsampled_ (new Cloud ());
-  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_ (new pcl::PointCloud<pcl::Normal> ());
-  pcl::PointIndices::Ptr table_inliers_ (new pcl::PointIndices ());
-  pcl::ModelCoefficients::Ptr table_coefficients_ (new pcl::ModelCoefficients ());
-  CloudPtr table_projected_ (new Cloud ());
-  CloudPtr table_hull_ (new Cloud ());
+  CloudPtr cloud_filtered_(new Cloud());
+  CloudPtr cloud_downsampled_(new Cloud());
+  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_(new pcl::PointCloud<pcl::Normal>());
+  pcl::PointIndices::Ptr table_inliers_(new pcl::PointIndices());
+  pcl::ModelCoefficients::Ptr table_coefficients_(new pcl::ModelCoefficients());
+  CloudPtr table_projected_(new Cloud());
+  CloudPtr table_hull_(new Cloud());
 
-  typename pcl::search::KdTree<PointType>::Ptr normals_tree_ (new pcl::search::KdTree<PointType>);
+  typename pcl::search::KdTree<PointType>::Ptr normals_tree_(
+      new pcl::search::KdTree<PointType>);
 
   // Normal estimation parameters
-  n3d_.setKSearch (k_);
-  n3d_.setSearchMethod (normals_tree_);
+  n3d_.setKSearch(k_);
+  n3d_.setSearchMethod(normals_tree_);
 
   // Table model fitting parameters
-  seg_.setDistanceThreshold (sac_distance_threshold_);
-  seg_.setMaxIterations (2000);
-  seg_.setNormalDistanceWeight (0.1);
-  seg_.setOptimizeCoefficients (true);
-  seg_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  seg_.setMethodType (pcl::SAC_RANSAC);
-  seg_.setProbability (0.99);
+  seg_.setDistanceThreshold(sac_distance_threshold_);
+  seg_.setMaxIterations(2000);
+  seg_.setNormalDistanceWeight(0.1);
+  seg_.setOptimizeCoefficients(true);
+  seg_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  seg_.setMethodType(pcl::SAC_RANSAC);
+  seg_.setProbability(0.99);
 
-  proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  bb_cluster_proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
+  proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  bb_cluster_proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
 
   // ---[ PassThroughFilter
-  pass_.setFilterLimits (float (min_z_bounds_), float (max_z_bounds_));
-  pass_.setFilterFieldName ("z");
-  pass_.setInputCloud (input_);
-  pass_.filter (*cloud_filtered_);
-
-  if (int (cloud_filtered_->points.size ()) < k_)
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
-        cloud_filtered_->points.size ());
+  pass_.setFilterLimits(float(min_z_bounds_), float(max_z_bounds_));
+  pass_.setFilterFieldName("z");
+  pass_.setInputCloud(input_);
+  pass_.filter(*cloud_filtered_);
+
+  if (int(cloud_filtered_->points.size()) < k_) {
+    PCL_WARN("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
+             cloud_filtered_->points.size());
     return;
   }
 
   // Downsample the point cloud
-  grid_.setLeafSize (downsample_leaf_, downsample_leaf_, downsample_leaf_);
-  grid_.setDownsampleAllData (false);
-  grid_.setInputCloud (cloud_filtered_);
-  grid_.filter (*cloud_downsampled_);
+  grid_.setLeafSize(downsample_leaf_, downsample_leaf_, downsample_leaf_);
+  grid_.setDownsampleAllData(false);
+  grid_.setInputCloud(cloud_filtered_);
+  grid_.filter(*cloud_downsampled_);
 
   // ---[ Estimate the point normals
-  n3d_.setInputCloud (cloud_downsampled_);
-  n3d_.compute (*cloud_normals_);
+  n3d_.setInputCloud(cloud_downsampled_);
+  n3d_.compute(*cloud_normals_);
 
   // ---[ Perform segmentation
-  seg_.setInputCloud (cloud_downsampled_);
-  seg_.setInputNormals (cloud_normals_);
-  seg_.segment (*table_inliers_, *table_coefficients_);
+  seg_.setInputCloud(cloud_downsampled_);
+  seg_.setInputNormals(cloud_normals_);
+  seg_.segment(*table_inliers_, *table_coefficients_);
 
-  if (table_inliers_->indices.empty ())
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
+  if (table_inliers_->indices.empty()) {
+    PCL_WARN("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
     return;
   }
 
   // ---[ Extract the plane
-  proj_.setInputCloud (cloud_downsampled_);
-  proj_.setIndices (table_inliers_);
-  proj_.setModelCoefficients (table_coefficients_);
-  proj_.filter (*table_projected_);
+  proj_.setInputCloud(cloud_downsampled_);
+  proj_.setIndices(table_inliers_);
+  proj_.setModelCoefficients(table_coefficients_);
+  proj_.filter(*table_projected_);
 
   // ---[ Estimate the convex hull
   std::vector<pcl::Vertices> polygons;
-  CloudPtr table_hull (new Cloud ());
-  hull_.setInputCloud (table_projected_);
-  hull_.reconstruct (*table_hull, polygons);
+  CloudPtr table_hull(new Cloud());
+  hull_.setInputCloud(table_projected_);
+  hull_.reconstruct(*table_hull, polygons);
 
   // Compute the plane coefficients
   Eigen::Vector4f model_coefficients;
@@ -130,125 +130,126 @@ pcl::apps::DominantPlaneSegmentation<PointType>::compute_table_plane ()
   model_coefficients[3] = table_coefficients_->values[3];
 
   // Need to flip the plane normal towards the viewpoint
-  Eigen::Vector4f vp (0, 0, 0, 0);
+  Eigen::Vector4f vp(0, 0, 0, 0);
   // See if we need to flip any plane normals
-  vp -= table_hull->points[0].getVector4fMap ();
+  vp -= table_hull->points[0].getVector4fMap();
   vp[3] = 0;
   // Dot product between the (viewpoint - point) and the plane normal
-  float cos_theta = vp.dot (model_coefficients);
+  float cos_theta = vp.dot(model_coefficients);
   // Flip the plane normal
-  if (cos_theta < 0)
-  {
+  if (cos_theta < 0) {
     model_coefficients *= -1;
     model_coefficients[3] = 0;
     // Hessian form (D = nc . p_plane (centroid here) + p)
-    model_coefficients[3] = -1 * (model_coefficients.dot (table_hull->points[0].getVector4fMap ()));
+    model_coefficients[3] =
+        -1 * (model_coefficients.dot(table_hull->points[0].getVector4fMap()));
   }
 
-  //Set table_coeffs
+  // Set table_coeffs
   table_coeffs_ = model_coefficients;
 }
 
-template<typename PointType> void
-pcl::apps::DominantPlaneSegmentation<PointType>::compute_fast (std::vector<CloudPtr> & clusters)
+template <typename PointType>
+void
+pcl::apps::DominantPlaneSegmentation<PointType>::compute_fast(
+    std::vector<CloudPtr>& clusters)
 {
   // Has the input dataset been set already?
-  if (!input_)
-  {
-    PCL_WARN ("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
+  if (!input_) {
+    PCL_WARN("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
     return;
   }
 
   // Is the input dataset organized?
-  if (input_->is_dense)
-  {
-    PCL_WARN ("[pcl::apps::DominantPlaneSegmentation] compute_fast can only be used with organized point clouds!\n");
+  if (input_->is_dense) {
+    PCL_WARN("[pcl::apps::DominantPlaneSegmentation] compute_fast can only be used "
+             "with organized point clouds!\n");
     return;
   }
 
   CloudConstPtr cloud_;
-  CloudPtr cloud_filtered_ (new Cloud ());
-  CloudPtr cloud_downsampled_ (new Cloud ());
-  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_ (new pcl::PointCloud<pcl::Normal> ());
-  pcl::PointIndices::Ptr table_inliers_ (new pcl::PointIndices ());
-  pcl::ModelCoefficients::Ptr table_coefficients_ (new pcl::ModelCoefficients ());
-  CloudPtr table_projected_ (new Cloud ());
-  CloudPtr table_hull_ (new Cloud ());
-  CloudPtr cloud_objects_ (new Cloud ());
-  CloudPtr cluster_object_ (new Cloud ());
-
-  typename pcl::search::KdTree<PointType>::Ptr normals_tree_ (new pcl::search::KdTree<PointType>);
-  typename pcl::search::KdTree<PointType>::Ptr clusters_tree_ (new pcl::search::KdTree<PointType>);
-  clusters_tree_->setEpsilon (1);
+  CloudPtr cloud_filtered_(new Cloud());
+  CloudPtr cloud_downsampled_(new Cloud());
+  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_(new pcl::PointCloud<pcl::Normal>());
+  pcl::PointIndices::Ptr table_inliers_(new pcl::PointIndices());
+  pcl::ModelCoefficients::Ptr table_coefficients_(new pcl::ModelCoefficients());
+  CloudPtr table_projected_(new Cloud());
+  CloudPtr table_hull_(new Cloud());
+  CloudPtr cloud_objects_(new Cloud());
+  CloudPtr cluster_object_(new Cloud());
+
+  typename pcl::search::KdTree<PointType>::Ptr normals_tree_(
+      new pcl::search::KdTree<PointType>);
+  typename pcl::search::KdTree<PointType>::Ptr clusters_tree_(
+      new pcl::search::KdTree<PointType>);
+  clusters_tree_->setEpsilon(1);
 
   // Normal estimation parameters
-  n3d_.setKSearch (k_);
-  n3d_.setSearchMethod (normals_tree_);
+  n3d_.setKSearch(k_);
+  n3d_.setSearchMethod(normals_tree_);
 
   // Table model fitting parameters
-  seg_.setDistanceThreshold (sac_distance_threshold_);
-  seg_.setMaxIterations (2000);
-  seg_.setNormalDistanceWeight (0.1);
-  seg_.setOptimizeCoefficients (true);
-  seg_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  seg_.setMethodType (pcl::SAC_RANSAC);
-  seg_.setProbability (0.99);
+  seg_.setDistanceThreshold(sac_distance_threshold_);
+  seg_.setMaxIterations(2000);
+  seg_.setNormalDistanceWeight(0.1);
+  seg_.setOptimizeCoefficients(true);
+  seg_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  seg_.setMethodType(pcl::SAC_RANSAC);
+  seg_.setProbability(0.99);
 
-  proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  bb_cluster_proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
+  proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  bb_cluster_proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
 
-  prism_.setHeightLimits (object_min_height_, object_max_height_);
+  prism_.setHeightLimits(object_min_height_, object_max_height_);
 
   // Clustering parameters
-  cluster_.setClusterTolerance (object_cluster_tolerance_);
-  cluster_.setMinClusterSize (object_cluster_min_size_);
-  cluster_.setSearchMethod (clusters_tree_);
+  cluster_.setClusterTolerance(object_cluster_tolerance_);
+  cluster_.setMinClusterSize(object_cluster_min_size_);
+  cluster_.setSearchMethod(clusters_tree_);
 
   // ---[ PassThroughFilter
-  pass_.setFilterLimits (float (min_z_bounds_), float (max_z_bounds_));
-  pass_.setFilterFieldName ("z");
-  pass_.setInputCloud (input_);
-  pass_.filter (*cloud_filtered_);
-
-  if (int (cloud_filtered_->points.size ()) < k_)
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
-        cloud_filtered_->points.size ());
+  pass_.setFilterLimits(float(min_z_bounds_), float(max_z_bounds_));
+  pass_.setFilterFieldName("z");
+  pass_.setInputCloud(input_);
+  pass_.filter(*cloud_filtered_);
+
+  if (int(cloud_filtered_->points.size()) < k_) {
+    PCL_WARN("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
+             cloud_filtered_->points.size());
     return;
   }
 
   // Downsample the point cloud
-  grid_.setLeafSize (downsample_leaf_, downsample_leaf_, downsample_leaf_);
-  grid_.setDownsampleAllData (false);
-  grid_.setInputCloud (cloud_filtered_);
-  grid_.filter (*cloud_downsampled_);
+  grid_.setLeafSize(downsample_leaf_, downsample_leaf_, downsample_leaf_);
+  grid_.setDownsampleAllData(false);
+  grid_.setInputCloud(cloud_filtered_);
+  grid_.filter(*cloud_downsampled_);
 
   // ---[ Estimate the point normals
-  n3d_.setInputCloud (cloud_downsampled_);
-  n3d_.compute (*cloud_normals_);
+  n3d_.setInputCloud(cloud_downsampled_);
+  n3d_.compute(*cloud_normals_);
 
   // ---[ Perform segmentation
-  seg_.setInputCloud (cloud_downsampled_);
-  seg_.setInputNormals (cloud_normals_);
-  seg_.segment (*table_inliers_, *table_coefficients_);
+  seg_.setInputCloud(cloud_downsampled_);
+  seg_.setInputNormals(cloud_normals_);
+  seg_.segment(*table_inliers_, *table_coefficients_);
 
-  if (table_inliers_->indices.empty ())
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
+  if (table_inliers_->indices.empty()) {
+    PCL_WARN("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
     return;
   }
 
   // ---[ Extract the plane
-  proj_.setInputCloud (cloud_downsampled_);
-  proj_.setIndices (table_inliers_);
-  proj_.setModelCoefficients (table_coefficients_);
-  proj_.filter (*table_projected_);
+  proj_.setInputCloud(cloud_downsampled_);
+  proj_.setIndices(table_inliers_);
+  proj_.setModelCoefficients(table_coefficients_);
+  proj_.filter(*table_projected_);
 
   // ---[ Estimate the convex hull
   std::vector<pcl::Vertices> polygons;
-  CloudPtr table_hull (new Cloud ());
-  hull_.setInputCloud (table_projected_);
-  hull_.reconstruct (*table_hull, polygons);
+  CloudPtr table_hull(new Cloud());
+  hull_.setInputCloud(table_projected_);
+  hull_.reconstruct(*table_hull, polygons);
 
   // Compute the plane coefficients
   Eigen::Vector4f model_coefficients;
@@ -260,52 +261,54 @@ pcl::apps::DominantPlaneSegmentation<PointType>::compute_fast (std::vector<Cloud
   model_coefficients[3] = table_coefficients_->values[3];
 
   // Need to flip the plane normal towards the viewpoint
-  Eigen::Vector4f vp (0, 0, 0, 0);
+  Eigen::Vector4f vp(0, 0, 0, 0);
   // See if we need to flip any plane normals
-  vp -= table_hull->points[0].getVector4fMap ();
+  vp -= table_hull->points[0].getVector4fMap();
   vp[3] = 0;
   // Dot product between the (viewpoint - point) and the plane normal
-  float cos_theta = vp.dot (model_coefficients);
+  float cos_theta = vp.dot(model_coefficients);
   // Flip the plane normal
-  if (cos_theta < 0)
-  {
+  if (cos_theta < 0) {
     model_coefficients *= -1;
     model_coefficients[3] = 0;
     // Hessian form (D = nc . p_plane (centroid here) + p)
-    model_coefficients[3] = -1 * (model_coefficients.dot (table_hull->points[0].getVector4fMap ()));
+    model_coefficients[3] =
+        -1 * (model_coefficients.dot(table_hull->points[0].getVector4fMap()));
   }
 
-  //Set table_coeffs
+  // Set table_coeffs
   table_coeffs_ = model_coefficients;
 
   // ---[ Get the objects on top of the table
   pcl::PointIndices cloud_object_indices;
-  prism_.setInputCloud (input_);
-  prism_.setInputPlanarHull (table_hull);
-  prism_.segment (cloud_object_indices);
+  prism_.setInputCloud(input_);
+  prism_.setInputPlanarHull(table_hull);
+  prism_.segment(cloud_object_indices);
 
   pcl::ExtractIndices<PointType> extract_object_indices;
-  extract_object_indices.setInputCloud (input_);
-  extract_object_indices.setIndices (boost::make_shared<const pcl::PointIndices> (cloud_object_indices));
-  extract_object_indices.filter (*cloud_objects_);
+  extract_object_indices.setInputCloud(input_);
+  extract_object_indices.setIndices(
+      pcl::make_shared<const pcl::PointIndices>(cloud_object_indices));
+  extract_object_indices.filter(*cloud_objects_);
 
-  //create new binary pointcloud with intensity values (0 and 1), 0 for non-object pixels and 1 otherwise
-  pcl::PointCloud<pcl::PointXYZI>::Ptr binary_cloud (new pcl::PointCloud<pcl::PointXYZI>);
+  // create new binary pointcloud with intensity values (0 and 1),
+  // 0 for non-object pixels and 1 otherwise
+  pcl::PointCloud<pcl::PointXYZI>::Ptr binary_cloud(
+      new pcl::PointCloud<pcl::PointXYZI>);
 
   {
     binary_cloud->width = input_->width;
     binary_cloud->height = input_->height;
-    binary_cloud->points.resize (input_->points.size ());
+    binary_cloud->points.resize(input_->points.size());
     binary_cloud->is_dense = input_->is_dense;
 
-    for (const int &idx : cloud_object_indices.indices)
-    {
-      binary_cloud->points[idx].getVector4fMap () = input_->points[idx].getVector4fMap ();
+    for (const int& idx : cloud_object_indices.indices) {
+      binary_cloud->points[idx].getVector4fMap() = input_->points[idx].getVector4fMap();
       binary_cloud->points[idx].intensity = 1.0;
     }
   }
 
-  //connected components on the binary image
+  // connected components on the binary image
 
   std::map<float, float> connected_labels;
   float c_intensity = 0.1f;
@@ -314,156 +317,156 @@ pcl::apps::DominantPlaneSegmentation<PointType>::compute_fast (std::vector<Cloud
   {
 
     int wsize = wsize_;
-    for (int i = 0; i < int (binary_cloud->width); i++)
-    {
-      for (int j = 0; j < int (binary_cloud->height); j++)
-      {
-        if (binary_cloud->at (i, j).intensity != 0)
-        {
-          //check neighboring pixels, first left and then top
-          //be aware of margins
-
-          if ((i - 1) < 0 && (j - 1) < 0)
-          {
-            //top-left pixel
-            (*binary_cloud) (i, j).intensity = c_intensity;
+    for (int i = 0; i < int(binary_cloud->width); i++) {
+      for (int j = 0; j < int(binary_cloud->height); j++) {
+        if (binary_cloud->at(i, j).intensity != 0) {
+          // check neighboring pixels, first left and then top
+          // be aware of margins
+
+          if ((i - 1) < 0 && (j - 1) < 0) {
+            // top-left pixel
+            (*binary_cloud)(i, j).intensity = c_intensity;
           }
-          else
-          {
-            if ((j - 1) < 0)
-            {
-              //top-row, check on the left of pixel to assign a new label or not
-              int left = check ((*binary_cloud) (i - 1, j), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-              if (left)
-              {
-                //Nothing found on the left, check bigger window
+          else {
+            if ((j - 1) < 0) {
+              // top-row, check on the left of pixel to assign a new label or not
+              int left = check((*binary_cloud)(i - 1, j),
+                               (*binary_cloud)(i, j),
+                               c_intensity,
+                               object_cluster_tolerance_);
+              if (left) {
+                // Nothing found on the left, check bigger window
 
                 bool found = false;
-                for (int kk = 2; kk < wsize && !found; kk++)
-                {
+                for (int kk = 2; kk < wsize && !found; kk++) {
                   if ((i - kk) < 0)
                     continue;
 
-                  int left = check ((*binary_cloud) (i - kk, j), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-                  if (left == 0)
-                  {
+                  int left = check((*binary_cloud)(i - kk, j),
+                                   (*binary_cloud)(i, j),
+                                   c_intensity,
+                                   object_cluster_tolerance_);
+                  if (left == 0) {
                     found = true;
                   }
                 }
 
-                if (!found)
-                {
+                if (!found) {
                   c_intensity += intensity_incr;
-                  (*binary_cloud) (i, j).intensity = c_intensity;
+                  (*binary_cloud)(i, j).intensity = c_intensity;
                 }
-
               }
             }
-            else
-            {
-              if ((i - 1) == 0)
-              {
-                //check only top
-                int top = check ((*binary_cloud) (i, j - 1), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-                if (top)
-                {
+            else {
+              if ((i - 1) == 0) {
+                // check only top
+                int top = check((*binary_cloud)(i, j - 1),
+                                (*binary_cloud)(i, j),
+                                c_intensity,
+                                object_cluster_tolerance_);
+                if (top) {
                   bool found = false;
-                  for (int kk = 2; kk < wsize && !found; kk++)
-                  {
+                  for (int kk = 2; kk < wsize && !found; kk++) {
                     if ((j - kk) < 0)
                       continue;
 
-                    int top = check ((*binary_cloud) (i, j - kk), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-                    if (top == 0)
-                    {
+                    int top = check((*binary_cloud)(i, j - kk),
+                                    (*binary_cloud)(i, j),
+                                    c_intensity,
+                                    object_cluster_tolerance_);
+                    if (top == 0) {
                       found = true;
                     }
                   }
 
-                  if (!found)
-                  {
+                  if (!found) {
                     c_intensity += intensity_incr;
-                    (*binary_cloud) (i, j).intensity = c_intensity;
+                    (*binary_cloud)(i, j).intensity = c_intensity;
                   }
                 }
-
               }
-              else
-              {
-                //check left and top
-                int left = check ((*binary_cloud) (i - 1, j), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-                int top = check ((*binary_cloud) (i, j - 1), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-
-                if (left == 0 && top == 0)
-                {
-                  //both top and left had labels, check if they are different
-                  //if they are, take the smallest one and mark labels to be connected..
-
-                  if ((*binary_cloud) (i - 1, j).intensity != (*binary_cloud) (i, j - 1).intensity)
-                  {
-                    float smaller_intensity = (*binary_cloud) (i - 1, j).intensity;
-                    float bigger_intensity = (*binary_cloud) (i, j - 1).intensity;
-
-                    if ((*binary_cloud) (i - 1, j).intensity > (*binary_cloud) (i, j - 1).intensity)
-                    {
-                      smaller_intensity = (*binary_cloud) (i, j - 1).intensity;
-                      bigger_intensity = (*binary_cloud) (i - 1, j).intensity;
+              else {
+                // check left and top
+                int left = check((*binary_cloud)(i - 1, j),
+                                 (*binary_cloud)(i, j),
+                                 c_intensity,
+                                 object_cluster_tolerance_);
+                int top = check((*binary_cloud)(i, j - 1),
+                                (*binary_cloud)(i, j),
+                                c_intensity,
+                                object_cluster_tolerance_);
+
+                if (left == 0 && top == 0) {
+                  // both top and left had labels, check if they are different
+                  // if they are, take the smallest one and mark labels to be
+                  // connected..
+
+                  if ((*binary_cloud)(i - 1, j).intensity !=
+                      (*binary_cloud)(i, j - 1).intensity) {
+                    float smaller_intensity = (*binary_cloud)(i - 1, j).intensity;
+                    float bigger_intensity = (*binary_cloud)(i, j - 1).intensity;
+
+                    if ((*binary_cloud)(i - 1, j).intensity >
+                        (*binary_cloud)(i, j - 1).intensity) {
+                      smaller_intensity = (*binary_cloud)(i, j - 1).intensity;
+                      bigger_intensity = (*binary_cloud)(i - 1, j).intensity;
                     }
 
                     connected_labels[bigger_intensity] = smaller_intensity;
-                    (*binary_cloud) (i, j).intensity = smaller_intensity;
+                    (*binary_cloud)(i, j).intensity = smaller_intensity;
                   }
                 }
 
-                if (left == 1 && top == 1)
-                {
-                  //if none had labels, increment c_intensity
-                  //search first on bigger window
+                if (left == 1 && top == 1) {
+                  // if none had labels, increment c_intensity
+                  // search first on bigger window
                   bool found = false;
-                  for (int dist = 2; dist < wsize && !found; dist++)
-                  {
+                  for (int dist = 2; dist < wsize && !found; dist++) {
                     if (((i - dist) < 0) || ((j - dist) < 0))
                       continue;
 
-                    int left = check ((*binary_cloud) (i - dist, j), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-                    int top = check ((*binary_cloud) (i, j - dist), (*binary_cloud) (i, j), c_intensity, object_cluster_tolerance_);
-
-                    if (left == 0 && top == 0)
-                    {
-                      if ((*binary_cloud) (i - dist, j).intensity != (*binary_cloud) (i, j - dist).intensity)
-                      {
-                        float smaller_intensity = (*binary_cloud) (i - dist, j).intensity;
-                        float bigger_intensity = (*binary_cloud) (i, j - dist).intensity;
-
-                        if ((*binary_cloud) (i - dist, j).intensity > (*binary_cloud) (i, j - dist).intensity)
-                        {
-                          smaller_intensity = (*binary_cloud) (i, j - dist).intensity;
-                          bigger_intensity = (*binary_cloud) (i - dist, j).intensity;
+                    int left = check((*binary_cloud)(i - dist, j),
+                                     (*binary_cloud)(i, j),
+                                     c_intensity,
+                                     object_cluster_tolerance_);
+                    int top = check((*binary_cloud)(i, j - dist),
+                                    (*binary_cloud)(i, j),
+                                    c_intensity,
+                                    object_cluster_tolerance_);
+
+                    if (left == 0 && top == 0) {
+                      if ((*binary_cloud)(i - dist, j).intensity !=
+                          (*binary_cloud)(i, j - dist).intensity) {
+                        float smaller_intensity =
+                            (*binary_cloud)(i - dist, j).intensity;
+                        float bigger_intensity = (*binary_cloud)(i, j - dist).intensity;
+
+                        if ((*binary_cloud)(i - dist, j).intensity >
+                            (*binary_cloud)(i, j - dist).intensity) {
+                          smaller_intensity = (*binary_cloud)(i, j - dist).intensity;
+                          bigger_intensity = (*binary_cloud)(i - dist, j).intensity;
                         }
 
                         connected_labels[bigger_intensity] = smaller_intensity;
-                        (*binary_cloud) (i, j).intensity = smaller_intensity;
+                        (*binary_cloud)(i, j).intensity = smaller_intensity;
                         found = true;
                       }
                     }
-                    else if (left == 0 || top == 0)
-                    {
-                      //one had label
+                    else if (left == 0 || top == 0) {
+                      // one had label
                       found = true;
                     }
                   }
 
-                  if (!found)
-                  {
-                    //none had label in the bigger window
+                  if (!found) {
+                    // none had label in the bigger window
                     c_intensity += intensity_incr;
-                    (*binary_cloud) (i, j).intensity = c_intensity;
+                    (*binary_cloud)(i, j).intensity = c_intensity;
                   }
                 }
               }
             }
           }
-
         }
       }
     }
@@ -474,154 +477,154 @@ pcl::apps::DominantPlaneSegmentation<PointType>::compute_fast (std::vector<Cloud
   {
     std::map<float, float>::iterator it;
 
-    for (int i = 0; i < int (binary_cloud->width); i++)
-    {
-      for (int j = 0; j < int (binary_cloud->height); j++)
-      {
-        if (binary_cloud->at (i, j).intensity != 0)
-        {
-          //check if this is a root label...
-          it = connected_labels.find (binary_cloud->at (i, j).intensity);
-          while (it != connected_labels.end ())
-          {
-            //the label is on the list, change pixel intensity until it has a root label
-            (*binary_cloud) (i, j).intensity = (*it).second;
-            it = connected_labels.find (binary_cloud->at (i, j).intensity);
+    for (int i = 0; i < int(binary_cloud->width); i++) {
+      for (int j = 0; j < int(binary_cloud->height); j++) {
+        if (binary_cloud->at(i, j).intensity != 0) {
+          // check if this is a root label...
+          it = connected_labels.find(binary_cloud->at(i, j).intensity);
+          while (it != connected_labels.end()) {
+            // the label is on the list, change pixel intensity until it
+            // has a root label
+            (*binary_cloud)(i, j).intensity = (*it).second;
+            it = connected_labels.find(binary_cloud->at(i, j).intensity);
           }
 
           std::map<float, pcl::PointIndices>::iterator it_indices;
-          it_indices = clusters_map.find (binary_cloud->at (i, j).intensity);
-          if (it_indices == clusters_map.end ())
-          {
+          it_indices = clusters_map.find(binary_cloud->at(i, j).intensity);
+          if (it_indices == clusters_map.end()) {
             pcl::PointIndices indices;
-            clusters_map[binary_cloud->at (i, j).intensity] = indices;
+            clusters_map[binary_cloud->at(i, j).intensity] = indices;
           }
 
-          clusters_map[binary_cloud->at (i, j).intensity].indices.push_back (static_cast<int> (j * binary_cloud->width + i));
+          clusters_map[binary_cloud->at(i, j).intensity].indices.push_back(
+              static_cast<int>(j * binary_cloud->width + i));
         }
       }
     }
   }
 
-  clusters.resize (clusters_map.size ());
+  clusters.resize(clusters_map.size());
 
   int k = 0;
-  for (const auto &cluster : clusters_map)
-  {
+  for (const auto& cluster : clusters_map) {
 
-    if (int (cluster.second.indices.size ()) >= object_cluster_min_size_)
-    {
+    if (int(cluster.second.indices.size()) >= object_cluster_min_size_) {
 
-      clusters[k] = CloudPtr (new Cloud ());
-      pcl::copyPointCloud (*input_, cluster.second.indices, *clusters[k]);
+      clusters[k] = CloudPtr(new Cloud());
+      pcl::copyPointCloud(*input_, cluster.second.indices, *clusters[k]);
       k++;
       indices_clusters_.push_back(cluster.second);
     }
   }
 
-  clusters.resize (k);
-
+  clusters.resize(k);
 }
 
-template<typename PointType> void
-pcl::apps::DominantPlaneSegmentation<PointType>::compute (std::vector<CloudPtr> & clusters)
+template <typename PointType>
+void
+pcl::apps::DominantPlaneSegmentation<PointType>::compute(
+    std::vector<CloudPtr>& clusters)
 {
 
   // Has the input dataset been set already?
-  if (!input_)
-  {
-    PCL_WARN ("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
+  if (!input_) {
+    PCL_WARN("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
     return;
   }
 
   CloudConstPtr cloud_;
-  CloudPtr cloud_filtered_ (new Cloud ());
-  CloudPtr cloud_downsampled_ (new Cloud ());
-  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_ (new pcl::PointCloud<pcl::Normal> ());
-  pcl::PointIndices::Ptr table_inliers_ (new pcl::PointIndices ());
-  pcl::ModelCoefficients::Ptr table_coefficients_ (new pcl::ModelCoefficients ());
-  CloudPtr table_projected_ (new Cloud ());
-  CloudPtr table_hull_ (new Cloud ());
-  CloudPtr cloud_objects_ (new Cloud ());
-  CloudPtr cluster_object_ (new Cloud ());
-
-  typename pcl::search::KdTree<PointType>::Ptr normals_tree_ (new pcl::search::KdTree<PointType>);
-  typename pcl::search::KdTree<PointType>::Ptr clusters_tree_ (new pcl::search::KdTree<PointType>);
-  clusters_tree_->setEpsilon (1);
+  CloudPtr cloud_filtered_(new Cloud());
+  CloudPtr cloud_downsampled_(new Cloud());
+  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_(new pcl::PointCloud<pcl::Normal>());
+  pcl::PointIndices::Ptr table_inliers_(new pcl::PointIndices());
+  pcl::ModelCoefficients::Ptr table_coefficients_(new pcl::ModelCoefficients());
+  CloudPtr table_projected_(new Cloud());
+  CloudPtr table_hull_(new Cloud());
+  CloudPtr cloud_objects_(new Cloud());
+  CloudPtr cluster_object_(new Cloud());
+
+  typename pcl::search::KdTree<PointType>::Ptr normals_tree_(
+      new pcl::search::KdTree<PointType>);
+  typename pcl::search::KdTree<PointType>::Ptr clusters_tree_(
+      new pcl::search::KdTree<PointType>);
+  clusters_tree_->setEpsilon(1);
 
   // Normal estimation parameters
-  n3d_.setKSearch (k_);
-  n3d_.setSearchMethod (normals_tree_);
+  n3d_.setKSearch(k_);
+  n3d_.setSearchMethod(normals_tree_);
 
   // Table model fitting parameters
-  seg_.setDistanceThreshold (sac_distance_threshold_);
-  seg_.setMaxIterations (2000);
-  seg_.setNormalDistanceWeight (0.1);
-  seg_.setOptimizeCoefficients (true);
-  seg_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  seg_.setMethodType (pcl::SAC_RANSAC);
-  seg_.setProbability (0.99);
+  seg_.setDistanceThreshold(sac_distance_threshold_);
+  seg_.setMaxIterations(2000);
+  seg_.setNormalDistanceWeight(0.1);
+  seg_.setOptimizeCoefficients(true);
+  seg_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  seg_.setMethodType(pcl::SAC_RANSAC);
+  seg_.setProbability(0.99);
 
-  proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  bb_cluster_proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
+  proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  bb_cluster_proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
 
-  prism_.setHeightLimits (object_min_height_, object_max_height_);
+  prism_.setHeightLimits(object_min_height_, object_max_height_);
 
   // Clustering parameters
-  cluster_.setClusterTolerance (object_cluster_tolerance_);
-  cluster_.setMinClusterSize (object_cluster_min_size_);
-  cluster_.setSearchMethod (clusters_tree_);
+  cluster_.setClusterTolerance(object_cluster_tolerance_);
+  cluster_.setMinClusterSize(object_cluster_min_size_);
+  cluster_.setSearchMethod(clusters_tree_);
 
   // ---[ PassThroughFilter
-  pass_.setFilterLimits (float (min_z_bounds_), float (max_z_bounds_));
-  pass_.setFilterFieldName ("z");
-  pass_.setInputCloud (input_);
-  pass_.filter (*cloud_filtered_);
-
-  if (int (cloud_filtered_->points.size ()) < k_)
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
-        cloud_filtered_->points.size ());
+  pass_.setFilterLimits(float(min_z_bounds_), float(max_z_bounds_));
+  pass_.setFilterFieldName("z");
+  pass_.setInputCloud(input_);
+  pass_.filter(*cloud_filtered_);
+
+  if (int(cloud_filtered_->points.size()) < k_) {
+    PCL_WARN("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
+             cloud_filtered_->points.size());
     return;
   }
 
   // Downsample the point cloud
-  grid_.setLeafSize (downsample_leaf_, downsample_leaf_, downsample_leaf_);
-  grid_.setDownsampleAllData (false);
-  grid_.setInputCloud (cloud_filtered_);
-  grid_.filter (*cloud_downsampled_);
-
-  PCL_INFO ("[DominantPlaneSegmentation] Number of points left after filtering (%f -> %f): %lu out of %lu\n",
-      min_z_bounds_, max_z_bounds_, cloud_downsampled_->points.size (), input_->points.size ());
+  grid_.setLeafSize(downsample_leaf_, downsample_leaf_, downsample_leaf_);
+  grid_.setDownsampleAllData(false);
+  grid_.setInputCloud(cloud_filtered_);
+  grid_.filter(*cloud_downsampled_);
+
+  PCL_INFO("[DominantPlaneSegmentation] Number of points left after filtering "
+           "(%f -> %f): %lu out of %lu\n",
+           min_z_bounds_,
+           max_z_bounds_,
+           cloud_downsampled_->points.size(),
+           input_->points.size());
 
   // ---[ Estimate the point normals
-  n3d_.setInputCloud (cloud_downsampled_);
-  n3d_.compute (*cloud_normals_);
+  n3d_.setInputCloud(cloud_downsampled_);
+  n3d_.compute(*cloud_normals_);
 
-  PCL_INFO ("[DominantPlaneSegmentation] %lu normals estimated. \n", cloud_normals_->points.size ());
+  PCL_INFO("[DominantPlaneSegmentation] %lu normals estimated. \n",
+           cloud_normals_->points.size());
 
   // ---[ Perform segmentation
-  seg_.setInputCloud (cloud_downsampled_);
-  seg_.setInputNormals (cloud_normals_);
-  seg_.segment (*table_inliers_, *table_coefficients_);
+  seg_.setInputCloud(cloud_downsampled_);
+  seg_.setInputNormals(cloud_normals_);
+  seg_.segment(*table_inliers_, *table_coefficients_);
 
-  if (table_inliers_->indices.empty ())
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
+  if (table_inliers_->indices.empty()) {
+    PCL_WARN("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
     return;
   }
 
   // ---[ Extract the plane
-  proj_.setInputCloud (cloud_downsampled_);
-  proj_.setIndices (table_inliers_);
-  proj_.setModelCoefficients (table_coefficients_);
-  proj_.filter (*table_projected_);
+  proj_.setInputCloud(cloud_downsampled_);
+  proj_.setIndices(table_inliers_);
+  proj_.setModelCoefficients(table_coefficients_);
+  proj_.filter(*table_projected_);
 
   // ---[ Estimate the convex hull
   std::vector<pcl::Vertices> polygons;
-  CloudPtr table_hull (new Cloud ());
-  hull_.setInputCloud (table_projected_);
-  hull_.reconstruct (*table_hull, polygons);
+  CloudPtr table_hull(new Cloud());
+  hull_.setInputCloud(table_projected_);
+  hull_.reconstruct(*table_hull, polygons);
 
   // Compute the plane coefficients
   Eigen::Vector4f model_coefficients;
@@ -633,158 +636,164 @@ pcl::apps::DominantPlaneSegmentation<PointType>::compute (std::vector<CloudPtr>
   model_coefficients[3] = table_coefficients_->values[3];
 
   // Need to flip the plane normal towards the viewpoint
-  Eigen::Vector4f vp (0, 0, 0, 0);
+  Eigen::Vector4f vp(0, 0, 0, 0);
   // See if we need to flip any plane normals
-  vp -= table_hull->points[0].getVector4fMap ();
+  vp -= table_hull->points[0].getVector4fMap();
   vp[3] = 0;
   // Dot product between the (viewpoint - point) and the plane normal
-  float cos_theta = vp.dot (model_coefficients);
+  float cos_theta = vp.dot(model_coefficients);
   // Flip the plane normal
-  if (cos_theta < 0)
-  {
+  if (cos_theta < 0) {
     model_coefficients *= -1;
     model_coefficients[3] = 0;
     // Hessian form (D = nc . p_plane (centroid here) + p)
-    model_coefficients[3] = -1 * (model_coefficients.dot (table_hull->points[0].getVector4fMap ()));
+    model_coefficients[3] =
+        -1 * (model_coefficients.dot(table_hull->points[0].getVector4fMap()));
   }
 
-  //Set table_coeffs
+  // Set table_coeffs
   table_coeffs_ = model_coefficients;
 
   // ---[ Get the objects on top of the table
   pcl::PointIndices cloud_object_indices;
-  prism_.setInputCloud (cloud_downsampled_);
-  prism_.setInputPlanarHull (table_hull);
-  prism_.segment (cloud_object_indices);
+  prism_.setInputCloud(cloud_downsampled_);
+  prism_.setInputPlanarHull(table_hull);
+  prism_.segment(cloud_object_indices);
 
   pcl::ExtractIndices<PointType> extract_object_indices;
-  extract_object_indices.setInputCloud (cloud_downsampled_);
-  extract_object_indices.setIndices (boost::make_shared<const pcl::PointIndices> (cloud_object_indices));
-  extract_object_indices.filter (*cloud_objects_);
+  extract_object_indices.setInputCloud(cloud_downsampled_);
+  extract_object_indices.setIndices(
+      pcl::make_shared<const pcl::PointIndices>(cloud_object_indices));
+  extract_object_indices.filter(*cloud_objects_);
 
-  if (cloud_objects_->points.empty ())
+  if (cloud_objects_->points.empty())
     return;
 
-  //down_.reset(new Cloud(*cloud_downsampled_));
+  // down_.reset(new Cloud(*cloud_downsampled_));
 
   // ---[ Split the objects into Euclidean clusters
   std::vector<pcl::PointIndices> clusters2;
-  cluster_.setInputCloud (cloud_downsampled_);
-  cluster_.setIndices (boost::make_shared<const pcl::PointIndices> (cloud_object_indices));
-  cluster_.extract (clusters2);
+  cluster_.setInputCloud(cloud_downsampled_);
+  cluster_.setIndices(pcl::make_shared<const pcl::PointIndices>(cloud_object_indices));
+  cluster_.extract(clusters2);
 
-  PCL_INFO ("[DominantPlaneSegmentation::compute()] Number of clusters found matching the given constraints: %lu.\n",
-      clusters2.size ());
+  PCL_INFO("[DominantPlaneSegmentation::compute()] Number of clusters found matching "
+           "the given constraints: %lu.\n",
+           clusters2.size());
 
-  clusters.resize (clusters2.size ());
+  clusters.resize(clusters2.size());
 
-  for (std::size_t i = 0; i < clusters2.size (); ++i)
-  {
-    clusters[i] = CloudPtr (new Cloud ());
-    pcl::copyPointCloud (*cloud_downsampled_, clusters2[i].indices, *clusters[i]);
+  for (std::size_t i = 0; i < clusters2.size(); ++i) {
+    clusters[i] = CloudPtr(new Cloud());
+    pcl::copyPointCloud(*cloud_downsampled_, clusters2[i].indices, *clusters[i]);
   }
 }
 
-template<typename PointType>
+template <typename PointType>
 void
-pcl::apps::DominantPlaneSegmentation<PointType>::compute_full (std::vector<CloudPtr> & clusters)
+pcl::apps::DominantPlaneSegmentation<PointType>::compute_full(
+    std::vector<CloudPtr>& clusters)
 {
 
   // Has the input dataset been set already?
-  if (!input_)
-  {
-    PCL_WARN ("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
+  if (!input_) {
+    PCL_WARN("[pcl::apps::DominantPlaneSegmentation] No input dataset given!\n");
     return;
   }
 
   CloudConstPtr cloud_;
-  CloudPtr cloud_filtered_ (new Cloud ());
-  CloudPtr cloud_downsampled_ (new Cloud ());
-  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_ (new pcl::PointCloud<pcl::Normal> ());
-  pcl::PointIndices::Ptr table_inliers_ (new pcl::PointIndices ());
-  pcl::ModelCoefficients::Ptr table_coefficients_ (new pcl::ModelCoefficients ());
-  CloudPtr table_projected_ (new Cloud ());
-  CloudPtr table_hull_ (new Cloud ());
-  CloudPtr cloud_objects_ (new Cloud ());
-  CloudPtr cluster_object_ (new Cloud ());
-
-  typename pcl::search::KdTree<PointType>::Ptr normals_tree_ (new pcl::search::KdTree<PointType>);
-  typename pcl::search::KdTree<PointType>::Ptr clusters_tree_ (new pcl::search::KdTree<PointType>);
-  clusters_tree_->setEpsilon (1);
+  CloudPtr cloud_filtered_(new Cloud());
+  CloudPtr cloud_downsampled_(new Cloud());
+  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_(new pcl::PointCloud<pcl::Normal>());
+  pcl::PointIndices::Ptr table_inliers_(new pcl::PointIndices());
+  pcl::ModelCoefficients::Ptr table_coefficients_(new pcl::ModelCoefficients());
+  CloudPtr table_projected_(new Cloud());
+  CloudPtr table_hull_(new Cloud());
+  CloudPtr cloud_objects_(new Cloud());
+  CloudPtr cluster_object_(new Cloud());
+
+  typename pcl::search::KdTree<PointType>::Ptr normals_tree_(
+      new pcl::search::KdTree<PointType>);
+  typename pcl::search::KdTree<PointType>::Ptr clusters_tree_(
+      new pcl::search::KdTree<PointType>);
+  clusters_tree_->setEpsilon(1);
 
   // Normal estimation parameters
-  n3d_.setKSearch (10);
-  n3d_.setSearchMethod (normals_tree_);
+  n3d_.setKSearch(10);
+  n3d_.setSearchMethod(normals_tree_);
 
   // Table model fitting parameters
-  seg_.setDistanceThreshold (sac_distance_threshold_);
-  seg_.setMaxIterations (2000);
-  seg_.setNormalDistanceWeight (0.1);
-  seg_.setOptimizeCoefficients (true);
-  seg_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  seg_.setMethodType (pcl::SAC_MSAC);
-  seg_.setProbability (0.98);
+  seg_.setDistanceThreshold(sac_distance_threshold_);
+  seg_.setMaxIterations(2000);
+  seg_.setNormalDistanceWeight(0.1);
+  seg_.setOptimizeCoefficients(true);
+  seg_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  seg_.setMethodType(pcl::SAC_MSAC);
+  seg_.setProbability(0.98);
 
-  proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
-  bb_cluster_proj_.setModelType (pcl::SACMODEL_NORMAL_PLANE);
+  proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
+  bb_cluster_proj_.setModelType(pcl::SACMODEL_NORMAL_PLANE);
 
-  prism_.setHeightLimits (object_min_height_, object_max_height_);
+  prism_.setHeightLimits(object_min_height_, object_max_height_);
 
   // Clustering parameters
-  cluster_.setClusterTolerance (object_cluster_tolerance_);
-  cluster_.setMinClusterSize (object_cluster_min_size_);
-  cluster_.setSearchMethod (clusters_tree_);
+  cluster_.setClusterTolerance(object_cluster_tolerance_);
+  cluster_.setMinClusterSize(object_cluster_min_size_);
+  cluster_.setSearchMethod(clusters_tree_);
 
   // ---[ PassThroughFilter
-  pass_.setFilterLimits (float (min_z_bounds_), float (max_z_bounds_));
-  pass_.setFilterFieldName ("z");
-  pass_.setInputCloud (input_);
-  pass_.filter (*cloud_filtered_);
-
-  if (int (cloud_filtered_->points.size ()) < k_)
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
-        cloud_filtered_->points.size ());
+  pass_.setFilterLimits(float(min_z_bounds_), float(max_z_bounds_));
+  pass_.setFilterFieldName("z");
+  pass_.setInputCloud(input_);
+  pass_.filter(*cloud_filtered_);
+
+  if (int(cloud_filtered_->points.size()) < k_) {
+    PCL_WARN("[DominantPlaneSegmentation] Filtering returned %lu points! Aborting.",
+             cloud_filtered_->points.size());
     return;
   }
 
   // Downsample the point cloud
-  grid_.setLeafSize (downsample_leaf_, downsample_leaf_, downsample_leaf_);
-  grid_.setDownsampleAllData (false);
-  grid_.setInputCloud (cloud_filtered_);
-  grid_.filter (*cloud_downsampled_);
-
-  PCL_INFO ("[DominantPlaneSegmentation] Number of points left after filtering&downsampling (%f -> %f): %lu out of %lu\n",
-      min_z_bounds_, max_z_bounds_, cloud_downsampled_->points.size (), input_->points.size ());
+  grid_.setLeafSize(downsample_leaf_, downsample_leaf_, downsample_leaf_);
+  grid_.setDownsampleAllData(false);
+  grid_.setInputCloud(cloud_filtered_);
+  grid_.filter(*cloud_downsampled_);
+
+  PCL_INFO("[DominantPlaneSegmentation] Number of points left after "
+           "filtering&downsampling (%f -> %f): %lu out of %lu\n",
+           min_z_bounds_,
+           max_z_bounds_,
+           cloud_downsampled_->points.size(),
+           input_->points.size());
 
   // ---[ Estimate the point normals
-  n3d_.setInputCloud (cloud_downsampled_);
-  n3d_.compute (*cloud_normals_);
+  n3d_.setInputCloud(cloud_downsampled_);
+  n3d_.compute(*cloud_normals_);
 
-  PCL_INFO ("[DominantPlaneSegmentation] %lu normals estimated. \n", cloud_normals_->points.size ());
+  PCL_INFO("[DominantPlaneSegmentation] %lu normals estimated. \n",
+           cloud_normals_->points.size());
 
   // ---[ Perform segmentation
-  seg_.setInputCloud (cloud_downsampled_);
-  seg_.setInputNormals (cloud_normals_);
-  seg_.segment (*table_inliers_, *table_coefficients_);
+  seg_.setInputCloud(cloud_downsampled_);
+  seg_.setInputNormals(cloud_normals_);
+  seg_.segment(*table_inliers_, *table_coefficients_);
 
-  if (table_inliers_->indices.empty ())
-  {
-    PCL_WARN ("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
+  if (table_inliers_->indices.empty()) {
+    PCL_WARN("[DominantPlaneSegmentation] No Plane Inliers points! Aborting.");
     return;
   }
 
   // ---[ Extract the plane
-  proj_.setInputCloud (cloud_downsampled_);
-  proj_.setIndices (table_inliers_);
-  proj_.setModelCoefficients (table_coefficients_);
-  proj_.filter (*table_projected_);
+  proj_.setInputCloud(cloud_downsampled_);
+  proj_.setIndices(table_inliers_);
+  proj_.setModelCoefficients(table_coefficients_);
+  proj_.filter(*table_projected_);
 
   // ---[ Estimate the convex hull
   std::vector<pcl::Vertices> polygons;
-  CloudPtr table_hull (new Cloud ());
-  hull_.setInputCloud (table_projected_);
-  hull_.reconstruct (*table_hull, polygons);
+  CloudPtr table_hull(new Cloud());
+  hull_.setInputCloud(table_projected_);
+  hull_.reconstruct(*table_hull, polygons);
 
   // Compute the plane coefficients
   Eigen::Vector4f model_coefficients;
@@ -796,54 +805,56 @@ pcl::apps::DominantPlaneSegmentation<PointType>::compute_full (std::vector<Cloud
   model_coefficients[3] = table_coefficients_->values[3];
 
   // Need to flip the plane normal towards the viewpoint
-  Eigen::Vector4f vp (0, 0, 0, 0);
+  Eigen::Vector4f vp(0, 0, 0, 0);
   // See if we need to flip any plane normals
-  vp -= table_hull->points[0].getVector4fMap ();
+  vp -= table_hull->points[0].getVector4fMap();
   vp[3] = 0;
   // Dot product between the (viewpoint - point) and the plane normal
-  float cos_theta = vp.dot (model_coefficients);
+  float cos_theta = vp.dot(model_coefficients);
   // Flip the plane normal
-  if (cos_theta < 0)
-  {
+  if (cos_theta < 0) {
     model_coefficients *= -1;
     model_coefficients[3] = 0;
     // Hessian form (D = nc . p_plane (centroid here) + p)
-    model_coefficients[3] = -1 * (model_coefficients.dot (table_hull->points[0].getVector4fMap ()));
+    model_coefficients[3] =
+        -1 * (model_coefficients.dot(table_hull->points[0].getVector4fMap()));
   }
 
-  //Set table_coeffs
+  // Set table_coeffs
   table_coeffs_ = model_coefficients;
 
   // ---[ Get the objects on top of the table
   pcl::PointIndices cloud_object_indices;
-  prism_.setInputCloud (cloud_filtered_);
-  prism_.setInputPlanarHull (table_hull);
-  prism_.segment (cloud_object_indices);
+  prism_.setInputCloud(cloud_filtered_);
+  prism_.setInputPlanarHull(table_hull);
+  prism_.segment(cloud_object_indices);
 
   pcl::ExtractIndices<PointType> extract_object_indices;
-  extract_object_indices.setInputCloud (cloud_downsampled_);
-  extract_object_indices.setIndices (boost::make_shared<const pcl::PointIndices> (cloud_object_indices));
-  extract_object_indices.filter (*cloud_objects_);
+  extract_object_indices.setInputCloud(cloud_downsampled_);
+  extract_object_indices.setIndices(
+      pcl::make_shared<const pcl::PointIndices>(cloud_object_indices));
+  extract_object_indices.filter(*cloud_objects_);
 
-  if (cloud_objects_->points.empty ())
+  if (cloud_objects_->points.empty())
     return;
 
   // ---[ Split the objects into Euclidean clusters
   std::vector<pcl::PointIndices> clusters2;
-  cluster_.setInputCloud (cloud_filtered_);
-  cluster_.setIndices (boost::make_shared<const pcl::PointIndices> (cloud_object_indices));
-  cluster_.extract (clusters2);
+  cluster_.setInputCloud(cloud_filtered_);
+  cluster_.setIndices(pcl::make_shared<const pcl::PointIndices>(cloud_object_indices));
+  cluster_.extract(clusters2);
 
-  PCL_INFO ("[DominantPlaneSegmentation::compute_full()] Number of clusters found matching the given constraints: %lu.\n",
-      clusters2.size ());
+  PCL_INFO("[DominantPlaneSegmentation::compute_full()] Number of clusters found "
+           "matching the given constraints: %lu.\n",
+           clusters2.size());
 
-  clusters.resize (clusters2.size ());
+  clusters.resize(clusters2.size());
 
-  for (std::size_t i = 0; i < clusters2.size (); ++i)
-  {
-    clusters[i] = CloudPtr (new Cloud ());
-    pcl::copyPointCloud (*cloud_filtered_, clusters2[i].indices, *clusters[i]);
+  for (std::size_t i = 0; i < clusters2.size(); ++i) {
+    clusters[i] = CloudPtr(new Cloud());
+    pcl::copyPointCloud(*cloud_filtered_, clusters2[i].indices, *clusters[i]);
   }
 }
 
-#define PCL_INSTANTIATE_DominantPlaneSegmentation(T) template class PCL_EXPORTS pcl::apps::DominantPlaneSegmentation<T>;
+#define PCL_INSTANTIATE_DominantPlaneSegmentation(T)                                   \
+  template class PCL_EXPORTS pcl::apps::DominantPlaneSegmentation<T>;
index 973886d7153ebcef2cae3822118f7deb187e61f1..aef724e26fa0108c3b95518f83bed0f35cadc22c 100644 (file)
@@ -1,15 +1,15 @@
 /*
  * Software License Agreement (BSD License)
- * 
+ *
  * Point Cloud Library (PCL) - www.pointclouds.org
  * Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
- * 
+ * are met:
+ *
  *  * Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above
@@ -19,7 +19,7 @@
  *  * Neither the name of the copyright holder(s) nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <ui_manual_registration.h>
-
-// QT
-#include <QMainWindow>
-#include <QMutex>
-#include <QTimer>
-
-// PCL
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
-
-#include <pcl/common/common.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/common.h>
 #include <pcl/common/time.h>
 #include <pcl/common/transforms.h>
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/io/pcd_io.h>
-
+#include <pcl/registration/transformation_estimation_svd.h>
 #include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/point_cloud_handlers.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
-#include <pcl/registration/transformation_estimation_svd.h>
+#include <QMainWindow>
+#include <QMutex>
+#include <QTimer>
+#include <ui_manual_registration.h>
 
 using PointT = pcl::PointXYZRGBA;
 
 // Useful macros
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
-
-namespace Ui
-{
-  class MainWindow;
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
+
+namespace Ui {
+class MainWindow;
 }
 
-class ManualRegistration : public QMainWindow
-{
+class ManualRegistration : public QMainWindow {
   Q_OBJECT
-  public:
-    using Cloud = pcl::PointCloud<PointT>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-    ManualRegistration ();
-
-    ~ManualRegistration ()
-    {
-    }
-
-    void
-    setSrcCloud (pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src)
-    {
-      cloud_src_ = std::move(cloud_src);
-      cloud_src_present_ = true;
-    }
-    void
-    setDstCloud (pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst)
-    {
-      cloud_dst_ = std::move(cloud_dst);
-      cloud_dst_present_ = true;
-    }
-
-    void
-    SourcePointPickCallback (const pcl::visualization::PointPickingEvent& event, void*);
-    void
-    DstPointPickCallback (const pcl::visualization::PointPickingEvent& event, void*);
-
-  protected:
-    pcl::visualization::PCLVisualizer::Ptr vis_src_;
-    pcl::visualization::PCLVisualizer::Ptr vis_dst_;
-
-    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src_;
-    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst_;
-
-    QMutex mtx_;
-    QMutex vis_mtx_;
-    Ui::MainWindow *ui_;
-    QTimer *vis_timer_;
-
-    bool                              cloud_src_present_;
-    bool                              cloud_src_modified_;
-    bool                              cloud_dst_present_;
-    bool                              cloud_dst_modified_;
-
-    bool                              src_point_selected_;
-    bool                              dst_point_selected_;
-
-    pcl::PointXYZ                     src_point_;
-    pcl::PointXYZ                     dst_point_;
-
-    pcl::PointCloud<pcl::PointXYZ>    src_pc_;
-    pcl::PointCloud<pcl::PointXYZ>    dst_pc_;
-
-    Eigen::Matrix4f                   transform_;
-
-  public Q_SLOTS:
-    void 
-    confirmSrcPointPressed();
-    void 
-    confirmDstPointPressed();
-    void 
-    calculatePressed();
-    void
-    clearPressed();
-    void 
-    orthoChanged(int state);
-    void 
-    applyTransformPressed();
-    void
-    refinePressed();
-    void
-    undoPressed();
-    void
-    safePressed();
-
-  private Q_SLOTS:
-    void
-    timeoutSlot();
-
+public:
+  using Cloud = pcl::PointCloud<PointT>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  ManualRegistration();
+
+  ~ManualRegistration() {}
+
+  void
+  setSrcCloud(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src)
+  {
+    cloud_src_ = std::move(cloud_src);
+    cloud_src_present_ = true;
+  }
+  void
+  setDstCloud(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst)
+  {
+    cloud_dst_ = std::move(cloud_dst);
+    cloud_dst_present_ = true;
+  }
+
+  void
+  SourcePointPickCallback(const pcl::visualization::PointPickingEvent& event, void*);
+  void
+  DstPointPickCallback(const pcl::visualization::PointPickingEvent& event, void*);
+
+protected:
+  pcl::visualization::PCLVisualizer::Ptr vis_src_;
+  pcl::visualization::PCLVisualizer::Ptr vis_dst_;
+
+  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src_;
+  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst_;
+
+  QMutex mtx_;
+  QMutex vis_mtx_;
+  Ui::MainWindow* ui_;
+  QTimer* vis_timer_;
+
+  bool cloud_src_present_;
+  bool cloud_src_modified_;
+  bool cloud_dst_present_;
+  bool cloud_dst_modified_;
+
+  bool src_point_selected_;
+  bool dst_point_selected_;
+
+  pcl::PointXYZ src_point_;
+  pcl::PointXYZ dst_point_;
+
+  pcl::PointCloud<pcl::PointXYZ> src_pc_;
+  pcl::PointCloud<pcl::PointXYZ> dst_pc_;
+
+  Eigen::Matrix4f transform_;
+
+public Q_SLOTS:
+  void
+  confirmSrcPointPressed();
+  void
+  confirmDstPointPressed();
+  void
+  calculatePressed();
+  void
+  clearPressed();
+  void
+  orthoChanged(int state);
+  void
+  applyTransformPressed();
+  void
+  refinePressed();
+  void
+  undoPressed();
+  void
+  safePressed();
+
+private Q_SLOTS:
+  void
+  timeoutSlot();
 };
index 827d8208497c16202ff7f17b5660ae45d5f57a75..d0836fcaba8427497bdc11cdfcd98dce579d5c09 100644 (file)
 
 #pragma once
 
-#include <cstdlib>
-#include <cfloat>
-#include <algorithm>
-#include <boost/foreach.hpp>
+#include <pcl/io/pcd_io.h>
+#include <pcl/kdtree/kdtree_flann.h>
 
-namespace pcl
-{
-  /**
-    * \brief Nearest neighbor search based classification of PCL point type features.
-    * FLANN is used to identify a neighborhood, based on which different scoring schemes
-    * can be employed to obtain likelihood values for a specified list of classes.
-    * \author Zoltan Csaba Marton
-    */
-  template <typename PointT>
-  class NNClassification
-  {
-    private:
+namespace pcl {
 
-      typename pcl::KdTree<PointT>::Ptr tree_;
+/**
+ * \brief Nearest neighbor search based classification of PCL point type features.
+ * FLANN is used to identify a neighborhood, based on which different scoring schemes
+ * can be employed to obtain likelihood values for a specified list of classes.
+ * \author Zoltan Csaba Marton
+ */
+template <typename PointT>
+class NNClassification {
+private:
+  typename pcl::KdTree<PointT>::Ptr tree_;
 
-      /** \brief List of class labels */
-      std::vector<std::string> classes_;
-      /** \brief The index in the class labels list for all the training examples */
-      std::vector<int> labels_idx_;
+  /** \brief List of class labels */
+  std::vector<std::string> classes_;
+  /** \brief The index in the class labels list for all the training examples */
+  std::vector<int> labels_idx_;
 
-    public:
+public:
+  NNClassification() : tree_() {}
 
-      NNClassification () : tree_ () {}
+  /** \brief Result is a list of class labels and scores */
+  using Result = std::pair<std::vector<std::string>, std::vector<float>>;
+  using ResultPtr = std::shared_ptr<Result>;
 
-      /** \brief Result is a list of class labels and scores */
-      using Result = std::pair<std::vector<std::string>, std::vector<float> >;
-      using ResultPtr = std::shared_ptr<Result>;
+  // TODO setIndices method, distance metrics and reset tree
 
-      // TODO setIndices method, distance metrics and reset tree
+  /**
+   * \brief Setting the training features.
+   * \param[in] features the training features
+   */
+  void
+  setTrainingFeatures(const typename pcl::PointCloud<PointT>::ConstPtr& features)
+  {
+    // Do not limit the number of dimensions used in the tree
+    typename pcl::CustomPointRepresentation<PointT>::Ptr cpr(
+        new pcl::CustomPointRepresentation<PointT>(INT_MAX, 0));
+    tree_.reset(new pcl::KdTreeFLANN<PointT>);
+    tree_->setPointRepresentation(cpr);
+    tree_->setInputCloud(features);
+  }
 
-      /** \brief Setting the training features.
-        * \param[in] features the training features
-        */
-      void 
-      setTrainingFeatures (const typename pcl::PointCloud<PointT>::ConstPtr &features)
-      {
-        // Do not limit the number of dimensions used in the tree
-        typename pcl::CustomPointRepresentation<PointT>::Ptr cpr (new pcl::CustomPointRepresentation<PointT> (INT_MAX, 0));
-        tree_.reset (new pcl::KdTreeFLANN<PointT>);
-        tree_->setPointRepresentation (cpr);
-        tree_->setInputCloud (features);
-      }
+  /**
+   * \brief Updating the labels for each training example.
+   * \param classes the class labels
+   * \param labels_idx the index in the class labels list for each training example
+   */
+  void
+  setTrainingLabelIndicesAndLUT(const std::vector<std::string>& classes,
+                                const std::vector<int>& labels_idx)
+  {
+    // TODO check if min/max index is inside classes?
+    classes_ = classes;
+    labels_idx_ = labels_idx;
+  }
 
-      /** \brief Updating the labels for each training example.
-        * \param classes the class labels
-        * \param labels_idx the index in the class labels list for each training example
-        */
-      void 
-      setTrainingLabelIndicesAndLUT (const std::vector<std::string> &classes, const std::vector<int> &labels_idx)
-      {
-        // TODO check if min/max index is inside classes?
-        classes_ = classes;
-        labels_idx_ = labels_idx;
-      }
+  /**
+   * \brief Setting the labels for each training example.
+   * The unique labels from the list are stored as the class labels, and
+   * for each training example an index pointing to these labels is stored.
+   * \note See the setTrainingLabelIndicesAndLUT method for easily re-labeling.
+   * \param labels the class label for each training example
+   */
+  void
+  setTrainingLabels(const std::vector<std::string>& labels)
+  {
+    // Create a list of unique labels
+    classes_ = labels;
+    std::sort(classes_.begin(), classes_.end());
+    classes_.erase(std::unique(classes_.begin(), classes_.end()), classes_.end());
 
-      /** \brief Setting the labels for each training example.
-        * The unique labels from the list are stored as the class labels, and
-        * for each training example an index pointing to these labels is stored.
-        * \note See the setTrainingLabelIndicesAndLUT method for easily re-labeling.
-        * \param labels the class label for each training example
-        */
-      void 
-      setTrainingLabels (const std::vector<std::string> &labels)
-      {
-        // Create a list of unique labels
-        classes_ = labels;
-        std::sort (classes_.begin(), classes_.end());
-        classes_.erase (std::unique (classes_.begin(), classes_.end()), classes_.end());
+    // Save the mapping from labels to indices in the class list
+    std::map<std::string, int> label2idx;
+    for (std::size_t i = 0; i < classes_.size(); ++i) {
+      label2idx[classes_[i]] = i;
+    }
 
-        // Save the mapping from labels to indices in the class list
-        std::map<std::string, int> label2idx;
-        for (std::size_t i = 0; i < classes_.size(); ++i)
-        {
-            label2idx[classes_[i]] = i;
-        }
+    // Create a list holding the class index of each label
+    labels_idx_.reserve(labels.size());
+    for (const auto& s : labels) {
+      labels_idx_.push_back(label2idx[s]);
+    }
+  }
 
-        // Create a list holding the class index of each label
-        labels_idx_.reserve (labels.size ());
-        for (const auto &s : labels)
-        {
-          labels_idx_.push_back (label2idx[s]);
-        }
-      }
+  /**
+   * \brief Load the list of training examples and corresponding labels.
+   * \param file_name PCD file containing the training features
+   * \param labels_file_name the class label for each training example
+   * \return true on success, false on failure (read error or number of entries don't
+   * match)
+   */
+  bool
+  loadTrainingFeatures(const std::string& file_name,
+                       const std::string& labels_file_name)
+  {
+    typename pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>);
+    if (pcl::io::loadPCDFile(file_name, *cloud) != 0)
+      return false;
+    std::vector<std::string> labels;
+    std::ifstream f(labels_file_name.c_str());
+    std::string label;
+    while (getline(f, label))
+      if (!label.empty())
+        labels.push_back(label);
+    if (labels.size() != cloud->points.size())
+      return false;
+    setTrainingFeatures(cloud);
+    setTrainingLabels(labels);
+    return true;
+  }
 
-      /** \brief Load the list of training examples and corresponding labels.
-        * \param file_name PCD file containing the training features
-        * \param labels_file_name the class label for each training example
-        * \return true on success, false on failure (read error or number of entries don't match)
-        */
-      bool 
-      loadTrainingFeatures(const std::string& file_name, const std::string& labels_file_name)
-      {
-        typename pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>);
-        if (pcl::io::loadPCDFile (file_name, *cloud) != 0)
-          return (false);
-        std::vector<std::string> labels;
-        std::ifstream f (labels_file_name.c_str ());
-        std::string label;
-        while (getline (f, label))
-          if (!label.empty ())
-            labels.push_back(label);
-        if (labels.size () != cloud->points.size ())
-          return (false);
-        setTrainingFeatures (cloud);
-        setTrainingLabels (labels);
-        return (true);
+  /**
+   * \brief Save the list of training examples and corresponding labels.
+   * \param file_name file name for writing the training features
+   * \param labels_file_name file name for writing the class label for each
+   * training example
+   * \return true on success, false on failure (write error or number of entries
+   * don't match)
+   */
+  bool
+  saveTrainingFeatures(const std::string& file_name,
+                       const std::string& labels_file_name)
+  {
+    typename pcl::PointCloud<PointT>::ConstPtr training_features =
+        tree_->getInputCloud();
+    if (labels_idx_.size() == training_features->points.size()) {
+      if (pcl::io::savePCDFile(file_name.c_str(), *training_features) != 0)
+        return false;
+      std::ofstream f(labels_file_name.c_str());
+      for (const int& i : labels_idx_) {
+        f << classes_[i] << "\n";
       }
+      return true;
+    }
+    return false;
+  }
 
-      /** \brief Save the list of training examples and corresponding labels.
-        * \param file_name file name for writing the training features
-        * \param labels_file_name file name for writing the class label for each training example
-        * \return true on success, false on failure (write error or number of entries don't match)
-        */
-      bool 
-      saveTrainingFeatures (const std::string& file_name, const std::string& labels_file_name)
-      {
-        typename pcl::PointCloud<PointT>::ConstPtr training_features = tree_->getInputCloud ();
-        if (labels_idx_.size () == training_features->points.size ())
-        {
-          if (pcl::io::savePCDFile (file_name.c_str (), *training_features) != 0)
-            return (false);
-          std::ofstream f (labels_file_name.c_str ());
-          for (const int& i : labels_idx_)
-          {
-            f << classes_[i] << "\n";
-          }
-          return (true);
-        }
-        return (false);
-      }
+  /**
+   * \brief Utility function for the default classification process.
+   * \param p_q the given query point
+   * \param radius the radius of the sphere bounding all of p_q's neighbors
+   * \param gaussian_param influences the width of the Gaussian by specifying where
+   * the 36.78 score should be: score = exp(-distance/gaussian_param)
+   * \param max_nn if given, bounds the maximum returned neighbors to this value
+   * \return pair of label and score for each training class from the neighborhood
+   */
+  ResultPtr
+  classify(const PointT& p_q, double radius, float gaussian_param, int max_nn = INT_MAX)
+  {
+    std::vector<int> k_indices;
+    std::vector<float> k_sqr_distances;
+    getSimilarExemplars(p_q, radius, k_indices, k_sqr_distances, max_nn);
+    return getGaussianBestScores(gaussian_param, k_indices, k_sqr_distances);
+  }
 
-      /** \brief Utility function for the default classification process.
-        * \param p_q the given query point
-        * \param radius the radius of the sphere bounding all of p_q's neighbors
-        * \param gaussian_param influences the width of the Gaussian by specifying where the 36.78 score should be: score = exp(-distance/gaussian_param)
-        * \param max_nn if given, bounds the maximum returned neighbors to this value
-        * \return pair of label and score for each training class from the neighborhood
-        */
-      ResultPtr 
-      classify (const PointT &p_q, double radius, float gaussian_param, int max_nn = INT_MAX)
-      {
-        std::vector<int> k_indices;
-        std::vector<float> k_sqr_distances;
-        getSimilarExemplars (p_q, radius, k_indices, k_sqr_distances, max_nn);
-        return (getGaussianBestScores (gaussian_param, k_indices, k_sqr_distances));
-      }
+  /**
+   * \brief Search for k-nearest neighbors for the given query point.
+   * \param p_q the given query point
+   * \param k the number of neighbors to search for
+   * \param k_indices the resultant indices of the neighboring points
+   * (does not have to be resized to \a k a priori!)
+   * \param k_sqr_distances the resultant squared distances to the neighboring points
+   * (does not have to be resized to \a k a priori!)
+   * \return number of neighbors found
+   */
+  int
+  getKNearestExemplars(const PointT& p_q,
+                       int k,
+                       std::vector<int>& k_indices,
+                       std::vector<float>& k_sqr_distances)
+  {
+    k_indices.resize(k);
+    k_sqr_distances.resize(k);
+    return tree_->nearestKSearch(p_q, k, k_indices, k_sqr_distances);
+  }
 
-      /** \brief Search for k-nearest neighbors for the given query point.
-        * \param p_q the given query point
-        * \param k the number of neighbors to search for
-        * \param k_indices the resultant indices of the neighboring points (does not have to be resized to \a k a priori!)
-        * \param k_sqr_distances the resultant squared distances to the neighboring points (does not have be resized to \a k
-        * a priori!)
-        * \return number of neighbors found
-        */
-      int 
-      getKNearestExemplars (const PointT &p_q, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
-      {
-        k_indices.resize (k);
-        k_sqr_distances.resize (k);
-        return (tree_->nearestKSearch (p_q, k, k_indices, k_sqr_distances));
-      }
+  /**
+   * \brief Search for all the nearest neighbors of the query point in a given radius.
+   * \param p_q the given query point
+   * \param radius the radius of the sphere bounding all of p_q's neighbors
+   * \param k_indices the resultant indices of the neighboring points
+   * \param k_sqr_distances the resultant squared distances to the neighboring points
+   * \param max_nn if given, bounds the maximum returned neighbors to this value
+   * \return number of neighbors found in radius
+   */
+  int
+  getSimilarExemplars(const PointT& p_q,
+                      double radius,
+                      std::vector<int>& k_indices,
+                      std::vector<float>& k_sqr_distances,
+                      int max_nn = INT_MAX)
+  {
+    return tree_->radiusSearch(p_q, radius, k_indices, k_sqr_distances, max_nn);
+  }
 
-      /** \brief Search for all the nearest neighbors of the query point in a given radius.
-        * \param p_q the given query point
-        * \param radius the radius of the sphere bounding all of p_q's neighbors
-        * \param k_indices the resultant indices of the neighboring points
-        * \param k_sqr_distances the resultant squared distances to the neighboring points
-        * \param max_nn if given, bounds the maximum returned neighbors to this value
-        * \return number of neighbors found in radius
-        */
-      int 
-      getSimilarExemplars (const PointT &p_q, double radius, std::vector<int> &k_indices,
-                           std::vector<float> &k_sqr_distances, int max_nn = INT_MAX)
-      {
-        return (tree_->radiusSearch (p_q, radius, k_indices, k_sqr_distances, max_nn));
-      }
+  /**
+   * \brief Gets the smallest square distance to each class given a neighborhood.
+   * \param k_indices the resultant indices of the neighboring points
+   * \param k_sqr_distances the resultant squared distances to the neighboring points
+   * \return a square distance to each training class
+   */
+  std::shared_ptr<std::vector<float>>
+  getSmallestSquaredDistances(std::vector<int>& k_indices,
+                              std::vector<float>& k_sqr_distances)
+  {
+    // Reserve space for distances
+    auto sqr_distances = std::make_shared<std::vector<float>>(classes_.size(), FLT_MAX);
+
+    // Select square distance to each class
+    for (std::vector<int>::const_iterator i = k_indices.begin(); i != k_indices.end();
+         ++i)
+      if ((*sqr_distances)[labels_idx_[*i]] > k_sqr_distances[i - k_indices.begin()])
+        (*sqr_distances)[labels_idx_[*i]] = k_sqr_distances[i - k_indices.begin()];
+    return sqr_distances;
+  }
 
-      /** \brief Gets the smallest square distance to each class given a neighborhood.
-        * \param k_indices the resultant indices of the neighboring points
-        * \param k_sqr_distances the resultant squared distances to the neighboring points
-        * \return a square distance to each training class
-        */
-      std::shared_ptr<std::vector<float>>
-      getSmallestSquaredDistances (std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
-      {
-        // Reserve space for distances
-        auto sqr_distances  = std::make_shared<std::vector<float>> (classes_.size (), FLT_MAX);
+  /**
+   * \brief Computes a score that is inversely proportional to the distance to each
+   * class given a neighborhood.
+   * \note Scores will sum up to one.
+   * \param k_indices the resultant indices of the neighboring points
+   * \param k_sqr_distances the resultant squared distances to the neighboring points
+   * \return pair of label and score for each training class from the neighborhood
+   */
+  ResultPtr
+  getLinearBestScores(std::vector<int>& k_indices, std::vector<float>& k_sqr_distances)
+  {
+    // Get smallest squared distances and transform them to a score for each class
+    auto sqr_distances = getSmallestSquaredDistances(k_indices, k_sqr_distances);
 
-        // Select square distance to each class
-        for (std::vector<int>::const_iterator i = k_indices.begin (); i != k_indices.end (); ++i)
-          if ((*sqr_distances)[labels_idx_[*i]] > k_sqr_distances[i - k_indices.begin ()])
-            (*sqr_distances)[labels_idx_[*i]] = k_sqr_distances[i - k_indices.begin ()];
-        return (sqr_distances);
+    // Transform distances to scores
+    double sum_dist = 0;
+    auto result =
+        std::make_shared<std::pair<std::vector<std::string>, std::vector<float>>>();
+    result->first.reserve(classes_.size());
+    result->second.reserve(classes_.size());
+    for (std::vector<float>::const_iterator it = sqr_distances->begin();
+         it != sqr_distances->end();
+         ++it)
+      if (*it != FLT_MAX) {
+        result->first.push_back(classes_[it - sqr_distances->begin()]);
+        result->second.push_back(sqrt(*it));
+        sum_dist += result->second.back();
       }
+    for (float& it : result->second)
+      it = 1 - it / sum_dist;
 
-      /** \brief Computes a score that is inversely proportional to the distance to each class given a neighborhood.
-        * \note Scores will sum up to one.
-        * \param k_indices the resultant indices of the neighboring points
-        * \param k_sqr_distances the resultant squared distances to the neighboring points
-        * \return pair of label and score for each training class from the neighborhood
-        */
-      ResultPtr 
-      getLinearBestScores (std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
-      {
-        // Get smallest squared distances and transform them to a score for each class
-        auto sqr_distances = getSmallestSquaredDistances (k_indices, k_sqr_distances);
+    // Return label/score list pair
+    return result;
+  }
 
-        // Transform distances to scores
-        double sum_dist = 0;
-        auto result = std::make_shared<std::pair<std::vector<std::string>, std::vector<float>>> ();
-        result->first.reserve (classes_.size ());
-        result->second.reserve (classes_.size ());
-        for (std::vector<float>::const_iterator it = sqr_distances->begin (); it != sqr_distances->end (); ++it)
-          if (*it != FLT_MAX)
-          {
-            result->first.push_back (classes_[it - sqr_distances->begin ()]);
-            result->second.push_back (sqrt (*it));
-            sum_dist += result->second.back ();
-          }
-        for (float &it : result->second)
-          it = 1 - it/sum_dist;
+  /**
+   * \brief Computes a score exponentially decreasing with the distance for each class
+   * given a neighborhood.
+   * \param[in] gaussian_param influences the width of the Gaussian:
+   * score = exp(-distance/gaussioan_param)
+   * \param[out] k_indices the resultant indices of the neighboring points
+   * \param[out] k_sqr_distances the resultant squared distances to the
+   * neighboring points
+   * \return pair of label and score for each training class from the neighborhood
+   */
+  ResultPtr
+  getGaussianBestScores(float gaussian_param,
+                        std::vector<int>& k_indices,
+                        std::vector<float>& k_sqr_distances)
+  {
+    // Get smallest squared distances and transform them to a score for each class
+    auto sqr_distances = getSmallestSquaredDistances(k_indices, k_sqr_distances);
 
-        // Return label/score list pair
-        return (result);
+    // Transform distances to scores
+    auto result =
+        std::make_shared<std::pair<std::vector<std::string>, std::vector<float>>>();
+    result->first.reserve(classes_.size());
+    result->second.reserve(classes_.size());
+    for (std::vector<float>::const_iterator it = sqr_distances->begin();
+         it != sqr_distances->end();
+         ++it)
+      if (*it != FLT_MAX) {
+        result->first.push_back(classes_[it - sqr_distances->begin()]);
+        // TODO leave it squared, and relate param to sigma...
+        result->second.push_back(std::exp(-std::sqrt(*it) / gaussian_param));
       }
 
-      /** \brief Computes a score exponentially decreasing with the distance for each class given a neighborhood.
-        * \param[in] gaussian_param influences the width of the Gaussian: score = exp(-distance/gaussioan_param)
-        * \param[out] k_indices the resultant indices of the neighboring points
-        * \param[out] k_sqr_distances the resultant squared distances to the neighboring points
-        * \return pair of label and score for each training class from the neighborhood
-        */
-      ResultPtr 
-      getGaussianBestScores (float gaussian_param, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
-      {
-        // Get smallest squared distances and transform them to a score for each class
-        auto sqr_distances = getSmallestSquaredDistances (k_indices, k_sqr_distances);
+    // Return label/score list pair
+    return result;
+  }
+};
 
-        // Transform distances to scores
-        auto result = std::make_shared<std::pair<std::vector<std::string>, std::vector<float>>> ();
-        result->first.reserve (classes_.size ());
-        result->second.reserve (classes_.size ());
-        for (std::vector<float>::const_iterator it = sqr_distances->begin (); it != sqr_distances->end (); ++it)
-          if (*it != FLT_MAX)
-          {
-            result->first.push_back (classes_[it - sqr_distances->begin ()]);
-            // TODO leave it squared, and relate param to sigma...
-            result->second.push_back (std::exp (-std::sqrt (*it) / gaussian_param));
-          }
-
-        // Return label/score list pair
-        return (result);
-      }
-  };
-}
+} // namespace pcl
index 5bf7b2faa906a9c2973066e979f009d89687026a..d264865b5599a6272148cee89e0a7faea7509459 100644 (file)
 
 #pragma once
 
-// PCL
 #include <pcl/apps/openni_passthrough_qt.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
 #include <pcl/common/time.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/filters/passthrough.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 // Useful macros
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
-namespace Ui
-{
-  class MainWindow;
+namespace Ui {
+class MainWindow;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class OpenNIPassthrough : public QMainWindow
-{
+class OpenNIPassthrough : public QMainWindow {
   Q_OBJECT
-  public:
-    using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
+public:
+  using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  OpenNIPassthrough(pcl::OpenNIGrabber& grabber);
+
+  ~OpenNIPassthrough()
+  {
+    if (grabber_.isRunning())
+      grabber_.stop();
+  }
+
+  void
+  cloud_cb(const CloudConstPtr& cloud);
 
-    OpenNIPassthrough (pcl::OpenNIGrabber& grabber);
+protected:
+  pcl::visualization::PCLVisualizer::Ptr vis_;
+  pcl::OpenNIGrabber& grabber_;
+  std::string device_id_;
+  CloudPtr cloud_pass_;
+  pcl::PassThrough<pcl::PointXYZRGBA> pass_;
 
-    ~OpenNIPassthrough ()
-    {
-      if (grabber_.isRunning ())
-        grabber_.stop ();
-    }
-    
-    void
-    cloud_cb (const CloudConstPtr& cloud);
+private:
+  QMutex mtx_;
+  Ui::MainWindow* ui_;
+  QTimer* vis_timer_;
 
-  protected:
-    pcl::visualization::PCLVisualizer::Ptr vis_;
-    pcl::OpenNIGrabber& grabber_;
-    std::string device_id_;
-    CloudPtr cloud_pass_;
-    pcl::PassThrough<pcl::PointXYZRGBA> pass_;
+public Q_SLOTS:
+  void
+  adjustPassThroughValues(int new_value)
+  {
+    pass_.setFilterLimits(0.0f, float(new_value) / 10.0f);
+    PCL_INFO("Changed passthrough maximum value to: %f\n", float(new_value) / 10.0f);
+  }
 
-  private:
-    QMutex mtx_;
-    Ui::MainWindow *ui_;
-    QTimer *vis_timer_;
+private Q_SLOTS:
+  void
+  timeoutSlot();
 
-  public Q_SLOTS:
-    void
-    adjustPassThroughValues (int new_value)
-    {
-      pass_.setFilterLimits (0.0f, float (new_value) / 10.0f);
-      PCL_INFO ("Changed passthrough maximum value to: %f\n", float (new_value) / 10.0f);
-    }
-    
-  private Q_SLOTS:
-    void
-    timeoutSlot ();
-    
-  Q_SIGNALS:
-    void 
-    valueChanged (int new_value);
+Q_SIGNALS:
+  void
+  valueChanged(int new_value);
 };
index cdb8f010bb167a1c1fa2866eac80219afbf3238d..a4923198fdcfe1b13cd9e5ac778e1a7e9be014e6 100644 (file)
@@ -41,9 +41,8 @@
 #pragma GCC system_header
 #endif
 
-#include <ui_openni_passthrough.h>
-// QT4
 #include <QMainWindow>
 #include <QMutex>
-#include <QTimer>
 #include <QObject>
+#include <QTimer>
+#include <ui_openni_passthrough.h>
index 95e6935e9cbbf154b3b7e2e27314ed9c3b85af3d..f8b660d90ee6961142c26a51ce859136bcc6182f 100644 (file)
 #pragma once
 
 #include <pcl/apps/organized_segmentation_demo_qt.h>
-
-// PCL
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
+#include <pcl/common/time.h>
+#include <pcl/common/transforms.h>
+#include <pcl/features/integral_image_normal.h>
+#include <pcl/filters/voxel_grid.h>
 #include <pcl/io/oni_grabber.h>
+#include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/common/time.h>
-#include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/features/integral_image_normal.h>
+#include <pcl/segmentation/edge_aware_plane_comparator.h>
+#include <pcl/segmentation/euclidean_cluster_comparator.h>
+#include <pcl/segmentation/euclidean_plane_coefficient_comparator.h>
+#include <pcl/segmentation/organized_connected_component_segmentation.h>
 #include <pcl/segmentation/organized_multi_plane_segmentation.h>
 #include <pcl/segmentation/planar_polygon_fusion.h>
-#include <pcl/common/transforms.h>
 #include <pcl/segmentation/plane_coefficient_comparator.h>
-#include <pcl/segmentation/euclidean_plane_coefficient_comparator.h>
 #include <pcl/segmentation/rgb_plane_coefficient_comparator.h>
-#include <pcl/segmentation/edge_aware_plane_comparator.h>
-#include <pcl/segmentation/euclidean_cluster_comparator.h>
-#include <pcl/segmentation/organized_connected_component_segmentation.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 using PointT = pcl::PointXYZRGBA;
 
 // Useful macros
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
-
-namespace Ui
-{
-  class MainWindow;
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
+
+namespace Ui {
+class MainWindow;
 }
 
-class OrganizedSegmentationDemo : public QMainWindow
-{
+class OrganizedSegmentationDemo : public QMainWindow {
   Q_OBJECT
-  public:
-    using Cloud = pcl::PointCloud<PointT>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-
-    OrganizedSegmentationDemo(pcl::Grabber& grabber);
-
-    ~OrganizedSegmentationDemo ()
-    {
-      if(grabber_.isRunning())
-        grabber_.stop();
-    }
-
-    void cloud_cb (const CloudConstPtr& cloud);
-
-  protected:
-    pcl::visualization::PCLVisualizer::Ptr vis_;
-    pcl::Grabber& grabber_;
-
-    QMutex mtx_;
-    QMutex vis_mtx_;
-    Ui::MainWindow *ui_;
-    QTimer *vis_timer_;
-    pcl::PointCloud<PointT> prev_cloud_;
-    pcl::PointCloud<pcl::Normal> prev_normals_;
-    std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > prev_regions_;
-    float* prev_distance_map_;
-
-    pcl::PointCloud<PointT>::CloudVectorType prev_clusters_;
-
-    pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
-    pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
-
-    bool capture_;
-    bool data_modified_;
-    std::size_t previous_data_size_;
-    std::size_t previous_clusters_size_;
-
-    bool display_normals_;
-    bool display_curvature_;
-    bool display_distance_map_;
-
-    bool use_planar_refinement_;
-    bool use_clustering_;
-
-    pcl::PlaneCoefficientComparator<PointT, pcl::Normal>::Ptr plane_comparator_;
-    pcl::EuclideanPlaneCoefficientComparator<PointT, pcl::Normal>::Ptr euclidean_comparator_;
-    pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal>::Ptr rgb_comparator_;
-    pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal> rgb_comp_;
-    pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal>::Ptr edge_aware_comparator_;
-    pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr euclidean_cluster_comparator_;
-
-  public Q_SLOTS:
-    void toggleCapturePressed()
-    {
-      capture_ = !capture_;
-    }
-
-    void usePlaneComparatorPressed ();
-    void useEuclideanComparatorPressed ();
-    void useRGBComparatorPressed ();
-    void useEdgeAwareComparatorPressed ();
-
-    void displayCurvaturePressed ();
-    void displayDistanceMapPressed ();
-    void displayNormalsPressed ();
-
-    void disableRefinementPressed ()
-    {
-      use_planar_refinement_ = false;
-    }
-
-    void usePlanarRefinementPressed ()
-    {
-      use_planar_refinement_ = true;
-    }
-
-    void disableClusteringPressed ()
-    {
-      use_clustering_ = false;
-    }
-
-    void useEuclideanClusteringPressed ()
-    {
-      use_clustering_ = true;
-    }
-
-
-  private Q_SLOTS:
+public:
+  using Cloud = pcl::PointCloud<PointT>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  OrganizedSegmentationDemo(pcl::Grabber& grabber);
+
+  ~OrganizedSegmentationDemo()
+  {
+    if (grabber_.isRunning())
+      grabber_.stop();
+  }
+
+  void
+  cloud_cb(const CloudConstPtr& cloud);
+
+protected:
+  pcl::visualization::PCLVisualizer::Ptr vis_;
+  pcl::Grabber& grabber_;
+
+  QMutex mtx_;
+  QMutex vis_mtx_;
+  Ui::MainWindow* ui_;
+  QTimer* vis_timer_;
+  pcl::PointCloud<PointT> prev_cloud_;
+  pcl::PointCloud<pcl::Normal> prev_normals_;
+  std::vector<pcl::PlanarRegion<PointT>,
+              Eigen::aligned_allocator<pcl::PlanarRegion<PointT>>>
+      prev_regions_;
+  float* prev_distance_map_;
+
+  pcl::PointCloud<PointT>::CloudVectorType prev_clusters_;
+
+  pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
+  pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
+
+  bool capture_;
+  bool data_modified_;
+  std::size_t previous_data_size_;
+  std::size_t previous_clusters_size_;
+
+  bool display_normals_;
+  bool display_curvature_;
+  bool display_distance_map_;
+
+  bool use_planar_refinement_;
+  bool use_clustering_;
+
+  pcl::PlaneCoefficientComparator<PointT, pcl::Normal>::Ptr plane_comparator_;
+  pcl::EuclideanPlaneCoefficientComparator<PointT, pcl::Normal>::Ptr
+      euclidean_comparator_;
+  pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal>::Ptr rgb_comparator_;
+  pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal> rgb_comp_;
+  pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal>::Ptr edge_aware_comparator_;
+  pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr
+      euclidean_cluster_comparator_;
+
+public Q_SLOTS:
+  void
+  toggleCapturePressed()
+  {
+    capture_ = !capture_;
+  }
+
+  void
+  usePlaneComparatorPressed();
+  void
+  useEuclideanComparatorPressed();
   void
-    timeoutSlot();
+  useRGBComparatorPressed();
+  void
+  useEdgeAwareComparatorPressed();
 
+  void
+  displayCurvaturePressed();
+  void
+  displayDistanceMapPressed();
+  void
+  displayNormalsPressed();
+
+  void
+  disableRefinementPressed()
+  {
+    use_planar_refinement_ = false;
+  }
+
+  void
+  usePlanarRefinementPressed()
+  {
+    use_planar_refinement_ = true;
+  }
+
+  void
+  disableClusteringPressed()
+  {
+    use_clustering_ = false;
+  }
+
+  void
+  useEuclideanClusteringPressed()
+  {
+    use_clustering_ = true;
+  }
+
+private Q_SLOTS:
+  void
+  timeoutSlot();
 };
index 218ad679c0dfd3de2d4bc10354f1dbbde9e3ea97..5a5cb0f951daaced6e803c88c669bd4f6dc655b7 100644 (file)
@@ -1,15 +1,15 @@
 /*
  * Software License Agreement (BSD License)
- * 
+ *
  * Point Cloud Library (PCL) - www.pointclouds.org
  * Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
- * 
+ * are met:
+ *
  *  * Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above
@@ -19,7 +19,7 @@
  *  * Neither the name of the copyright holder(s) nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -40,8 +40,7 @@
 #pragma GCC system_header
 #endif
 
-#include <ui_organized_segmentation_demo.h>
-// QT4
 #include <QMainWindow>
 #include <QMutex>
 #include <QTimer>
+#include <ui_organized_segmentation_demo.h>
index a8c3d17e4aa57833d19d47dd7cd0e720545b0165..46a63ef31a6e3db55c16969f11c5e86970c4e5ec 100644 (file)
@@ -1,15 +1,15 @@
 /*
  * Software License Agreement (BSD License)
- * 
+ *
  * Point Cloud Library (PCL) - www.pointclouds.org
  * Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
- * 
+ * are met:
+ *
  *  * Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above
@@ -19,7 +19,7 @@
  *  * Neither the name of the copyright holder(s) nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <ui_pcd_video_player.h>
-
-#include <iostream>
-#include <ctime>
-
-// QT4
-#include <QMainWindow>
-#include <QMutex>
-#include <QTimer>
-
-// Boost
-#include <boost/filesystem.hpp>
-
-// PCL
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
-
-#include <pcl/common/common.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/common.h>
 #include <pcl/common/time.h>
 #include <pcl/common/transforms.h>
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/io/pcd_io.h>
-
+#include <pcl/registration/transformation_estimation_svd.h>
 #include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/point_cloud_handlers.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
-#include <pcl/registration/transformation_estimation_svd.h>
+#include <boost/filesystem.hpp>
+
+#include <QMainWindow>
+#include <QMutex>
+#include <QTimer>
+#include <ui_pcd_video_player.h>
+
+#include <ctime>
+#include <iostream>
 
 #define CURRENT_VERSION 0.2
 
 // Useful macros
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
-
-namespace Ui
-{
-  class MainWindow;
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
+
+namespace Ui {
+class MainWindow;
 }
 
-class PCDVideoPlayer : public QMainWindow
-{
+class PCDVideoPlayer : public QMainWindow {
   Q_OBJECT
-  public:
-    using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-    PCDVideoPlayer ();
-
-    ~PCDVideoPlayer () {}
-
-  protected:
-    pcl::visualization::PCLVisualizer::Ptr vis_;
-    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_;
-
-    QMutex mtx_;
-    QMutex vis_mtx_;
-    Ui::MainWindow *ui_;
-    QTimer *vis_timer_;
-
-    QString dir_;
-
-    std::vector<std::string> pcd_files_;
-    std::vector<boost::filesystem::path> pcd_paths_;
-
-
-    /** \brief The current displayed frame */
-    unsigned int current_frame_;
-    /** \brief Store the number of loaded frames */
-    unsigned int nr_of_frames_;
-
-    /** \brief Indicate that pointclouds were loaded */
-    bool cloud_present_;
-    /** \brief Indicate that the timeoutSlot needs to reload the pointcloud */
-    bool cloud_modified_;
-
-    /** \brief Indicate that files should play continuously */
-    bool play_mode_;
-    /** \brief In play mode only update if speed_counter_ == speed_value */
-    unsigned int speed_counter_;
-    /** \brief Fixes the speed in steps of 5ms, default 5, gives 5+1 * 5ms = 30ms = 33,3 Hz playback speed */
-    unsigned int speed_value_;
-
-  public Q_SLOTS:
-    void 
-    playButtonPressed ()
-    { play_mode_ = true; }
-
-    void 
-    stopButtonPressed()
-    { play_mode_ = false; }
-
-    void
-    backButtonPressed ();
-
-    void
-    nextButtonPressed ();
-
-    void
-    selectFolderButtonPressed ();
-
-    void
-    selectFilesButtonPressed ();
-
-    void
-    indexSliderValueChanged (int value);
-
-  private Q_SLOTS:
-    void
-    timeoutSlot ();
-
+public:
+  using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  PCDVideoPlayer();
+
+  ~PCDVideoPlayer() {}
+
+protected:
+  pcl::visualization::PCLVisualizer::Ptr vis_;
+  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_;
+
+  QMutex mtx_;
+  QMutex vis_mtx_;
+  Ui::MainWindow* ui_;
+  QTimer* vis_timer_;
+
+  QString dir_;
+
+  std::vector<std::string> pcd_files_;
+  std::vector<boost::filesystem::path> pcd_paths_;
+
+  /** \brief The current displayed frame */
+  unsigned int current_frame_;
+  /** \brief Store the number of loaded frames */
+  unsigned int nr_of_frames_;
+
+  /** \brief Indicate that pointclouds were loaded */
+  bool cloud_present_;
+  /** \brief Indicate that the timeoutSlot needs to reload the pointcloud */
+  bool cloud_modified_;
+
+  /** \brief Indicate that files should play continuously */
+  bool play_mode_;
+  /** \brief In play mode only update if speed_counter_ == speed_value */
+  unsigned int speed_counter_;
+  /**
+   * \brief Fixes the speed in steps of 5ms, default 5, gives 5+1 * 5ms = 30ms = 33,3
+   * Hz playback speed
+   */
+  unsigned int speed_value_;
+
+public Q_SLOTS:
+  void
+  playButtonPressed()
+  {
+    play_mode_ = true;
+  }
+
+  void
+  stopButtonPressed()
+  {
+    play_mode_ = false;
+  }
+
+  void
+  backButtonPressed();
+
+  void
+  nextButtonPressed();
+
+  void
+  selectFolderButtonPressed();
+
+  void
+  selectFilesButtonPressed();
+
+  void
+  indexSliderValueChanged(int value);
+
+private Q_SLOTS:
+  void
+  timeoutSlot();
 };
index 4d0376af935db2386e8403bc2a31428801dc8d88..c61f39f2b1f805045872b6b80c8202c5c9a12477 100644 (file)
 
 #include <pcl/common/common.h>
 
-#include <vtkSmartPointer.h>
 #include <vtkPolyData.h>
+#include <vtkSmartPointer.h>
 
 #include <functional>
 
-namespace pcl
-{
-  namespace apps
-  {
-    /** \brief @b Class to render synthetic views of a 3D mesh using a tessellated sphere
-     * NOTE: This class should replace renderViewTesselatedSphere from pcl::visualization.
-     * Some extensions are planned in the near future to this class like removal of duplicated views for
-     * symmetrical objects, generation of RGB synthetic clouds when RGB available on mesh, etc.
-     * \author Aitor Aldoma
-     * \ingroup apps
-     */
-    class PCL_EXPORTS RenderViewsTesselatedSphere
+namespace pcl {
+namespace apps {
+
+/**
+ * \brief @b Class to render synthetic views of a 3D mesh using a tessellated sphere
+ * NOTE: This class should replace renderViewTesselatedSphere from pcl::visualization.
+ * Some extensions are planned in the near future to this class like removal of
+ * duplicated views for symmetrical objects, generation of RGB synthetic clouds when RGB
+ * available on mesh, etc.
+ * \author Aitor Aldoma
+ * \ingroup apps
+ */
+class PCL_EXPORTS RenderViewsTesselatedSphere {
+private:
+  std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f>> poses_;
+  std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> generated_views_;
+  std::vector<float> entropies_;
+  int resolution_;
+  int tesselation_level_;
+  bool use_vertices_;
+  float view_angle_;
+  float radius_sphere_;
+  bool compute_entropy_;
+  vtkSmartPointer<vtkPolyData> polydata_;
+  bool gen_organized_;
+  std::function<bool(const Eigen::Vector3f&)> campos_constraints_func_;
+
+  struct camPosConstraintsAllTrue {
+    bool
+    operator()(const Eigen::Vector3f& /*pos*/) const
     {
-    private:
-      std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > poses_;
-      std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> generated_views_;
-      std::vector<float> entropies_;
-      int resolution_;
-      int tesselation_level_;
-      bool use_vertices_;
-      float view_angle_;
-      float radius_sphere_;
-      bool compute_entropy_;
-      vtkSmartPointer<vtkPolyData> polydata_;
-      bool gen_organized_;
-      std::function<bool
-      (const Eigen::Vector3f &)> campos_constraints_func_;
-
-      struct camPosConstraintsAllTrue
-      {
-        bool
-        operator() (const Eigen::Vector3f & /*pos*/) const
-        {
-          return true;
-        }
-        ;
-      };
-
-    public:
-      RenderViewsTesselatedSphere ()
-      {
-        resolution_ = 150;
-        tesselation_level_ = 1;
-        use_vertices_ = false;
-        view_angle_ = 57;
-        radius_sphere_ = 1.f;
-        compute_entropy_ = false;
-        gen_organized_ = false;
-        campos_constraints_func_ = camPosConstraintsAllTrue ();
-      }
-
-      void
-      setCamPosConstraints (std::function<bool (const Eigen::Vector3f &)> & bb)
-      {
-        campos_constraints_func_ = bb;
-      }
-
-      /* \brief Indicates whether to generate organized or unorganized data
-       * \param b organized/unorganized
-       */
-      void
-      setGenOrganized (bool b)
-      {
-        gen_organized_ = b;
-      }
-
-      /* \brief Sets the size of the render window
-       * \param res resolution size
-       */
-      void
-      setResolution (int res)
-      {
-        resolution_ = res;
-      }
-
-      /* \brief Whether to use the vertices or triangle centers of the tessellated sphere
-       * \param use true indicates to use vertices, false triangle centers
-       */
-
-      void
-      setUseVertices (bool use)
-      {
-        use_vertices_ = use;
-      }
-
-      /* \brief Radius of the sphere where the virtual camera will be placed
-       * \param use true indicates to use vertices, false triangle centers
-       */
-      void
-      setRadiusSphere (float radius)
-      {
-        radius_sphere_ = radius;
-      }
-
-      /* \brief Whether to compute the entropies (level of occlusions for each view)
-       * \param compute true to compute entropies, false otherwise
-       */
-      void
-      setComputeEntropies (bool compute)
-      {
-        compute_entropy_ = compute;
-      }
-
-      /* \brief How many times the icosahedron should be tessellated. Results in more or less camera positions and generated views.
-       * \param level amount of tessellation
-       */
-      void
-      setTesselationLevel (int level)
-      {
-        tesselation_level_ = level;
-      }
-
-      /* \brief Sets the view angle of the virtual camera
-       * \param angle view angle in degrees
-       */
-      void
-      setViewAngle (float angle)
-      {
-        view_angle_ = angle;
-      }
-
-      /* \brief adds the mesh to be used as a vtkPolyData
-       * \param polydata vtkPolyData object
-       */
-      void
-      addModelFromPolyData (vtkSmartPointer<vtkPolyData> &polydata)
-      {
-        polydata_ = polydata;
-      }
-
-      /* \brief performs the rendering and stores the generated information
-       */
-      void
-      generateViews ();
-
-      /* \brief Get the generated poses for the generated views
-       * \param poses 4x4 matrices representing the pose of the cloud relative to the model coordinate system
-       */
-      void
-      getPoses (std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > & poses)
-      {
-        poses = poses_;
-      }
-
-      /* \brief Get the generated views
-       * \param views generated pointclouds in camera coordinates
-       */
-      void
-      getViews (std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> & views)
-      {
-        views = generated_views_;
-      }
-
-      /* \brief Get the entropies (level of occlusions) for the views
-       * \param entropies level of occlusions
-       */
-      void
-      getEntropies (std::vector<float> & entropies)
-      {
-        entropies = entropies_;
-      }
+      return true;
     };
+  };
+
+public:
+  RenderViewsTesselatedSphere()
+  {
+    resolution_ = 150;
+    tesselation_level_ = 1;
+    use_vertices_ = false;
+    view_angle_ = 57;
+    radius_sphere_ = 1.f;
+    compute_entropy_ = false;
+    gen_organized_ = false;
+    campos_constraints_func_ = camPosConstraintsAllTrue();
+  }
+
+  void
+  setCamPosConstraints(std::function<bool(const Eigen::Vector3f&)>& bb)
+  {
+    campos_constraints_func_ = bb;
+  }
+
+  /**
+   * \brief Indicates whether to generate organized or unorganized data
+   * \param b organized/unorganized
+   */
+  void
+  setGenOrganized(bool b)
+  {
+    gen_organized_ = b;
+  }
 
+  /**
+   * \brief Sets the size of the render window
+   * \param res resolution size
+   */
+  void
+  setResolution(int res)
+  {
+    resolution_ = res;
   }
-}
+
+  /**
+   * \brief Whether to use the vertices or triangle centers of the tessellated sphere
+   * \param use true indicates to use vertices, false triangle centers
+   */
+
+  void
+  setUseVertices(bool use)
+  {
+    use_vertices_ = use;
+  }
+
+  /**
+   * \brief Radius of the sphere where the virtual camera will be placed
+   * \param use true indicates to use vertices, false triangle centers
+   */
+  void
+  setRadiusSphere(float radius)
+  {
+    radius_sphere_ = radius;
+  }
+
+  /**
+   * \brief Whether to compute the entropies (level of occlusions for each view)
+   * \param compute true to compute entropies, false otherwise
+   */
+  void
+  setComputeEntropies(bool compute)
+  {
+    compute_entropy_ = compute;
+  }
+
+  /**
+   * \brief How many times the icosahedron should be tessellated. Results in more or
+   * less camera positions and generated views.
+   * \param level amount of tessellation
+   */
+  void
+  setTesselationLevel(int level)
+  {
+    tesselation_level_ = level;
+  }
+
+  /**
+   * \brief Sets the view angle of the virtual camera
+   * \param angle view angle in degrees
+   */
+  void
+  setViewAngle(float angle)
+  {
+    view_angle_ = angle;
+  }
+
+  /**
+   * \brief adds the mesh to be used as a vtkPolyData
+   * \param polydata vtkPolyData object
+   */
+  void
+  addModelFromPolyData(vtkSmartPointer<vtkPolyData>& polydata)
+  {
+    polydata_ = polydata;
+  }
+
+  /**
+   * \brief performs the rendering and stores the generated information
+   */
+  void
+  generateViews();
+
+  /**
+   * \brief Get the generated poses for the generated views
+   * \param poses 4x4 matrices representing the pose of the cloud relative to the model
+   * coordinate system
+   */
+  void
+  getPoses(
+      std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f>>& poses)
+  {
+    poses = poses_;
+  }
+
+  /**
+   * \brief Get the generated views
+   * \param views generated pointclouds in camera coordinates
+   */
+  void
+  getViews(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>& views)
+  {
+    views = generated_views_;
+  }
+
+  /**
+   * \brief Get the entropies (level of occlusions) for the views
+   * \param entropies level of occlusions
+   */
+  void
+  getEntropies(std::vector<float>& entropies)
+  {
+    entropies = entropies_;
+  }
+};
+
+} // namespace apps
+} // namespace pcl
index 630a22e98c3b973cd7c63d0c3a1f897dfb41ed92..86e431f344ac30d9a86c29b6654082cfa197218e 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2012, Open Perception, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
 #include <pcl/common/time.h> //fps calculations
 
 #if SHOW_FPS
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 #else
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-}while(false)
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+  } while (false)
 #endif
index 944d82c9e9bb66e2eb3604b4b75c3b9684c91493..be067b836cf08f782c55125f33bec4917727017a 100644 (file)
 
 #pragma once
 
-#include <fstream>
-#include <pcl/point_types.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/features/vfh.h>
-#include <pcl/features/normal_3d.h>
 #include <pcl/apps/nn_classification.h>
+#include <pcl/features/normal_3d.h>
+#include <pcl/features/vfh.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/PCLPointCloud2.h>
+#include <pcl/point_types.h>
 
-namespace pcl
-{
-  /** \brief Helper function to extract the VFH feature describing the given point cloud.
-    * \param points point cloud for feature extraction
-    * \param radius search radius for normal estimation
-    * \return point cloud containing the extracted feature
-    */
-  template <typename PointT> pcl::PointCloud<pcl::VFHSignature308>::Ptr
-  computeVFH (typename PointCloud<PointT>::ConstPtr cloud, double radius)
-  {
-    using namespace pcl;
-
-    // Create an empty kdtree representation, and pass it to the objects.
-    // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
-    typename pcl::search::KdTree<PointT>::Ptr tree (new pcl::search::KdTree<PointT> ());
+#include <fstream>
 
-    // Create the normal estimation class, and pass the input dataset to it
-    NormalEstimation<PointT, Normal> ne;
-    ne.setInputCloud (cloud);
-    ne.setSearchMethod (tree);
+namespace pcl {
 
-    // Use all neighbors in a sphere of given radius to compute the normals
-    PointCloud<Normal>::Ptr normals (new PointCloud<Normal> ());
-    ne.setRadiusSearch (radius);
-    ne.compute (*normals);
+/**
+ * \brief Helper function to extract the VFH feature describing the given point cloud.
+ * \param points point cloud for feature extraction
+ * \param radius search radius for normal estimation
+ * \return point cloud containing the extracted feature
+ */
+template <typename PointT>
+pcl::PointCloud<pcl::VFHSignature308>::Ptr
+computeVFH(typename PointCloud<PointT>::ConstPtr cloud, double radius)
+{
+  using namespace pcl;
 
-    // Create the VFH estimation class, and pass the input dataset+normals to it
-    VFHEstimation<PointT, Normal, VFHSignature308> vfh;
-    vfh.setInputCloud (cloud);
-    vfh.setInputNormals (normals);
-    vfh.setSearchMethod (tree);
+  // Create an empty kdtree representation, and pass it to the objects.
+  // Its content will be filled inside the object, based on the given input dataset
+  // (as no other search surface is given).
+  typename pcl::search::KdTree<PointT>::Ptr tree(new pcl::search::KdTree<PointT>());
 
-    // Output datasets
-    PointCloud<VFHSignature308>::Ptr vfhs (new PointCloud<VFHSignature308>);
+  // Create the normal estimation class, and pass the input dataset to it
+  NormalEstimation<PointT, Normal> ne;
+  ne.setInputCloud(cloud);
+  ne.setSearchMethod(tree);
 
-    // Compute the features and return
-    vfh.compute (*vfhs);
-    return vfhs;
-  }
+  // Use all neighbors in a sphere of given radius to compute the normals
+  PointCloud<Normal>::Ptr normals(new PointCloud<Normal>());
+  ne.setRadiusSearch(radius);
+  ne.compute(*normals);
 
-  /**
-    * \brief Utility class for nearest neighbor search based classification of VFH features.
-    * \author Zoltan Csaba Marton
-    */
-  class VFHClassifierNN
-  {
-    public:
+  // Create the VFH estimation class, and pass the input dataset+normals to it
+  VFHEstimation<PointT, Normal, VFHSignature308> vfh;
+  vfh.setInputCloud(cloud);
+  vfh.setInputNormals(normals);
+  vfh.setSearchMethod(tree);
 
-      using FeatureCloud = pcl::PointCloud<pcl::VFHSignature308>;
-      using FeatureCloudPtr = pcl::PointCloud<pcl::VFHSignature308>::Ptr;
-      using FeatureCloudConstPtr = pcl::PointCloud<pcl::VFHSignature308>::ConstPtr;
-      using Result = NNClassification<pcl::VFHSignature308>::Result;
-      using ResultPtr = NNClassification<pcl::VFHSignature308>::ResultPtr;
+  // Output datasets
+  PointCloud<VFHSignature308>::Ptr vfhs(new PointCloud<VFHSignature308>);
 
-    private:
+  // Compute the features and return
+  vfh.compute(*vfhs);
+  return vfhs;
+}
 
-      /** \brief Point cloud containing the training VFH features */
-      FeatureCloudPtr training_features_;
-      /** \brief Class label for each training example */
-      std::vector<std::string> labels_;
-      /** \brief Nearest neighbor classifier instantiated for VFH features */
-      NNClassification<pcl::VFHSignature308> classifier_;
+/**
+ * \brief Utility class for nearest neighbor search based classification of VFH
+ * features.
+ * \author Zoltan Csaba Marton
+ */
+class VFHClassifierNN {
+public:
+  using FeatureCloud = pcl::PointCloud<pcl::VFHSignature308>;
+  using FeatureCloudPtr = pcl::PointCloud<pcl::VFHSignature308>::Ptr;
+  using FeatureCloudConstPtr = pcl::PointCloud<pcl::VFHSignature308>::ConstPtr;
+  using Result = NNClassification<pcl::VFHSignature308>::Result;
+  using ResultPtr = NNClassification<pcl::VFHSignature308>::ResultPtr;
 
-    public:
+private:
+  /** \brief Point cloud containing the training VFH features */
+  FeatureCloudPtr training_features_;
+  /** \brief Class label for each training example */
+  std::vector<std::string> labels_;
+  /** \brief Nearest neighbor classifier instantiated for VFH features */
+  NNClassification<pcl::VFHSignature308> classifier_;
 
-      VFHClassifierNN ()
-      {
-        reset ();
-      }
+public:
+  VFHClassifierNN() { reset(); }
 
-      void reset ()
-      {
-        training_features_.reset (new FeatureCloud);
-        labels_.clear ();
-        classifier_ = NNClassification<pcl::VFHSignature308> ();
-      }
+  void
+  reset()
+  {
+    training_features_.reset(new FeatureCloud);
+    labels_.clear();
+    classifier_ = NNClassification<pcl::VFHSignature308>();
+  }
 
-      /** \brief Set up the classifier with the current training features and labels */
-      void finalizeTraining ()
-      {
-        finalizeTree ();
-        finalizeLabels ();
-      }
+  /** \brief Set up the classifier with the current training features and labels */
+  void
+  finalizeTraining()
+  {
+    finalizeTree();
+    finalizeLabels();
+  }
 
-      /** \brief Set up the classifier with the current training features */
-      void finalizeTree ()
-      {
-        classifier_.setTrainingFeatures(training_features_);
-      }
+  /** \brief Set up the classifier with the current training features */
+  void
+  finalizeTree()
+  {
+    classifier_.setTrainingFeatures(training_features_);
+  }
 
-      /** \brief Set up the classifier with the current training example labels */
-      void finalizeLabels ()
-      {
-        classifier_.setTrainingLabels(labels_);
-      }
+  /** \brief Set up the classifier with the current training example labels */
+  void
+  finalizeLabels()
+  {
+    classifier_.setTrainingLabels(labels_);
+  }
 
-      /** \brief Save the list of training examples and corresponding labels.
-        * \param file_name file name for writing the training features
-        * \param labels_file_name file name for writing the class label for each training example
-        * \return true on success, false on failure (write error or number of entries don't match)
-        */
-      bool saveTrainingFeatures(const std::string& file_name, const std::string& labels_file_name)
-      {
-        if (labels_.size () == training_features_->points.size ())
-        {
-          if (pcl::io::savePCDFile (file_name, *training_features_) != 0)
-            return false;
-          std::ofstream f (labels_file_name.c_str ());
-          for (const auto& s : labels_)
-          {
-            f << s << "\n";
-          }
-          return true;
-        }
+  /**
+   * \brief Save the list of training examples and corresponding labels.
+   * \param file_name file name for writing the training features
+   * \param labels_file_name file name for writing the class label for each
+   * training example
+   * \return true on success, false on failure (write error or number of entries
+   * don't match)
+   */
+  bool
+  saveTrainingFeatures(const std::string& file_name,
+                       const std::string& labels_file_name)
+  {
+    if (labels_.size() == training_features_->points.size()) {
+      if (pcl::io::savePCDFile(file_name, *training_features_) != 0)
         return false;
+      std::ofstream f(labels_file_name.c_str());
+      for (const auto& s : labels_) {
+        f << s << "\n";
       }
+      return true;
+    }
+    return false;
+  }
 
-      /** \brief Fill the list of training examples and corresponding labels.
-        * \note this function has a cumulative effect.
-        * \param training_features the training features
-        * \param labels the class label for each training example
-        * \return true on success, false on failure (number of entries don't match)
-        */
-      bool addTrainingFeatures (const FeatureCloudPtr& training_features, const std::vector<std::string> &labels)
-      {
-        if (labels.size () == training_features->points.size ())
-        {
-          labels_.insert (labels_.end (), labels.begin (), labels.end ());
-          training_features_->points.insert (training_features_->points.end (), training_features->points.begin (), training_features->points.end ());
-          training_features_->header = training_features->header;
-          training_features_->height = 1;
-          training_features_->width  = static_cast<std::uint32_t> (training_features_->points.size ());
-          training_features_->is_dense &= training_features->is_dense;
-          training_features_->sensor_origin_ = training_features->sensor_origin_;
-          training_features_->sensor_orientation_ = training_features->sensor_orientation_;
-          return true;
-        }
-        return false;
-      }
+  /**
+   * \brief Fill the list of training examples and corresponding labels.
+   * \note this function has a cumulative effect.
+   * \param training_features the training features
+   * \param labels the class label for each training example
+   * \return true on success, false on failure (number of entries don't match)
+   */
+  bool
+  addTrainingFeatures(const FeatureCloudPtr& training_features,
+                      const std::vector<std::string>& labels)
+  {
+    if (labels.size() == training_features->points.size()) {
+      labels_.insert(labels_.end(), labels.begin(), labels.end());
+      training_features_->points.insert(training_features_->points.end(),
+                                        training_features->points.begin(),
+                                        training_features->points.end());
+      training_features_->header = training_features->header;
+      training_features_->height = 1;
+      training_features_->width =
+          static_cast<std::uint32_t>(training_features_->points.size());
+      training_features_->is_dense &= training_features->is_dense;
+      training_features_->sensor_origin_ = training_features->sensor_origin_;
+      training_features_->sensor_orientation_ = training_features->sensor_orientation_;
+      return true;
+    }
+    return false;
+  }
 
-      /** \brief Fill the list of training examples and corresponding labels.
-        * \note this function has a cumulative effect.
-        * \param file_name PCD file containing the training features
-        * \param labels_file_name the class label for each training example
-        * \return true on success, false on failure (read error or number of entries don't match)
-        */
-      bool loadTrainingFeatures(const std::string& file_name, const std::string& labels_file_name)
-      {
-        FeatureCloudPtr cloud (new FeatureCloud);
-        if (pcl::io::loadPCDFile (file_name, *cloud) != 0)
-          return false;
-        std::vector<std::string> labels;
-        std::ifstream f (labels_file_name.c_str ());
-        std::string label;
-        while (getline (f, label))
-          if (!label.empty ())
-            labels.push_back(label);
-        return addTrainingFeatures (cloud, labels);
-      }
+  /**
+   * \brief Fill the list of training examples and corresponding labels.
+   * \note this function has a cumulative effect.
+   * \param file_name PCD file containing the training features
+   * \param labels_file_name the class label for each training example
+   * \return true on success, false on failure (read error or number of entries don't
+   * match)
+   */
+  bool
+  loadTrainingFeatures(const std::string& file_name,
+                       const std::string& labels_file_name)
+  {
+    FeatureCloudPtr cloud(new FeatureCloud);
+    if (pcl::io::loadPCDFile(file_name, *cloud) != 0)
+      return false;
+    std::vector<std::string> labels;
+    std::ifstream f(labels_file_name.c_str());
+    std::string label;
+    while (getline(f, label))
+      if (!label.empty())
+        labels.push_back(label);
+    return addTrainingFeatures(cloud, labels);
+  }
 
-      /** \brief Add the feature extracted from the cloud at the specified
-        * location as a training example with the given labels.
-        * \note this function has a cumulative effect.
-        * \param file_name PCD file containing the training data
-        * \param label the class label for the training example
-        * \return true on success, false on failure (read error or number of entries don't match)
-        */
-      bool loadTrainingData (const std::string& file_name, std::string label)
-      {
-        pcl::PCLPointCloud2 cloud_blob;
-        if (pcl::io::loadPCDFile (file_name, cloud_blob) != 0)
-          return false;
-        return addTrainingData (cloud_blob, label);
-      }
+  /**
+   * \brief Add the feature extracted from the cloud at the specified
+   * location as a training example with the given labels.
+   * \note this function has a cumulative effect.
+   * \param file_name PCD file containing the training data
+   * \param label the class label for the training example
+   * \return true on success, false on failure (read error or number of entries don't
+   * match)
+   */
+  bool
+  loadTrainingData(const std::string& file_name, std::string label)
+  {
+    pcl::PCLPointCloud2 cloud_blob;
+    if (pcl::io::loadPCDFile(file_name, cloud_blob) != 0)
+      return false;
+    return addTrainingData(cloud_blob, label);
+  }
 
-      /** \brief Add the feature extracted from the cloud as a training example with the given labels.
-        * \note this function has a cumulative effect.
-        * \param training_data point cloud for training feature extraction
-        * \param label the class label for the training example
-        * \return true on success, false on failure (read error or number of entries don't match)
-        */
-      bool addTrainingData (const pcl::PCLPointCloud2 &training_data, std::string &label)
-      {
-        // Create label list containing the single label
-        std::vector<std::string> labels;
-        labels.push_back (label);
+  /**
+   * \brief Add the feature extracted from the cloud as a training example with the
+   * given labels.
+   * \note this function has a cumulative effect.
+   * \param training_data point cloud for training feature extraction
+   * \param label the class label for the training example
+   * \return true on success, false on failure (read error or number of entries
+   * don't match)
+   */
+  bool
+  addTrainingData(const pcl::PCLPointCloud2& training_data, std::string& label)
+  {
+    // Create label list containing the single label
+    std::vector<std::string> labels;
+    labels.push_back(label);
 
-        // Compute the feature from the cloud and add it as a training example
-        FeatureCloudPtr vfhs = computeFeature (training_data);
-        return addTrainingFeatures(vfhs, labels);
-      }
+    // Compute the feature from the cloud and add it as a training example
+    FeatureCloudPtr vfhs = computeFeature(training_data);
+    return addTrainingFeatures(vfhs, labels);
+  }
 
-      /** \brief Utility function for the default classification process.
-        * \param testing_data the point clouds to be classified
-        * \param radius the maximum search radius in feature space -- 300 by default
-        * \param minimum_score the score to be given to matches at maximum distance (>0) -- 0.002 by default
-        * \return pair of label and score for each relevant training class
-        */
-      ResultPtr classify (const pcl::PCLPointCloud2 &testing_data, double radius = 300, double min_score = 0.002)
-      {
-        // compute the VFH feature for this point cloud
-        FeatureCloudPtr vfhs = computeFeature (testing_data);
-        // compute gaussian parameter producing the desired minimum score (around 50 for the default values)
-        float gaussian_param = - static_cast<float> (radius / std::log (min_score));
-        // TODO accept result to be filled in by reference
-        return classifier_.classify(vfhs->points.at (0), radius, gaussian_param);
-      }
+  /**
+   * \brief Utility function for the default classification process.
+   * \param testing_data the point clouds to be classified
+   * \param radius the maximum search radius in feature space -- 300 by default
+   * \param minimum_score the score to be given to matches at maximum distance
+   * (>0) -- 0.002 by default
+   * \return pair of label and score for each relevant training class
+   */
+  ResultPtr
+  classify(const pcl::PCLPointCloud2& testing_data,
+           double radius = 300,
+           double min_score = 0.002)
+  {
+    // compute the VFH feature for this point cloud
+    FeatureCloudPtr vfhs = computeFeature(testing_data);
+    // compute gaussian parameter producing the desired minimum score
+    // (around 50 for the default values)
+    float gaussian_param = -static_cast<float>(radius / std::log(min_score));
+    // TODO accept result to be filled in by reference
+    return classifier_.classify(vfhs->points.at(0), radius, gaussian_param);
+  }
 
-      /** \brief Extract the VFH feature describing the given point cloud.
-        * \param points point cloud for feature extraction
-        * \param radius search radius for normal estimation -- 0.03 m by default
-        * \return point cloud containing the extracted feature
-        */
-      FeatureCloudPtr computeFeature (const pcl::PCLPointCloud2 &points, double radius = 0.03)
-      {
-        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
-        pcl::fromPCLPointCloud2 (points, *cloud);
-        return pcl::computeVFH<pcl::PointXYZ> (cloud, radius);
-      }
-  };
-}
+  /**
+   * \brief Extract the VFH feature describing the given point cloud.
+   * \param points point cloud for feature extraction
+   * \param radius search radius for normal estimation -- 0.03 m by default
+   * \return point cloud containing the extracted feature
+   */
+  FeatureCloudPtr
+  computeFeature(const pcl::PCLPointCloud2& points, double radius = 0.03)
+  {
+    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
+    pcl::fromPCLPointCloud2(points, *cloud);
+    return pcl::computeVFH<pcl::PointXYZ>(cloud, radius);
+  }
+};
+
+} // namespace pcl
index 1db7e2884470c9262e48ca7d282d3dc8deaab920..07a023e121b3f747206ee2940dcacf9dd6affe89 100755 (executable)
 
 class QMenu;
 class QPoint;
-namespace Ui
-{
-  class MainWindow;
+
+namespace Ui {
+class MainWindow;
 }
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class ParameterDialog;
+namespace pcl {
+namespace modeler {
 
-    class AbstractItem
-    {
-      public:
-        AbstractItem();
-        ~AbstractItem();
+class ParameterDialog;
 
-        void
-        showContextMenu(const QPoint* position);
+class AbstractItem {
+public:
+  AbstractItem();
+  ~AbstractItem();
 
-        virtual std::string
-        getItemName() const = 0;
+  void
+  showContextMenu(const QPoint* position);
 
-        void
-        showPropertyEditor();
+  virtual std::string
+  getItemName() const = 0;
 
-      protected:
-        Ui::MainWindow* ui() const;
+  void
+  showPropertyEditor();
 
-        virtual void
-        prepareContextMenu(QMenu* menu) const = 0;
+protected:
+  Ui::MainWindow*
+  ui() const;
 
-        virtual void
-        prepareProperties(ParameterDialog* parameter_dialog) = 0;
+  virtual void
+  prepareContextMenu(QMenu* menu) const = 0;
 
-        virtual void
-        setProperties() = 0;
-    };
+  virtual void
+  prepareProperties(ParameterDialog* parameter_dialog) = 0;
 
-  }
-}
+  virtual void
+  setProperties() = 0;
+};
+
+} // namespace modeler
+} // namespace pcl
index 0752b64c16eb60f21797811b5a823c44a7fd4280..bd73202d0f01a27b1c10e05bfd3328aaec9edcd9 100755 (executable)
 
 #include <QObject>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class CloudMeshItem;
-    class ParameterDialog;
+namespace pcl {
+namespace modeler {
 
-    class AbstractWorker : public QObject
-    {
-      Q_OBJECT
+class CloudMeshItem;
+class ParameterDialog;
 
-      public:
-        AbstractWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent=nullptr);
-        ~AbstractWorker();
+class AbstractWorker : public QObject {
+  Q_OBJECT
 
-        int
-        exec();
+public:
+  AbstractWorker(const QList<CloudMeshItem*>& cloud_mesh_items,
+                 QWidget* parent = nullptr);
+  ~AbstractWorker();
 
-      public Q_SLOTS:
-        void
-        process();
+  int
+  exec();
 
-      Q_SIGNALS:
-        void
-        dataUpdated(CloudMeshItem* cloud_mesh_item);
+public Q_SLOTS:
+  void
+  process();
 
-        void
-        finished();
+Q_SIGNALS:
+  void
+  dataUpdated(CloudMeshItem* cloud_mesh_item);
 
-      protected:
-        void
-        emitDataUpdated(CloudMeshItem* cloud_mesh_item);
+  void
+  finished();
 
-        virtual std::string
-        getName () const {return ("");}
+protected:
+  void
+  emitDataUpdated(CloudMeshItem* cloud_mesh_item);
 
-        virtual void
-        initParameters(CloudMeshItem* cloud_mesh_item) = 0;
+  virtual std::string
+  getName() const
+  {
+    return "";
+  }
 
-        virtual void
-        setupParameters() = 0;
+  virtual void
+  initParameters(CloudMeshItem* cloud_mesh_item) = 0;
 
-        virtual void
-        processImpl(CloudMeshItem* cloud_mesh_item) = 0;
+  virtual void
+  setupParameters() = 0;
 
-      protected:
-        QList<CloudMeshItem*>       cloud_mesh_items_;
-        ParameterDialog*            parameter_dialog_;
-    };
+  virtual void
+  processImpl(CloudMeshItem* cloud_mesh_item) = 0;
 
-  }
-}
+protected:
+  QList<CloudMeshItem*> cloud_mesh_items_;
+  ParameterDialog* parameter_dialog_;
+};
+
+} // namespace modeler
+} // namespace pcl
index 104d469dd58c63988bb1d3ae238e6fd85d3d0620..c82f362f704822d4c33790112e85134bab535b5f 100755 (executable)
 
 #pragma once
 
+#include <pcl/apps/modeler/abstract_item.h>
+#include <pcl/apps/modeler/cloud_mesh.h>
+#include <pcl/common/eigen.h>
+
 #include <QTreeWidgetItem>
 
 #include <vtkSmartPointer.h>
 
-#include <pcl/common/eigen.h>
-#include <pcl/apps/modeler/abstract_item.h>
-#include <pcl/apps/modeler/cloud_mesh.h>
-
 class vtkActor;
 class vtkPolyData;
 class vtkMatrix4x4;
 class vtkRenderWindow;
 
+namespace pcl {
+namespace modeler {
+
+class ChannelActorItem : public QTreeWidgetItem, public AbstractItem {
+public:
+  ChannelActorItem(QTreeWidgetItem* parent,
+                   const CloudMesh::Ptr& cloud_mesh,
+                   const vtkSmartPointer<vtkRenderWindow>& render_window,
+                   const vtkSmartPointer<vtkActor>& actor,
+                   const std::string& channel_name);
+  ~ChannelActorItem();
+
+  void
+  init();
+
+  void
+  update();
+
+  void
+  switchRenderWindow(vtkRenderWindow* render_window);
+
+protected:
+  void
+  attachActor();
+
+  void
+  detachActor();
+
+  virtual void
+  initImpl() = 0;
+
+  virtual void
+  updateImpl() = 0;
+
+  void
+  prepareContextMenu(QMenu* menu) const override;
+
+  CloudMesh::Ptr cloud_mesh_;
+  vtkSmartPointer<vtkPolyData> poly_data_;
+  vtkSmartPointer<vtkRenderWindow> render_window_;
+  std::string color_scheme_;
+  vtkSmartPointer<vtkActor> actor_;
+  double r_, g_, b_;
+
+private:
+};
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class ChannelActorItem : public QTreeWidgetItem, public AbstractItem
-    {
-      public:
-        ChannelActorItem(QTreeWidgetItem* parent,
-                         const CloudMesh::Ptr& cloud_mesh,
-                         const vtkSmartPointer<vtkRenderWindow>& render_window,
-                         const vtkSmartPointer<vtkActor>& actor,
-                         const std::string& channel_name);
-        ~ChannelActorItem();
-
-        void
-        init();
-
-        void
-        update();
-
-        void
-        switchRenderWindow(vtkRenderWindow* render_window);
-
-      protected:
-        void
-        attachActor();
-
-        void
-        detachActor();
-
-        virtual void
-        initImpl() = 0;
-
-        virtual void
-        updateImpl() = 0;
-
-        void
-        prepareContextMenu(QMenu* menu) const override;
-
-        CloudMesh::Ptr                    cloud_mesh_;
-        vtkSmartPointer<vtkPolyData>      poly_data_;
-        vtkSmartPointer<vtkRenderWindow>  render_window_;
-        std::string                       color_scheme_;
-        vtkSmartPointer<vtkActor>         actor_;
-        double                            r_, g_, b_;
-
-      private:
-    };
-  }
-}
+} // namespace modeler
+} // namespace pcl
index c8dda9d7de691345114247557ce61baa9c5adb21..cc364bdd3a3a789ef765607fb1c655dea095fd33 100755 (executable)
 
 #pragma once
 
-#include <pcl/point_types.h>
-#include <pcl/point_cloud.h>
 #include <pcl/Vertices.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+
 #include <vtkSmartPointer.h>
 
 class vtkPoints;
 class vtkCellArray;
 class vtkDataArray;
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class CloudMesh
-    {
-    public:
-      using PointT = pcl::PointSurfel;
-      using PointCloud = pcl::PointCloud<PointT>;
-      using PointCloudPtr = PointCloud::Ptr;
-      using PointCloudConstPtr = PointCloud::ConstPtr;
-      using Ptr = std::shared_ptr<CloudMesh>;
+namespace pcl {
+namespace modeler {
 
-      CloudMesh ();
-      CloudMesh (PointCloudPtr cloud);
-      ~CloudMesh ();
+class CloudMesh {
+public:
+  using PointT = pcl::PointSurfel;
+  using PointCloud = pcl::PointCloud<PointT>;
+  using PointCloudPtr = PointCloud::Ptr;
+  using PointCloudConstPtr = PointCloud::ConstPtr;
+  using Ptr = std::shared_ptr<CloudMesh>;
 
-      PointCloudPtr& 
-      getCloud() {return cloud_;}
-      PointCloudConstPtr
-      getCloud() const {return cloud_;}
+  CloudMesh();
+  CloudMesh(PointCloudPtr cloud);
+  ~CloudMesh();
 
-      std::vector<pcl::Vertices>&
-      getPolygons() {return polygons_;}
-      const std::vector<pcl::Vertices>&
-      getPolygons() const {return polygons_;}
+  PointCloudPtr&
+  getCloud()
+  {
+    return cloud_;
+  }
+  PointCloudConstPtr
+  getCloud() const
+  {
+    return cloud_;
+  }
 
-      vtkSmartPointer<vtkPoints>&
-      getVtkPoints() {return vtk_points_;}
-      const vtkSmartPointer<vtkPoints>&
-      getVtkPoints() const {return vtk_points_;}
+  std::vector<pcl::Vertices>&
+  getPolygons()
+  {
+    return polygons_;
+  }
+  const std::vector<pcl::Vertices>&
+  getPolygons() const
+  {
+    return polygons_;
+  }
 
-      vtkSmartPointer<vtkCellArray>&
-      getVtkPolygons() {return vtk_polygons_;}
-      const vtkSmartPointer<vtkCellArray>&
-      getVtkPolygons() const {return vtk_polygons_;}
+  vtkSmartPointer<vtkPoints>&
+  getVtkPoints()
+  {
+    return vtk_points_;
+  }
+  const vtkSmartPointer<vtkPoints>&
+  getVtkPoints() const
+  {
+    return vtk_points_;
+  }
 
-      std::vector<std::string>
-      getAvaiableFieldNames() const;
+  vtkSmartPointer<vtkCellArray>&
+  getVtkPolygons()
+  {
+    return vtk_polygons_;
+  }
+  const vtkSmartPointer<vtkCellArray>&
+  getVtkPolygons() const
+  {
+    return vtk_polygons_;
+  }
 
-      bool
-      open(const std::string& filename);
+  std::vector<std::string>
+  getAvaiableFieldNames() const;
 
-      bool
-      save(const std::string& filename) const;
+  bool
+  open(const std::string& filename);
 
-      static bool
-      save(const std::vector<const CloudMesh*>& cloud_meshes, const std::string& filename);
+  bool
+  save(const std::string& filename) const;
 
-      void
-      getColorScalarsFromField(vtkSmartPointer<vtkDataArray> &scalars, const std::string& field) const;
+  static bool
+  save(const std::vector<const CloudMesh*>& cloud_meshes, const std::string& filename);
 
-      void
-      updateVtkPoints();
+  void
+  getColorScalarsFromField(vtkSmartPointer<vtkDataArray>& scalars,
+                           const std::string& field) const;
 
-      void
-      updateVtkPolygons();
+  void
+  updateVtkPoints();
 
-      void
-      transform(double tx, double ty, double tz, double rx, double ry, double rz);
+  void
+  updateVtkPolygons();
 
-    protected:
+  void
+  transform(double tx, double ty, double tz, double rx, double ry, double rz);
 
+protected:
+private:
+  PointCloudPtr cloud_;
+  std::vector<pcl::Vertices> polygons_;
 
-    private:
-      PointCloudPtr               cloud_;
-      std::vector<pcl::Vertices>  polygons_;
+  vtkSmartPointer<vtkPoints> vtk_points_;
+  vtkSmartPointer<vtkCellArray> vtk_polygons_;
+};
 
-      vtkSmartPointer<vtkPoints>            vtk_points_;
-      vtkSmartPointer<vtkCellArray>         vtk_polygons_;
-    };
-  }
-}
+} // namespace modeler
+} // namespace pcl
index be4d4c56f2fe826b1d9fdacf283f2b8c53e27127..02345010639a62533fe272d93bdc8bbbe6f3ba42 100755 (executable)
 
 #pragma once
 
-#include <QTreeWidgetItem>
-
 #include <pcl/apps/modeler/abstract_item.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 
-namespace pcl
-{
-  namespace modeler
+#include <QTreeWidgetItem>
+
+namespace pcl {
+namespace modeler {
+
+class CloudMesh;
+class DoubleParameter;
+
+class CloudMeshItem : public QTreeWidgetItem, public AbstractItem {
+public:
+  CloudMeshItem(QTreeWidgetItem* parent, const std::string& filename);
+  CloudMeshItem(QTreeWidgetItem* parent, CloudMesh::PointCloudPtr cloud);
+  CloudMeshItem(QTreeWidgetItem* parent, const CloudMeshItem& cloud_mesh_item);
+  ~CloudMeshItem();
+
+  inline CloudMesh::Ptr&
+  getCloudMesh()
+  {
+    return cloud_mesh_;
+  }
+
+  inline const CloudMesh::Ptr&
+  getCloudMesh() const
+  {
+    return cloud_mesh_;
+  }
+
+  static bool
+  savePointCloud(const QList<CloudMeshItem*>& items, const QString& filename);
+
+  bool
+  open();
+
+  void
+  createChannels();
+
+  void
+  updateChannels();
+
+  std::string
+  getItemName() const override
   {
-    class CloudMesh;
-    class DoubleParameter;
-
-    class CloudMeshItem : public QTreeWidgetItem, public AbstractItem
-    {
-      public:
-        CloudMeshItem(QTreeWidgetItem* parent, const std::string& filename);
-        CloudMeshItem(QTreeWidgetItem* parent, CloudMesh::PointCloudPtr cloud);
-        CloudMeshItem(QTreeWidgetItem* parent, const CloudMeshItem& cloud_mesh_item);
-        ~CloudMeshItem();
-
-        inline CloudMesh::Ptr&
-        getCloudMesh()
-        {
-          return cloud_mesh_;
-        }
-
-        inline const CloudMesh::Ptr&
-        getCloudMesh() const
-        {
-          return cloud_mesh_;
-        }
-
-        static bool
-        savePointCloud(const QList<CloudMeshItem*>& items, const QString& filename);
-
-        bool
-        open();
-
-        void
-        createChannels();
-
-        void
-        updateChannels();
-
-        std::string
-        getItemName() const override {return "Cloud Mesh Item";}
-
-        void
-        updateRenderWindow();
-
-      protected:
-        void
-        prepareContextMenu(QMenu* menu) const override;
-
-        void
-        prepareProperties(ParameterDialog* parameter_dialog) override;
-
-        void
-        setProperties() override;
-
-      private:
-        std::string                           filename_;
-        CloudMesh::Ptr                        cloud_mesh_;
-
-        DoubleParameter*                      translation_x_;
-        DoubleParameter*                      translation_y_;
-        DoubleParameter*                      translation_z_;
-        DoubleParameter*                      rotation_x_;
-        DoubleParameter*                      rotation_y_;
-        DoubleParameter*                      rotation_z_;
-    };
+    return "Cloud Mesh Item";
   }
-}
+
+  void
+  updateRenderWindow();
+
+protected:
+  void
+  prepareContextMenu(QMenu* menu) const override;
+
+  void
+  prepareProperties(ParameterDialog* parameter_dialog) override;
+
+  void
+  setProperties() override;
+
+private:
+  std::string filename_;
+  CloudMesh::Ptr cloud_mesh_;
+
+  DoubleParameter* translation_x_;
+  DoubleParameter* translation_y_;
+  DoubleParameter* translation_z_;
+  DoubleParameter* rotation_x_;
+  DoubleParameter* rotation_y_;
+  DoubleParameter* rotation_z_;
+};
+
+} // namespace modeler
+} // namespace pcl
index fb7c3e592ee64bd5db14ba91a4ed4088dfe22ff7..136dd6b42ed99dd4886e6a8780302deddbacbd34 100755 (executable)
 
 #include <QObject>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class CloudMeshItem;
-
-    class CloudMeshItemUpdater : public QObject
-    {
-      Q_OBJECT
-
-      public:
-        CloudMeshItemUpdater (CloudMeshItem* cloud_mesh_item);
-        ~CloudMeshItemUpdater ();
-
-      public Q_SLOTS:
-        void
-        updateCloudMeshItem();
-
-      private:
-        CloudMeshItem*      cloud_mesh_item_;
-    };
-  }
-}
+namespace pcl {
+namespace modeler {
+
+class CloudMeshItem;
+
+class CloudMeshItemUpdater : public QObject {
+  Q_OBJECT
+
+public:
+  CloudMeshItemUpdater(CloudMeshItem* cloud_mesh_item);
+  ~CloudMeshItemUpdater();
+
+public Q_SLOTS:
+  void
+  updateCloudMeshItem();
+
+private:
+  CloudMeshItem* cloud_mesh_item_;
+};
+
+} // namespace modeler
+} // namespace pcl
index be9ac2a98fd3c43245d347e18b9d18427731642e..40d63a346ea3d929c776096e0ca46d626d6d7a11 100755 (executable)
 
 #include <QDockWidget>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class DockWidget : public QDockWidget
-    {
-      public:
-        explicit DockWidget(const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 
-        explicit DockWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 
-        ~DockWidget();
-
-        void
-        setFocusBasedStyle(bool focused);
-      protected:
-        void
-        focusInEvent ( QFocusEvent * event ) override;
-
-      private:
-    };
-  }
-}
+namespace pcl {
+namespace modeler {
+
+class DockWidget : public QDockWidget {
+public:
+  explicit DockWidget(const QString& title,
+                      QWidget* parent = nullptr,
+                      Qt::WindowFlags flags = Qt::WindowFlags());
+  explicit DockWidget(QWidget* parent = nullptr,
+                      Qt::WindowFlags flags = Qt::WindowFlags());
+  ~DockWidget();
+
+  void
+  setFocusBasedStyle(bool focused);
+
+protected:
+  void
+  focusInEvent(QFocusEvent* event) override;
+
+private:
+};
+
+} // namespace modeler
+} // namespace pcl
index 4fccd26359edcbe3dc69ef9cae00b6a62f28b244..53c30600b8f0554ddfc12fb695bc4c5352f92895 100755 (executable)
 #include <pcl/apps/modeler/abstract_worker.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class IntParameter;
-    class DoubleParameter;
+namespace pcl {
+namespace modeler {
 
-    class ICPRegistrationWorker : public AbstractWorker 
-    {
-      public:
-        ICPRegistrationWorker(CloudMesh::PointCloudPtr cloud, const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent=nullptr);
-        ~ICPRegistrationWorker();
+class IntParameter;
+class DoubleParameter;
 
-      protected:
-        std::string
-        getName () const override {return ("Normal Estimation");}
+class ICPRegistrationWorker : public AbstractWorker {
+public:
+  ICPRegistrationWorker(CloudMesh::PointCloudPtr cloud,
+                        const QList<CloudMeshItem*>& cloud_mesh_items,
+                        QWidget* parent = nullptr);
+  ~ICPRegistrationWorker();
 
-        void
-        initParameters(CloudMeshItem* cloud_mesh_item) override;
+protected:
+  std::string
+  getName() const override
+  {
+    return "Normal Estimation";
+  }
 
-        void
-        setupParameters() override;
+  void
+  initParameters(CloudMeshItem* cloud_mesh_item) override;
 
-        void
-        processImpl(CloudMeshItem* cloud_mesh_item) override;
+  void
+  setupParameters() override;
 
-      private:
-        CloudMesh::PointCloudPtr    cloud_;
+  void
+  processImpl(CloudMeshItem* cloud_mesh_item) override;
 
-        double x_min_, x_max_;
-        double y_min_, y_max_;
-        double z_min_, z_max_;
+private:
+  CloudMesh::PointCloudPtr cloud_;
 
-        DoubleParameter*  max_correspondence_distance_;
-        IntParameter*     max_iterations_;
-        DoubleParameter*  transformation_epsilon_;
-        DoubleParameter*  euclidean_fitness_epsilon_;
-    };
+  double x_min_, x_max_;
+  double y_min_, y_max_;
+  double z_min_, z_max_;
 
-  }
-}
+  DoubleParameter* max_correspondence_distance_;
+  IntParameter* max_iterations_;
+  DoubleParameter* transformation_epsilon_;
+  DoubleParameter* euclidean_fitness_epsilon_;
+};
+
+} // namespace modeler
+} // namespace pcl
index 8d8410259694430647fef69be4e4c83db47174f2..3315955dc6c60d84bcb93315db5d7db06469b3c3 100755 (executable)
 /*
-* Software License Agreement (BSD License)
-*
-*  Copyright (c) 2010, Willow Garage, Inc.
-*  All rights reserved.
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*   * Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*   * Redistributions in binary form must reproduce the above
-*     copyright notice, this list of conditions and the following
-*     disclaimer in the documentation and/or other materials provided
-*     with the distribution.
-*   * Neither the name of Willow Garage, Inc. nor the names of its
-*     contributors may be used to endorse or promote products derived
-*     from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-*  POSSIBILITY OF SUCH DAMAGE.
-*
-*
-*/
+ * Software License Agreement (BSD License)
+ *
+ *  Copyright (c) 2010, Willow Garage, Inc.
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Willow Garage, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
 #ifndef PCL_MODELER_PARAMETER_IMPL_H_
 #define PCL_MODELER_PARAMETER_IMPL_H_
 
 #include <pcl/apps/modeler/parameter.h>
 
+namespace pcl {
+namespace modeler {
 
-namespace pcl
-{
-  namespace modeler
-  {
 //////////////////////////////////////////////////////////////////////////////////////////////
-    template <class T> std::string
-    EnumParameter<T>::valueTip()
-    {
-      std::string tip("possible values: {");
-      typename std::map<T, std::string>::const_iterator it = candidates_.begin();
-      do
-      {
-        tip += it->second;
-        ++ it;
-        if (it != candidates_.end())
-          tip += ", ";
-      } while(it != candidates_.end());
-      tip += "}";
+template <class T>
+std::string
+EnumParameter<T>::valueTip()
+{
+  std::string tip("possible values: {");
+  typename std::map<T, std::string>::const_iterator it = candidates_.begin();
+  do {
+    tip += it->second;
+    ++it;
+    if (it != candidates_.end())
+      tip += ", ";
+  } while (it != candidates_.end());
+  tip += "}";
 
-      return (tip);
-    }
+  return tip;
+}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-    template <class T> QWidget *
-    EnumParameter<T>::createEditor(QWidget *parent)
-    {
-      QComboBox* editor = new QComboBox(parent);
-      for (typename std::map<T, std::string>::const_iterator it = candidates_.begin();
-        it != candidates_.end();
-        ++ it)
-      {
-          editor->addItem(it->second.c_str());
-      }
+template <class T>
+QWidget*
+EnumParameter<T>::createEditor(QWidget* parent)
+{
+  QComboBox* editor = new QComboBox(parent);
+  for (typename std::map<T, std::string>::const_iterator it = candidates_.begin();
+       it != candidates_.end();
+       ++it) {
+    editor->addItem(it->second.c_str());
+  }
 
-      return (editor);
-    }
+  return editor;
+}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-    template <class T> void
-    EnumParameter<T>::setEditorData(QWidget *editor)
-    {
-      QComboBox *comboBox = static_cast<QComboBox*>(editor);
+template <class T>
+void
+EnumParameter<T>::setEditorData(QWidget* editor)
+{
+  QComboBox* comboBox = static_cast<QComboBox*>(editor);
 
-      T value = T (*this);
-      comboBox->setCurrentIndex(value);
-    }
+  T value = T(*this);
+  comboBox->setCurrentIndex(value);
+}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-    template <class T> void
-    EnumParameter<T>::getEditorData(QWidget *editor)
-    {
-      QComboBox *comboBox = static_cast<QComboBox*>(editor);
-      T value = T (comboBox->currentIndex());
-      current_value_ = value;
-    }
+template <class T>
+void
+EnumParameter<T>::getEditorData(QWidget* editor)
+{
+  QComboBox* comboBox = static_cast<QComboBox*>(editor);
+  T value = T(comboBox->currentIndex());
+  current_value_ = value;
+}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-    template <class T> std::pair<QVariant, int>
-    EnumParameter<T>::toModelData()
-    {
-      std::pair<QVariant, int> model_data;
-      for (typename std::map<T, std::string>::const_iterator it = candidates_.begin();
-        it != candidates_.end();
-        ++ it) 
-      {
-        if (it->first == value)
-        {
-          model_data.first = it->second;
-          break;
-        }
-      }
-      model_data.second = Qt::EditRole;
-
-      return (model_data);
+template <class T>
+std::pair<QVariant, int>
+EnumParameter<T>::toModelData()
+{
+  std::pair<QVariant, int> model_data;
+  for (typename std::map<T, std::string>::const_iterator it = candidates_.begin();
+       it != candidates_.end();
+       ++it) {
+    if (it->first == value) {
+      model_data.first = it->second;
+      break;
     }
   }
+  model_data.second = Qt::EditRole;
+
+  return model_data;
 }
 
+} // namespace modeler
+} // namespace pcl
+
 #endif // PCL_MODELER_PARAMETER_IMPL_H_
index 49821584c0d92221e7d7158eb5c55829fadd8717..563ee52abf8c881165c0125915d6ed568a7657c5 100755 (executable)
 
 #include <pcl/apps/modeler/scene_tree.h>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    /////////////////////////////////////////////////////////////////////////////////////////////
-    template <class T> QList<T*>
-    pcl::modeler::SceneTree::selectedTypeItems() const
-    {
-       QList<QTreeWidgetItem*> selected_items = selectedItems();
-       QList<T*> selected_t_items;
-       for (auto &selected_item : selected_items)
-       {
-         T* t_item = dynamic_cast<T*>(selected_item);
-         if(t_item != nullptr)
-           selected_t_items.push_back(t_item);
-       }
+namespace pcl {
+namespace modeler {
 
-       return (selected_t_items);
-    }
+/////////////////////////////////////////////////////////////////////////////////////////////
+template <class T>
+QList<T*>
+pcl::modeler::SceneTree::selectedTypeItems() const
+{
+  QList<QTreeWidgetItem*> selected_items = selectedItems();
+  QList<T*> selected_t_items;
+  for (auto& selected_item : selected_items) {
+    T* t_item = dynamic_cast<T*>(selected_item);
+    if (t_item != nullptr)
+      selected_t_items.push_back(t_item);
   }
+
+  return selected_t_items;
 }
 
+} // namespace modeler
+} // namespace pcl
 
 #endif // PCL_MODELER_SCENE_TREE_IMPL_H_
index cfb5858e30d18041018bb66d5962a1e70099d656..5a5cb57f0e2d6b0756eb6d7b9c9326ae901887c2 100755 (executable)
 
 #include <memory>
 
-namespace pcl
-{
-  namespace modeler
+namespace pcl {
+namespace modeler {
+
+class SceneTree;
+class AbstractItem;
+
+class MainWindow : public QMainWindow {
+  Q_OBJECT
+
+public:
+  static MainWindow&
+  getInstance()
   {
-    class SceneTree;
-    class AbstractItem;
-
-    class MainWindow : public QMainWindow
-    {
-      Q_OBJECT
-
-      public:
-        static MainWindow& getInstance() {
-          static MainWindow theSingleton;
-          return theSingleton;
-        }
-
-        QString 
-        getRecentFolder();
-
-        RenderWindowItem*
-        createRenderWindow();
-
-      public Q_SLOTS:
-        // slots for file menu
-        void 
-        slotOpenProject();
-        void 
-        slotSaveProject();
-        void 
-        slotCloseProject();
-        void 
-        slotExit();
-        void
-        slotUpdateRecentFile(const QString& filename);
-
-        // slots for view menu
-        void
-        slotCreateRenderWindow();
-
-        void
-        slotOnWorkerStarted();
-
-        void
-        slotOnWorkerFinished();
-
-      private:
-        // methods for file Menu
-        void 
-        connectFileMenuActions();
-        void 
-        createRecentPointCloudActions();
-        void 
-        updateRecentPointCloudActions();
-        void 
-        createRecentProjectActions();
-        void 
-        updateRecentProjectActions();
-        bool 
-        openProjectImpl(const QString& filename);
-        static void 
-        updateRecentActions(std::vector<std::shared_ptr<QAction>>& recent_actions, QStringList& recent_items);
-
-        // methods for view menu
-        void 
-        connectViewMenuActions();
-
-        // methods for edit menu
-        void 
-        connectEditMenuActions();
-
-        // methods for global settings
-        void 
-        loadGlobalSettings();
-        void 
-        saveGlobalSettings();
-
-      private Q_SLOTS:
-        void 
-        slotOpenRecentPointCloud();
-        void 
-        slotOpenRecentProject();
-
-      private:
-        friend class AbstractItem;
-
-        MainWindow();
-        MainWindow(const MainWindow &) = delete;
-        MainWindow& operator=(const MainWindow &) = delete;
-        ~MainWindow();
-
-        Ui::MainWindow                    *ui_; // Designer form
-
-        // shortcuts for recent point clouds/projects
-        QStringList                       recent_files_;
-        QStringList                       recent_projects_;
-        static const std::size_t               MAX_RECENT_NUMBER = 8;
-        std::vector<std::shared_ptr<QAction>>  recent_pointcloud_actions_;
-        std::vector<std::shared_ptr<QAction>>  recent_project_actions_;
-    };
+    static MainWindow theSingleton;
+    return theSingleton;
   }
-}
+
+  QString
+  getRecentFolder();
+
+  RenderWindowItem*
+  createRenderWindow();
+
+public Q_SLOTS:
+  // slots for file menu
+  void
+  slotOpenProject();
+  void
+  slotSaveProject();
+  void
+  slotCloseProject();
+  void
+  slotExit();
+  void
+  slotUpdateRecentFile(const QString& filename);
+
+  // slots for view menu
+  void
+  slotCreateRenderWindow();
+
+  void
+  slotOnWorkerStarted();
+
+  void
+  slotOnWorkerFinished();
+
+private:
+  // methods for file Menu
+  void
+  connectFileMenuActions();
+  void
+  createRecentPointCloudActions();
+  void
+  updateRecentPointCloudActions();
+  void
+  createRecentProjectActions();
+  void
+  updateRecentProjectActions();
+  bool
+  openProjectImpl(const QString& filename);
+  static void
+  updateRecentActions(std::vector<std::shared_ptr<QAction>>& recent_actions,
+                      QStringList& recent_items);
+
+  // methods for view menu
+  void
+  connectViewMenuActions();
+
+  // methods for edit menu
+  void
+  connectEditMenuActions();
+
+  // methods for global settings
+  void
+  loadGlobalSettings();
+  void
+  saveGlobalSettings();
+
+private Q_SLOTS:
+  void
+  slotOpenRecentPointCloud();
+  void
+  slotOpenRecentProject();
+
+private:
+  friend class AbstractItem;
+
+  MainWindow();
+  MainWindow(const MainWindow&) = delete;
+  MainWindow&
+  operator=(const MainWindow&) = delete;
+  ~MainWindow();
+
+  Ui::MainWindow* ui_; // Designer form
+
+  // shortcuts for recent point clouds/projects
+  QStringList recent_files_;
+  QStringList recent_projects_;
+  static const std::size_t MAX_RECENT_NUMBER = 8;
+  std::vector<std::shared_ptr<QAction>> recent_pointcloud_actions_;
+  std::vector<std::shared_ptr<QAction>> recent_project_actions_;
+};
+
+} // namespace modeler
+} // namespace pcl
index 79f69ce0cc70fafe009ce15807e9e841a0f7fb79..de9fa97f60c34052e18d335c6380ee049b981f9a 100755 (executable)
 
 #include <pcl/apps/modeler/abstract_worker.h>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class DoubleParameter;
+namespace pcl {
+namespace modeler {
 
-    class NormalEstimationWorker : public AbstractWorker 
-    {
-      public:
-        NormalEstimationWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent = nullptr);
-        ~NormalEstimationWorker();
+class DoubleParameter;
 
-      protected:
-        std::string
-        getName () const override { return ("Normal Estimation"); }
+class NormalEstimationWorker : public AbstractWorker {
+public:
+  NormalEstimationWorker(const QList<CloudMeshItem*>& cloud_mesh_items,
+                         QWidget* parent = nullptr);
+  ~NormalEstimationWorker();
 
-        void
-        initParameters(CloudMeshItem* cloud_mesh_item) override;
+protected:
+  std::string
+  getName() const override
+  {
+    return "Normal Estimation";
+  }
 
-        void
-        setupParameters() override;
+  void
+  initParameters(CloudMeshItem* cloud_mesh_item) override;
 
-        void
-        processImpl(CloudMeshItem* cloud_mesh_item) override;
+  void
+  setupParameters() override;
 
-      private:
-        double x_min_, x_max_;
-        double y_min_, y_max_;
-        double z_min_, z_max_;
+  void
+  processImpl(CloudMeshItem* cloud_mesh_item) override;
 
-        DoubleParameter* search_radius_;
-    };
+private:
+  double x_min_, x_max_;
+  double y_min_, y_max_;
+  double z_min_, z_max_;
 
-  }
-}
+  DoubleParameter* search_radius_;
+};
 
+} // namespace modeler
+} // namespace pcl
index 780363ed781176aa34e3f73a3f8aa6569c57f835..94e3221fe0580fc146e2466186a33d8ed841891d 100755 (executable)
 
 class vtkIdTypeArray;
 
-namespace pcl
-{
-  namespace modeler
+namespace pcl {
+namespace modeler {
+
+class NormalsActorItem : public ChannelActorItem {
+public:
+  NormalsActorItem(QTreeWidgetItem* parent,
+                   const CloudMesh::Ptr& cloud_mesh,
+                   const vtkSmartPointer<vtkRenderWindow>& render_window);
+  ~NormalsActorItem();
+
+  std::string
+  getItemName() const override
   {
-    class NormalsActorItem : public ChannelActorItem
-    {
-      public:
-        NormalsActorItem(QTreeWidgetItem* parent,
-                        const CloudMesh::Ptr& cloud_mesh,
-                        const vtkSmartPointer<vtkRenderWindow>& render_window);
-        ~NormalsActorItem ();
+    return "Points Actor Item";
+  }
 
-        std::string
-        getItemName() const override {return "Points Actor Item";}
+protected:
+  void
+  createNormalLines();
 
-      protected:
-        void
-        createNormalLines();
+  void
+  initImpl() override;
 
-        void
-        initImpl() override;
+  void
+  updateImpl() override;
 
-        void
-        updateImpl() override;
+  void
+  prepareContextMenu(QMenu* menu) const override;
 
-        void
-        prepareContextMenu(QMenu* menu) const override;
+  void
+  prepareProperties(ParameterDialog* parameter_dialog) override;
 
-        void
-        prepareProperties(ParameterDialog* parameter_dialog) override;
+  void
+  setProperties() override;
 
-        void
-        setProperties() override;
+private:
+  double level_;
+  double scale_;
+};
 
-      private:
-        double    level_;
-        double    scale_;
-    };
-  }
-}
+} // namespace modeler
+} // namespace pcl
index 52aa3b47270478b8cc4f5ec9dab888762e7bc1b1..58a12e98166078707d2a40e685b63a4205dc8d96 100755 (executable)
 /*
-* Software License Agreement (BSD License)
-*
-*  Copyright (c) 2010, Willow Garage, Inc.
-*  All rights reserved.
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*   * Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*   * Redistributions in binary form must reproduce the above
-*     copyright notice, this list of conditions and the following
-*     disclaimer in the documentation and/or other materials provided
-*     with the distribution.
-*   * Neither the name of Willow Garage, Inc. nor the names of its
-*     contributors may be used to endorse or promote products derived
-*     from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-*  POSSIBILITY OF SUCH DAMAGE.
-*
-*
-*/
+ * Software License Agreement (BSD License)
+ *
+ *  Copyright (c) 2010, Willow Garage, Inc.
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Willow Garage, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
 
 #pragma once
 
-#include <map>
-#include <string>
-
 #include <boost/any.hpp>
 
 #include <QColor>
 #include <QVariant>
 
+#include <map>
+#include <string>
+
 class QAbstractItemModel;
 class QWidget;
 
-namespace pcl
-{
-  namespace modeler
+namespace pcl {
+namespace modeler {
+
+class Parameter {
+public:
+  Parameter(const std::string& name,
+            const std::string& description,
+            const boost::any& value)
+  : name_(name), description_(description), default_value_(value), current_value_(value)
+  {}
+  ~Parameter() {}
+
+  const std::string&
+  getName() const
+  {
+    return name_;
+  }
+
+  const std::string&
+  getDescription() const
+  {
+    return description_;
+  }
+
+  void
+  setDefaultValue(const boost::any& value)
+  {
+    default_value_ = value;
+  }
+
+  void
+  reset()
   {
-    class Parameter
-    {
-      public:
-        Parameter(const std::string& name, const std::string& description, const boost::any& value):
-          name_(name), description_(description), default_value_(value), current_value_(value){}
-        ~Parameter() {}
+    current_value_ = default_value_;
+  }
 
-        const std::string&
-        getName() const {return name_;}
+  virtual std::string
+  valueTip() = 0;
 
-        const std::string&
-        getDescription()const {return description_;}
+  virtual QWidget*
+  createEditor(QWidget* parent) = 0;
 
-        void
-        setDefaultValue(const boost::any& value)
-        {
-          default_value_ = value;
-        }
+  virtual void
+  setEditorData(QWidget* editor) = 0;
 
-        void
-        reset() {current_value_ = default_value_;}
+  virtual void
+  setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index);
 
-        virtual std::string
-        valueTip() = 0;
-
-        virtual QWidget*
-        createEditor(QWidget *parent) = 0;
-
-        virtual void
-        setEditorData(QWidget *editor) = 0;
+  virtual std::pair<QVariant, int>
+  toModelData() = 0;
 
-        virtual void
-        setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index);
+protected:
+  virtual void
+  getEditorData(QWidget* editor) = 0;
 
-        virtual std::pair<QVariant, int>
-        toModelData() = 0;
+  std::string name_;
+  std::string description_;
+  boost::any default_value_;
+  boost::any current_value_;
+};
 
-      protected:
-        virtual void
-        getEditorData(QWidget *editor) = 0;
+class BoolParameter : public Parameter {
+public:
+  BoolParameter(const std::string& name, const std::string& description, bool value)
+  : Parameter(name, description, value)
+  {}
+  ~BoolParameter() {}
 
-        std::string     name_;
-        std::string     description_;
-        boost::any      default_value_;
-        boost::any      current_value_;
-    };
+  operator bool() const { return boost::any_cast<bool>(current_value_); }
 
-    class BoolParameter : public Parameter
-    {
-      public:
-        BoolParameter(const std::string& name, const std::string& description, bool value):
-            Parameter(name, description, value){}
-        ~BoolParameter(){}
+  std::string
+  valueTip() override;
 
-        operator bool() const {return boost::any_cast<bool>(current_value_);}
-
-        std::string
-        valueTip() override;
+  QWidget*
+  createEditor(QWidget* parent) override;
 
-        QWidget*
-        createEditor(QWidget *parent) override;
+  void
+  setEditorData(QWidget* editor) override;
 
-        void
-        setEditorData(QWidget *editor) override;
+  std::pair<QVariant, int>
+  toModelData() override;
 
-        std::pair<QVariant, int>
-        toModelData() override;
+protected:
+  void
+  getEditorData(QWidget* editor) override;
+};
 
-      protected:
-        void
-        getEditorData(QWidget *editor) override;
-    };
+class IntParameter : public Parameter {
+public:
+  IntParameter(const std::string& name,
+               const std::string& description,
+               int value,
+               int low,
+               int high,
+               int step = 1)
+  : Parameter(name, description, value), low_(low), high_(high), step_(step)
+  {}
+  virtual ~IntParameter() {}
 
-    class IntParameter : public Parameter
-    {
-      public:
-        IntParameter(const std::string& name, const std::string& description, int value, int low, int high, int step=1):
-          Parameter(name, description, value), low_(low), high_(high), step_(step){}
-        virtual ~IntParameter(){}
+  operator int() const { return boost::any_cast<int>(current_value_); }
 
-        operator int() const {return boost::any_cast<int>(current_value_);}
+  std::string
+  valueTip() override;
 
-        std::string
-        valueTip() override;
+  QWidget*
+  createEditor(QWidget* parent) override;
 
-        QWidget*
-        createEditor(QWidget *parent) override;
-
-        void
-        setEditorData(QWidget *editor) override;
+  void
+  setEditorData(QWidget* editor) override;
 
-        std::pair<QVariant, int>
-        toModelData() override;
+  std::pair<QVariant, int>
+  toModelData() override;
 
-        void
-        setLow(int low)
-        {
-          low_ = low;
-        }
-
-        void
-        setHigh(int high)
-        {
-          high_ = high;
-        }
+  void
+  setLow(int low)
+  {
+    low_ = low;
+  }
 
-        void
-        setStep(int step)
-        {
-          step_ = step;
-        }
+  void
+  setHigh(int high)
+  {
+    high_ = high;
+  }
 
-      protected:
-        void
-        getEditorData(QWidget *editor) override;
+  void
+  setStep(int step)
+  {
+    step_ = step;
+  }
 
-        int     low_;
-        int     high_;
-        int     step_;
-    };
+protected:
+  void
+  getEditorData(QWidget* editor) override;
 
-    template <class T>
-    class EnumParameter : public Parameter
-    {
-      public:
-        EnumParameter(const std::string& name, const std::string& description, T value, const std::map<T, std::string>& candidates):
-          Parameter(name, description, value), candidates_(candidates){}
-        ~EnumParameter(){}
+  int low_;
+  int high_;
+  int step_;
+};
 
-        operator T() const {return boost::any_cast<T>(current_value_);}
+template <class T>
+class EnumParameter : public Parameter {
+public:
+  EnumParameter(const std::string& name,
+                const std::string& description,
+                T value,
+                const std::map<T, std::string>& candidates)
+  : Parameter(name, description, value), candidates_(candidates)
+  {}
+  ~EnumParameter() {}
 
-        std::string
-        valueTip() override;
+  operator T() const { return boost::any_cast<T>(current_value_); }
 
-        QWidget*
-        createEditor(QWidget *parent) override;
+  std::string
+  valueTip() override;
 
-        void
-        setEditorData(QWidget *editor) override;
+  QWidget*
+  createEditor(QWidget* parent) override;
 
-        std::pair<QVariant, int>
-        toModelData() override;
+  void
+  setEditorData(QWidget* editor) override;
 
-      protected:
-        void
-        getEditorData(QWidget *editor) override;
+  std::pair<QVariant, int>
+  toModelData() override;
 
-        const std::map<T, std::string> candidates_;
-    };
+protected:
+  void
+  getEditorData(QWidget* editor) override;
 
-    class DoubleParameter : public Parameter
-    {
-      public:
-        DoubleParameter(const std::string& name, const std::string& description, double value, double low, double high, double step=0.01):
-          Parameter(name, description, value), low_(low), high_(high), step_(step){}
-        virtual ~DoubleParameter(){}
+  const std::map<T, std::string> candidates_;
+};
 
-        operator double() const {return boost::any_cast<double>(current_value_);}
+class DoubleParameter : public Parameter {
+public:
+  DoubleParameter(const std::string& name,
+                  const std::string& description,
+                  double value,
+                  double low,
+                  double high,
+                  double step = 0.01)
+  : Parameter(name, description, value), low_(low), high_(high), step_(step)
+  {}
+  virtual ~DoubleParameter() {}
 
-        std::string
-        valueTip() override;
+  operator double() const { return boost::any_cast<double>(current_value_); }
 
-        QWidget*
-        createEditor(QWidget *parent) override;
+  std::string
+  valueTip() override;
 
-        void
-        setEditorData(QWidget *editor) override;
+  QWidget*
+  createEditor(QWidget* parent) override;
 
-        std::pair<QVariant, int>
-        toModelData() override;
+  void
+  setEditorData(QWidget* editor) override;
 
-        void
-        setLow(double low)
-        {
-          low_ = low;
-        }
+  std::pair<QVariant, int>
+  toModelData() override;
 
-        void
-        setHigh(double high)
-        {
-          high_ = high;
-        }
+  void
+  setLow(double low)
+  {
+    low_ = low;
+  }
 
-        void
-        setStep(double step)
-        {
-          step_ = step;
-        }
-
-      protected:
-        void
-        getEditorData(QWidget *editor) override;
-
-        double  low_;
-        double  high_;
-        double  step_;
-    };
+  void
+  setHigh(double high)
+  {
+    high_ = high;
+  }
+
+  void
+  setStep(double step)
+  {
+    step_ = step;
+  }
 
-    class ColorParameter : public Parameter
-    {
-      public:
-        ColorParameter(const std::string& name, const std::string& description, const QColor& value):
-          Parameter(name, description, value){}
-        ~ColorParameter(){}
+protected:
+  void
+  getEditorData(QWidget* editor) override;
 
-        operator QColor() const {return boost::any_cast<QColor>(current_value_);}
+  double low_;
+  double high_;
+  double step_;
+};
 
-        std::string
-        valueTip() override;
+class ColorParameter : public Parameter {
+public:
+  ColorParameter(const std::string& name,
+                 const std::string& description,
+                 const QColor& value)
+  : Parameter(name, description, value)
+  {}
+  ~ColorParameter() {}
 
-        QWidget*
-        createEditor(QWidget *parent) override;
+  operator QColor() const { return boost::any_cast<QColor>(current_value_); }
 
-        void
-        setEditorData(QWidget *editor) override;
+  std::string
+  valueTip() override;
 
-        std::pair<QVariant, int>
-        toModelData() override;
+  QWidget*
+  createEditor(QWidget* parent) override;
 
-      protected:
-        void
-        getEditorData(QWidget *editor) override;
+  void
+  setEditorData(QWidget* editor) override;
 
-    };
-  }
-}
+  std::pair<QVariant, int>
+  toModelData() override;
+
+protected:
+  void
+  getEditorData(QWidget* editor) override;
+};
+
+} // namespace modeler
+} // namespace pcl
index 4fa57972b3eb8f85b52b8754d3a32df82601063e..6ee5f669ebd2a80a456f71ccc76d3be621cb88ac 100755 (executable)
@@ -1,38 +1,38 @@
 /*
-* Software License Agreement (BSD License)
-*
-*  Copyright (c) 2010, Willow Garage, Inc.
-*  All rights reserved.
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*   * Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*   * Redistributions in binary form must reproduce the above
-*     copyright notice, this list of conditions and the following
-*     disclaimer in the documentation and/or other materials provided
-*     with the distribution.
-*   * Neither the name of Willow Garage, Inc. nor the names of its
-*     contributors may be used to endorse or promote products derived
-*     from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-*  POSSIBILITY OF SUCH DAMAGE.
-*
-*
-*/
+ * Software License Agreement (BSD License)
+ *
+ *  Copyright (c) 2010, Willow Garage, Inc.
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Willow Garage, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
 
 #pragma once
 
 #include <QStandardItemModel>
 #include <QStyledItemDelegate>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class Parameter;
-
-    class ParameterModel: public QStandardItemModel
-    {
-      public: 
-        ParameterModel(QObject * parent = nullptr) : QStandardItemModel(parent){}
-        ParameterModel(int rows, int columns, QObject * parent = nullptr) : QStandardItemModel(rows, columns, parent){}
-        ~ParameterModel() {}
-
-        Qt::ItemFlags
-        flags ( const QModelIndex & index ) const override
-        {
-          return (index.column() == 0)?(Qt::ItemIsEnabled | Qt::ItemIsSelectable):QStandardItemModel::flags(index);
-        }
-    };
-
-    class ParameterDialog : public QDialog
-    {
-      Q_OBJECT
-      public:
-        ParameterDialog(const std::string& title, QWidget* parent=nullptr);
-        ~ParameterDialog(){}
-
-        void
-        addParameter(Parameter* parameter);
-
-        int
-        exec() override;
-
-      protected:
-        std::map<std::string, Parameter*>       name_parameter_map_;
-        ParameterModel*                         parameter_model_;
-
-      protected Q_SLOTS:
-        void
-        reset();
-    };
+namespace pcl {
+namespace modeler {
 
-    class ParameterDelegate : public QStyledItemDelegate
-    {
-      Q_OBJECT
-      public:
-        ParameterDelegate(std::map<std::string, Parameter*>& parameterMap, QObject *parent = nullptr);
+class Parameter;
 
-        QWidget *
-        createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
-
-        void
-        setEditorData(QWidget *editor, const QModelIndex &index) const override;
-
-        void
-        setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
-
-        void
-        updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
-
-      protected:
-        void
-        initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override;
-
-      private:
-        Parameter*
-        getCurrentParameter(const QModelIndex &index) const;
-
-        std::map<std::string, Parameter*>&      parameter_map_;
-    };
+class ParameterModel : public QStandardItemModel {
+public:
+  ParameterModel(QObject* parent = nullptr) : QStandardItemModel(parent) {}
+  ParameterModel(int rows, int columns, QObject* parent = nullptr)
+  : QStandardItemModel(rows, columns, parent)
+  {}
+  ~ParameterModel() {}
 
+  Qt::ItemFlags
+  flags(const QModelIndex& index) const override
+  {
+    return (index.column() == 0) ? (Qt::ItemIsEnabled | Qt::ItemIsSelectable)
+                                 : QStandardItemModel::flags(index);
   }
-}
+};
+
+class ParameterDialog : public QDialog {
+  Q_OBJECT
+public:
+  ParameterDialog(const std::string& title, QWidget* parent = nullptr);
+  ~ParameterDialog() {}
+
+  void
+  addParameter(Parameter* parameter);
+
+  int
+  exec() override;
+
+protected:
+  std::map<std::string, Parameter*> name_parameter_map_;
+  ParameterModel* parameter_model_;
+
+protected Q_SLOTS:
+  void
+  reset();
+};
+
+class ParameterDelegate : public QStyledItemDelegate {
+  Q_OBJECT
+public:
+  ParameterDelegate(std::map<std::string, Parameter*>& parameterMap,
+                    QObject* parent = nullptr);
+
+  QWidget*
+  createEditor(QWidget* parent,
+               const QStyleOptionViewItem& option,
+               const QModelIndex& index) const override;
+
+  void
+  setEditorData(QWidget* editor, const QModelIndex& index) const override;
+
+  void
+  setModelData(QWidget* editor,
+               QAbstractItemModel* model,
+               const QModelIndex& index) const override;
+
+  void
+  updateEditorGeometry(QWidget* editor,
+                       const QStyleOptionViewItem& option,
+                       const QModelIndex& index) const override;
+
+protected:
+  void
+  initStyleOption(QStyleOptionViewItem* option,
+                  const QModelIndex& index) const override;
+
+private:
+  Parameter*
+  getCurrentParameter(const QModelIndex& index) const;
+
+  std::map<std::string, Parameter*>& parameter_map_;
+};
+
+} // namespace modeler
+} // namespace pcl
index 8ffde6f7c51b4207292571c07eed5c10f6d23832..9c08e6c720ecee3383d83111b299d760af6c68f7 100755 (executable)
 
 class vtkIdTypeArray;
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class PointsActorItem : public ChannelActorItem
-    {
-      public:
-        PointsActorItem(QTreeWidgetItem* parent,
-                        const CloudMesh::Ptr& cloud_mesh,
-                        const vtkSmartPointer<vtkRenderWindow>& render_window);
-        ~PointsActorItem ();
+namespace pcl {
+namespace modeler {
 
-        std::string
-        getItemName() const override {return "Points Actor Item";}
+class PointsActorItem : public ChannelActorItem {
+public:
+  PointsActorItem(QTreeWidgetItem* parent,
+                  const CloudMesh::Ptr& cloud_mesh,
+                  const vtkSmartPointer<vtkRenderWindow>& render_window);
+  ~PointsActorItem();
 
-      protected:
-        void
-        initImpl() override;
+  std::string
+  getItemName() const override
+  {
+    return "Points Actor Item";
+  }
 
-        void
-        updateImpl() override;
+protected:
+  void
+  initImpl() override;
 
-        void
-        prepareContextMenu(QMenu* menu) const override;
+  void
+  updateImpl() override;
 
-        void
-        prepareProperties(ParameterDialog* parameter_dialog) override;
+  void
+  prepareContextMenu(QMenu* menu) const override;
 
-        void
-        setProperties() override;
+  void
+  prepareProperties(ParameterDialog* parameter_dialog) override;
 
-      private:
+  void
+  setProperties() override;
 
-    };
-  }
-}
+private:
+};
+
+} // namespace modeler
+} // namespace pcl
index 61ee899607894c0dd60adc1ed82c8d3a9b1de5be..d48d1b9610aeb7ff901c3bcacc14c406d33fd501 100755 (executable)
 
 #include <pcl/apps/modeler/abstract_worker.h>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class IntParameter;
-    class DoubleParameter;
+namespace pcl {
+namespace modeler {
 
-    class PoissonReconstructionWorker : public AbstractWorker 
-    {
-      public:
-        PoissonReconstructionWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent=nullptr);
-        ~PoissonReconstructionWorker();
+class IntParameter;
+class DoubleParameter;
 
-      protected:
-        std::string
-        getName () const override {return ("Poisson Reconstruction");}
+class PoissonReconstructionWorker : public AbstractWorker {
+public:
+  PoissonReconstructionWorker(const QList<CloudMeshItem*>& cloud_mesh_items,
+                              QWidget* parent = nullptr);
+  ~PoissonReconstructionWorker();
 
-        void
-        initParameters (CloudMeshItem*) override {}
+protected:
+  std::string
+  getName() const override
+  {
+    return "Poisson Reconstruction";
+  }
 
-        void
-        setupParameters() override;
+  void
+  initParameters(CloudMeshItem*) override
+  {}
 
-        void
-        processImpl(CloudMeshItem* cloud_mesh_item) override;
+  void
+  setupParameters() override;
 
-      private:
-        IntParameter*     depth_;
-        IntParameter*     solver_divide_;
-        IntParameter*     iso_divide_;
-        IntParameter*     degree_;
-        DoubleParameter*  scale_;
-        DoubleParameter*  samples_per_node_;
-    };
+  void
+  processImpl(CloudMeshItem* cloud_mesh_item) override;
 
-  }
-}
+private:
+  IntParameter* depth_;
+  IntParameter* solver_divide_;
+  IntParameter* iso_divide_;
+  IntParameter* degree_;
+  DoubleParameter* scale_;
+  DoubleParameter* samples_per_node_;
+};
+
+} // namespace modeler
+} // namespace pcl
index 763c3ca8c4b902fe6722269c3aa668338b7b85b5..b5f07a70be1eedb49521abcf5795f7379c58ca4e 100755 (executable)
 
 #pragma once
 
-#include <vtkSmartPointer.h>
-
 #include <QVTKWidget.h>
 
+#include <vtkSmartPointer.h>
+
 class vtkCubeAxesActor;
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class RenderWindowItem;
+namespace pcl {
+namespace modeler {
 
-    class RenderWindow : public QVTKWidget
-    {
-      public:
-        RenderWindow(RenderWindowItem* render_window_item, QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr);
-        ~RenderWindow();
+class RenderWindowItem;
 
-        QSize
-        sizeHint() const override {return {512, 512};}
+class RenderWindow : public QVTKWidget {
+public:
+  RenderWindow(RenderWindowItem* render_window_item,
+               QWidget* parent = nullptr,
+               Qt::WindowFlags flags = nullptr);
+  ~RenderWindow();
 
-        void
-        setActive(bool flag);
+  QSize
+  sizeHint() const override
+  {
+    return {512, 512};
+  }
 
-        void
-        setTitle(const QString& title);
+  void
+  setActive(bool flag);
 
-        void
-        render();
+  void
+  setTitle(const QString& title);
 
-        void
-        resetCamera();
+  void
+  render();
 
-        void
-        updateAxes();
+  void
+  resetCamera();
 
-        void
-        getBackground(double& r, double& g, double& b);
+  void
+  updateAxes();
 
-        void
-        setBackground(double r, double g, double b);
+  void
+  getBackground(double& r, double& g, double& b);
 
-        void
-        setShowAxes(bool flag);
+  void
+  setBackground(double r, double g, double b);
 
-      protected:
-        void
-        focusInEvent(QFocusEvent * event) override;
+  void
+  setShowAxes(bool flag);
 
-      private:
-        void
-        initRenderer();
+protected:
+  void
+  focusInEvent(QFocusEvent* event) override;
 
-        vtkSmartPointer<vtkCubeAxesActor>   axes_;
-        RenderWindowItem*     render_window_item_;
-    };
-  }
-}
+private:
+  void
+  initRenderer();
+
+  vtkSmartPointer<vtkCubeAxesActor> axes_;
+  RenderWindowItem* render_window_item_;
+};
+
+} // namespace modeler
+} // namespace pcl
index 7709f32e41d2689f9ea61d3d32444d42135641d3..bafdaa661778dcd6d68fb955374ea3bfb8d5aed5 100755 (executable)
@@ -1,4 +1,4 @@
- /*
+/*
  * Software License Agreement (BSD License)
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
 
 #pragma once
 
-#include <QTreeWidgetItem>
-
 #include <pcl/apps/modeler/abstract_item.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 
+#include <QTreeWidgetItem>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class RenderWindow;
-    class CloudMeshItem;
-    class ColorParameter;
-    class BoolParameter;
+namespace pcl {
+namespace modeler {
 
-    class RenderWindowItem : public QTreeWidgetItem, public AbstractItem
-    {
-      public:
-        RenderWindowItem(QTreeWidget * parent);
-        ~RenderWindowItem();
+class RenderWindow;
+class CloudMeshItem;
+class ColorParameter;
+class BoolParameter;
 
-        inline RenderWindow*
-        getRenderWindow()
-        {
-          return render_window_;
-        }
-        inline const RenderWindow*
-        getRenderWindow() const
-        {
-          return render_window_;
-        }
+class RenderWindowItem : public QTreeWidgetItem, public AbstractItem {
+public:
+  RenderWindowItem(QTreeWidget* parent);
+  ~RenderWindowItem();
 
-        bool
-        openPointCloud(const QString& filename);
+  inline RenderWindow*
+  getRenderWindow()
+  {
+    return render_window_;
+  }
+  inline const RenderWindow*
+  getRenderWindow() const
+  {
+    return render_window_;
+  }
+
+  bool
+  openPointCloud(const QString& filename);
+
+  CloudMeshItem*
+  addPointCloud(CloudMesh::PointCloudPtr cloud);
 
-        CloudMeshItem*
-        addPointCloud(CloudMesh::PointCloudPtr cloud);
+  std::string
+  getItemName() const override
+  {
+    return "Render Window Item";
+  }
 
-        std::string
-        getItemName() const override {return "Render Window Item";}
+protected:
+  void
+  prepareContextMenu(QMenu* menu) const override;
 
-      protected:
-        void
-        prepareContextMenu(QMenu* menu) const override;
+  void
+  prepareProperties(ParameterDialog* parameter_dialog) override;
 
-        void
-        prepareProperties(ParameterDialog* parameter_dialog) override;
+  void
+  setProperties() override;
 
-        void
-        setProperties() override;
+private:
+  RenderWindow* render_window_;
+  ColorParameter* background_color_;
+  BoolParameter* show_axes_;
+};
 
-      private:
-        RenderWindow*     render_window_;
-        ColorParameter*   background_color_;
-        BoolParameter*    show_axes_;
-    };
-  }
-}
+} // namespace modeler
+} // namespace pcl
index 82e4c99e63fbcd4c569273ab3f65e40093118adc..768761d65b943ce39a8eac6b92f5a0d7ca9a6029 100755 (executable)
 
 #include <QTreeWidget>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class CloudMeshItem;
-    class RenderWindowItem;
+namespace pcl {
+namespace modeler {
 
-    class SceneTree : public QTreeWidget
-    {
-      Q_OBJECT
+class CloudMeshItem;
+class RenderWindowItem;
 
-      public:
-        SceneTree(QWidget * parent = nullptr);
-        ~SceneTree();
+class SceneTree : public QTreeWidget {
+  Q_OBJECT
 
-        QSize
-        sizeHint() const override;
+public:
+  SceneTree(QWidget* parent = nullptr);
+  ~SceneTree();
 
-        bool 
-        openPointCloud(const QString& filename);
+  QSize
+  sizeHint() const override;
 
-        bool 
-        savePointCloud(const QString& filename);
+  bool
+  openPointCloud(const QString& filename);
 
-        void
-        selectRenderWindowItem(RenderWindowItem* render_window_item);
+  bool
+  savePointCloud(const QString& filename);
 
-        void
-        addTopLevelItem(RenderWindowItem* render_window_item);
+  void
+  selectRenderWindowItem(RenderWindowItem* render_window_item);
 
-      public Q_SLOTS:
-        // slots for file menu
-        void 
-        slotOpenPointCloud();
+  void
+  addTopLevelItem(RenderWindowItem* render_window_item);
 
-        void 
-        slotImportPointCloud();
+public Q_SLOTS:
+  // slots for file menu
+  void
+  slotOpenPointCloud();
 
-        void
-        slotSavePointCloud();
+  void
+  slotImportPointCloud();
 
-        void
-        slotClosePointCloud();
+  void
+  slotSavePointCloud();
 
-        // slots for edit menu
-        void
-        slotICPRegistration();
-        void
-        slotVoxelGridDownsampleFilter();
-        void
-        slotStatisticalOutlierRemovalFilter();
-        void
-        slotEstimateNormal();
-        void
-        slotPoissonReconstruction();
+  void
+  slotClosePointCloud();
 
-        // slots for view menu
-        void
-        slotCloseRenderWindow();
+  // slots for edit menu
+  void
+  slotICPRegistration();
+  void
+  slotVoxelGridDownsampleFilter();
+  void
+  slotStatisticalOutlierRemovalFilter();
+  void
+  slotEstimateNormal();
+  void
+  slotPoissonReconstruction();
 
-      Q_SIGNALS:
-        void
-        fileOpened(const QString& filename);
+  // slots for view menu
+  void
+  slotCloseRenderWindow();
 
-        void
-        itemInsertedOrRemoved();
+Q_SIGNALS:
+  void
+  fileOpened(const QString& filename);
 
-      protected:
-        void
-        dropEvent(QDropEvent * event) override;
+  void
+  itemInsertedOrRemoved();
 
-        bool
-        dropMimeData(QTreeWidgetItem * parent, int index, const QMimeData * data, Qt::DropAction action) override;
+protected:
+  void
+  dropEvent(QDropEvent* event) override;
 
-      private Q_SLOTS:
-        void
-        slotUpdateOnSelectionChange(const QItemSelection& selected, const QItemSelection& deselected);
+  bool
+  dropMimeData(QTreeWidgetItem* parent,
+               int index,
+               const QMimeData* data,
+               Qt::DropAction action) override;
 
-        void
-        slotUpdateOnInsertOrRemove();
+private Q_SLOTS:
+  void
+  slotUpdateOnSelectionChange(const QItemSelection& selected,
+                              const QItemSelection& deselected);
 
-        void
-        slotOnItemDoubleClicked(QTreeWidgetItem * item);
+  void
+  slotUpdateOnInsertOrRemove();
 
-      private:
-        template <class T> QList<T*>
-        selectedTypeItems() const;
+  void
+  slotOnItemDoubleClicked(QTreeWidgetItem* item);
 
-        QList<RenderWindowItem*>
-        selectedRenderWindowItems() const;
+private:
+  template <class T>
+  QList<T*>
+  selectedTypeItems() const;
 
-        static void
-        closePointCloud(const QList<CloudMeshItem*>& items);
+  QList<RenderWindowItem*>
+  selectedRenderWindowItems() const;
 
-        void
-        contextMenuEvent(QContextMenuEvent *event) override;
-    };
-  }
-}
+  static void
+  closePointCloud(const QList<CloudMeshItem*>& items);
+
+  void
+  contextMenuEvent(QContextMenuEvent* event) override;
+};
+
+} // namespace modeler
+} // namespace pcl
 
 #include <pcl/apps/modeler/impl/scene_tree.hpp>
index b71761612103d10637896727d213878265acd3a2..56d272033b7ff737ba48113086ae9025d6243931 100755 (executable)
 
 #include <pcl/apps/modeler/abstract_worker.h>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class IntParameter;
-    class DoubleParameter;
+namespace pcl {
+namespace modeler {
 
-    class StatisticalOutlierRemovalWorker : public AbstractWorker 
-    {
-      public:
-        StatisticalOutlierRemovalWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent=nullptr);
-        ~StatisticalOutlierRemovalWorker();
+class IntParameter;
+class DoubleParameter;
 
-      protected:
-        std::string
-        getName () const override {return ("Statistical Outlier Removal");}
+class StatisticalOutlierRemovalWorker : public AbstractWorker {
+public:
+  StatisticalOutlierRemovalWorker(const QList<CloudMeshItem*>& cloud_mesh_items,
+                                  QWidget* parent = nullptr);
+  ~StatisticalOutlierRemovalWorker();
 
-        void
-        initParameters(CloudMeshItem* cloud_mesh_item) override;
+protected:
+  std::string
+  getName() const override
+  {
+    return "Statistical Outlier Removal";
+  }
 
-        void
-        setupParameters() override;
+  void
+  initParameters(CloudMeshItem* cloud_mesh_item) override;
 
-        void
-        processImpl(CloudMeshItem* cloud_mesh_item) override;
+  void
+  setupParameters() override;
 
-      private:
-        IntParameter* mean_k_;
-        DoubleParameter* stddev_mul_thresh_;
+  void
+  processImpl(CloudMeshItem* cloud_mesh_item) override;
 
-    };
+private:
+  IntParameter* mean_k_;
+  DoubleParameter* stddev_mul_thresh_;
+};
 
-  }
-}
+} // namespace modeler
+} // namespace pcl
index e942641c0d0964f94408186cd328c284718df4c7..2ca3df238b04c1929b559356b562a1b6bb068aab 100755 (executable)
 
 class vtkIdTypeArray;
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class SurfaceActorItem : public ChannelActorItem
-    {
-      public:
-        using GeometryHandler = pcl::visualization::PointCloudGeometryHandler<pcl::PointSurfel>;
-        using GeometryHandlerPtr = GeometryHandler::Ptr;
-        using GeometryHandlerConstPtr = GeometryHandler::ConstPtr;
+namespace pcl {
+namespace modeler {
+
+class SurfaceActorItem : public ChannelActorItem {
+public:
+  using GeometryHandler =
+      pcl::visualization::PointCloudGeometryHandler<pcl::PointSurfel>;
+  using GeometryHandlerPtr = GeometryHandler::Ptr;
+  using GeometryHandlerConstPtr = GeometryHandler::ConstPtr;
+
+  using ColorHandler = pcl::visualization::PointCloudColorHandler<pcl::PointSurfel>;
+  using ColorHandlerPtr = ColorHandler::Ptr;
+  using ColorHandlerConstPtr = ColorHandler::ConstPtr;
 
-        using ColorHandler = pcl::visualization::PointCloudColorHandler<pcl::PointSurfel>;
-        using ColorHandlerPtr = ColorHandler::Ptr;
-        using ColorHandlerConstPtr = ColorHandler::ConstPtr;
+  SurfaceActorItem(QTreeWidgetItem* parent,
+                   const CloudMesh::Ptr& cloud_mesh,
+                   const vtkSmartPointer<vtkRenderWindow>& render_window);
+  ~SurfaceActorItem();
 
-        SurfaceActorItem(QTreeWidgetItem* parent,
-                        const CloudMesh::Ptr& cloud_mesh,
-                        const vtkSmartPointer<vtkRenderWindow>& render_window);
-        ~SurfaceActorItem ();
+  std::string
+  getItemName() const override
+  {
+    return "Points Actor Item";
+  }
 
-        std::string
-        getItemName() const override {return "Points Actor Item";}
+protected:
+  void
+  initImpl() override;
 
-      protected:
-        void
-        initImpl() override;
+  void
+  updateImpl() override;
 
-        void
-        updateImpl() override;
+  void
+  prepareContextMenu(QMenu* menu) const override;
 
-        void
-        prepareContextMenu(QMenu* menu) const override;
+  void
+  prepareProperties(ParameterDialog* parameter_dialog) override;
 
-        void
-        prepareProperties(ParameterDialog* parameter_dialog) override;
+  void
+  setProperties() override;
 
-        void
-        setProperties() override;
+private:
+};
 
-      private:
-    };
-  }
-}
+} // namespace modeler
+} // namespace pcl
index 5326bcb2c78763c7b0d0bb36b6fa495cbcadd127..df98cbe36f48eea9ac447dc4a0bd06aa56610bb9 100755 (executable)
 
 #include <QObject>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class CloudMeshItem;
-    class AbstractWorker;
+namespace pcl {
+namespace modeler {
 
-    class ThreadController : public QObject
-    {
-      Q_OBJECT
+class CloudMeshItem;
+class AbstractWorker;
 
-      public:
-        ThreadController();
-        ~ThreadController();
+class ThreadController : public QObject {
+  Q_OBJECT
 
-        bool
-        runWorker(AbstractWorker* worker);
+public:
+  ThreadController();
+  ~ThreadController();
 
-      Q_SIGNALS:
-        void
-        prepared();
+  bool
+  runWorker(AbstractWorker* worker);
 
-      private Q_SLOTS:
-        void
-        slotOnCloudMeshItemUpdate(CloudMeshItem* cloud_mesh_item);
-    };
+Q_SIGNALS:
+  void
+  prepared();
 
-  }
-}
+private Q_SLOTS:
+  void
+  slotOnCloudMeshItemUpdate(CloudMeshItem* cloud_mesh_item);
+};
+
+} // namespace modeler
+} // namespace pcl
index f2ded2c2e188ffabdc0987374136cbb262f530ce..c68cbb13e56e4ccfa27473f1d1cd3da7c3db48d8 100755 (executable)
 
 #include <pcl/apps/modeler/abstract_worker.h>
 
-namespace pcl
-{
-  namespace modeler
-  {
-    class DoubleParameter;
+namespace pcl {
+namespace modeler {
 
-    class VoxelGridDownampleWorker : public AbstractWorker 
-    {
-      public:
-        VoxelGridDownampleWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent=nullptr);
-        ~VoxelGridDownampleWorker();
+class DoubleParameter;
 
-      protected:
-        std::string
-        getName () const override {return ("Down Sample");}
+class VoxelGridDownampleWorker : public AbstractWorker {
+public:
+  VoxelGridDownampleWorker(const QList<CloudMeshItem*>& cloud_mesh_items,
+                           QWidget* parent = nullptr);
+  ~VoxelGridDownampleWorker();
 
-        void
-        initParameters(CloudMeshItem* cloud_mesh_item) override;
+protected:
+  std::string
+  getName() const override
+  {
+    return "Down Sample";
+  }
 
-        void
-        setupParameters() override;
+  void
+  initParameters(CloudMeshItem* cloud_mesh_item) override;
 
-        void
-        processImpl(CloudMeshItem* cloud_mesh_item) override;
+  void
+  setupParameters() override;
 
-      private:
-        double x_min_, x_max_;
-        double y_min_, y_max_;
-        double z_min_, z_max_;
+  void
+  processImpl(CloudMeshItem* cloud_mesh_item) override;
 
-        DoubleParameter* leaf_size_x_;
-        DoubleParameter* leaf_size_y_;
-        DoubleParameter* leaf_size_z_;
+private:
+  double x_min_, x_max_;
+  double y_min_, y_max_;
+  double z_min_, z_max_;
 
-    };
+  DoubleParameter* leaf_size_x_;
+  DoubleParameter* leaf_size_y_;
+  DoubleParameter* leaf_size_z_;
+};
 
-  }
-}
+} // namespace modeler
+} // namespace pcl
index ef004f9883d8ac1957886bd3cb83ddc5b50e6a25..9c022c39d78ae34310b0358183f977dc0640baaf 100755 (executable)
  */
 
 #include <pcl/apps/modeler/abstract_item.h>
-
 #include <pcl/apps/modeler/main_window.h>
 #include <pcl/apps/modeler/parameter_dialog.h>
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::AbstractItem::AbstractItem()
-{
-
-}
+pcl::modeler::AbstractItem::AbstractItem() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::AbstractItem::~AbstractItem()
-{
-
-}
+pcl::modeler::AbstractItem::~AbstractItem() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -59,8 +51,6 @@ pcl::modeler::AbstractItem::showContextMenu(const QPoint* position)
   QMenu menu(&MainWindow::getInstance());
   prepareContextMenu(&menu);
   menu.exec(*position);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -74,7 +64,8 @@ pcl::modeler::AbstractItem::ui() const
 void
 pcl::modeler::AbstractItem::showPropertyEditor()
 {
-  ParameterDialog* parameter_dialog = new ParameterDialog(getItemName() + " Properties", &MainWindow::getInstance());
+  ParameterDialog* parameter_dialog =
+      new ParameterDialog(getItemName() + " Properties", &MainWindow::getInstance());
   prepareProperties(parameter_dialog);
 
   if (parameter_dialog->exec() == QDialog::Accepted)
index 7ba717af107eaf8189756f9af618bd03eb37c450..6619f3cfec4e7b237bbc570032560da00cb7287e 100755 (executable)
  */
 
 #include <pcl/apps/modeler/abstract_worker.h>
-
-#include <pcl/apps/modeler/parameter_dialog.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
-
+#include <pcl/apps/modeler/parameter_dialog.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::AbstractWorker::AbstractWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent) :
-  cloud_mesh_items_(cloud_mesh_items),
-  parameter_dialog_(new ParameterDialog(getName(), parent))
-{
-}
+pcl::modeler::AbstractWorker::AbstractWorker(
+    const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent)
+: cloud_mesh_items_(cloud_mesh_items)
+, parameter_dialog_(new ParameterDialog(getName(), parent))
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::AbstractWorker::~AbstractWorker()
-{
-  parameter_dialog_->deleteLater();
-}
+pcl::modeler::AbstractWorker::~AbstractWorker() { parameter_dialog_->deleteLater(); }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 int
 pcl::modeler::AbstractWorker::exec()
 {
-  for (auto &cloud_mesh_item : cloud_mesh_items_)
+  for (autocloud_mesh_item : cloud_mesh_items_)
     initParameters(cloud_mesh_item);
 
   setupParameters();
 
-  return (parameter_dialog_->exec());
+  return parameter_dialog_->exec();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::AbstractWorker::process()
 {
-  for (auto &cloud_mesh_item : cloud_mesh_items_)
-  {
+  for (auto& cloud_mesh_item : cloud_mesh_items_) {
     processImpl(cloud_mesh_item);
   }
 
   emit finished();
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
index 2a2568472a592b143f1b96cc7a2c644930851b6a..fb254279d49673b01650522e84977bff9aa65617 100755 (executable)
  */
 
 #include <pcl/apps/modeler/channel_actor_item.h>
+#include <pcl/apps/modeler/cloud_mesh.h>
+#include <pcl/point_cloud.h>
 
 #include <vtkCamera.h>
-#include <vtkPolyData.h>
-#include <vtkRenderer.h>
 #include <vtkMatrix4x4.h>
+#include <vtkPolyData.h>
 #include <vtkRenderWindow.h>
+#include <vtkRenderer.h>
 #include <vtkRendererCollection.h>
-#include <pcl/point_cloud.h>
-#include <pcl/apps/modeler/cloud_mesh.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ChannelActorItem::ChannelActorItem(QTreeWidgetItem* parent,
-  const CloudMesh::Ptr& cloud_mesh,
-  const vtkSmartPointer<vtkRenderWindow>& render_window,
-  const vtkSmartPointer<vtkActor>& actor,
-  const std::string& channel_name)
-  :QTreeWidgetItem(parent),
-  cloud_mesh_(cloud_mesh),
-  poly_data_(vtkSmartPointer<vtkPolyData>::New()),
-  render_window_(render_window),
-  color_scheme_("rgb"),
-  actor_(actor)
+pcl::modeler::ChannelActorItem::ChannelActorItem(
+    QTreeWidgetItem* parent,
+    const CloudMesh::Ptr& cloud_mesh,
+    const vtkSmartPointer<vtkRenderWindow>& render_window,
+    const vtkSmartPointer<vtkActor>& actor,
+    const std::string& channel_name)
+: QTreeWidgetItem(parent)
+, cloud_mesh_(cloud_mesh)
+, poly_data_(vtkSmartPointer<vtkPolyData>::New())
+, render_window_(render_window)
+, color_scheme_("rgb")
+, actor_(actor)
 {
-  setFlags(flags()&(~Qt::ItemIsDragEnabled));
-  setFlags(flags()&(~Qt::ItemIsDropEnabled));
+  setFlags(flags() & (~Qt::ItemIsDragEnabled));
+  setFlags(flags() & (~Qt::ItemIsDropEnabled));
 
   setText(0, QString(channel_name.c_str()));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ChannelActorItem::~ChannelActorItem ()
-{
-  detachActor();
-}
+pcl::modeler::ChannelActorItem::~ChannelActorItem() { detachActor(); }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -106,9 +104,7 @@ pcl::modeler::ChannelActorItem::detachActor()
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::ChannelActorItem::prepareContextMenu(QMenu*) const
-{
-
-}
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -117,6 +113,4 @@ pcl::modeler::ChannelActorItem::switchRenderWindow(vtkRenderWindow* render_windo
   detachActor();
   render_window_ = vtkSmartPointer<vtkRenderWindow>(render_window);
   attachActor();
-
-  return;
 }
index cd2d2b2f59f7c19c8f322b71513de902e28d3e8c..beb479949b3aebb2535967438e75f17a2e701937 100755 (executable)
  */
 
 #include <pcl/apps/modeler/cloud_mesh.h>
-
-#include <pcl/visualization/point_cloud_handlers.h>
-#include <pcl/filters/filter_indices.h>
 #include <pcl/common/transforms.h>
-#include <pcl/PolygonMesh.h>
-#include <pcl/io/pcd_io.h>
+#include <pcl/filters/filter_indices.h>
 #include <pcl/io/obj_io.h>
-#include <vtkDataArray.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/visualization/point_cloud_handlers.h>
+#include <pcl/PolygonMesh.h>
+
 #include <vtkCellArray.h>
+#include <vtkDataArray.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::CloudMesh::CloudMesh()
-  :vtk_points_(vtkSmartPointer<vtkPoints>::New()),
-  vtk_polygons_(vtkSmartPointer<vtkCellArray>::New())
+: vtk_points_(vtkSmartPointer<vtkPoints>::New())
+, vtk_polygons_(vtkSmartPointer<vtkCellArray>::New())
 {
   cloud_.reset(new pcl::PointCloud<pcl::PointSurfel>());
-  vtk_points_->SetDataTypeToFloat ();
+  vtk_points_->SetDataTypeToFloat();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::CloudMesh::CloudMesh(PointCloudPtr cloud)
-  :cloud_(std::move(cloud)),
-  vtk_points_(vtkSmartPointer<vtkPoints>::New()),
-  vtk_polygons_(vtkSmartPointer<vtkCellArray>::New())
+: cloud_(std::move(cloud))
+, vtk_points_(vtkSmartPointer<vtkPoints>::New())
+, vtk_polygons_(vtkSmartPointer<vtkCellArray>::New())
 {
-  vtk_points_->SetDataTypeToFloat ();
+  vtk_points_->SetDataTypeToFloat();
   updateVtkPoints();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMesh::~CloudMesh ()
-{
-}
+pcl::modeler::CloudMesh::~CloudMesh() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 std::vector<std::string>
 pcl::modeler::CloudMesh::getAvaiableFieldNames() const
 {
   // TODO:
-  return (std::vector<std::string>());
+  return {};
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -82,48 +80,45 @@ bool
 pcl::modeler::CloudMesh::open(const std::string& filename)
 {
   if (pcl::io::loadPCDFile(filename, *cloud_) != 0)
-    return (false);
+    return false;
 
   updateVtkPoints();
 
-  return (true);
+  return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 bool
 pcl::modeler::CloudMesh::save(const std::string& filename) const
 {
-  if (filename.rfind(".obj") == (filename.length()-4))
-  {
+  if (filename.rfind(".obj") == (filename.length() - 4)) {
     pcl::PolygonMesh polygon_mesh;
     pcl::toPCLPointCloud2(*cloud_, polygon_mesh.cloud);
     polygon_mesh.polygons = polygons_;
-    return (pcl::io::saveOBJFile(filename, polygon_mesh, true) == 0);
+    return pcl::io::saveOBJFile(filename, polygon_mesh, true) == 0;
   }
 
-  return (pcl::io::savePCDFile(filename, *cloud_, true) == 0);
+  return pcl::io::savePCDFile(filename, *cloud_, true) == 0;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 bool
-pcl::modeler::CloudMesh::save(const std::vector<const CloudMesh*>& cloud_meshes, const std::string& filename)
+pcl::modeler::CloudMesh::save(const std::vector<const CloudMesh*>& cloud_meshes,
+                              const std::string& filename)
 {
   if (cloud_meshes.empty())
     return false;
 
   if (cloud_meshes.size() == 1)
-    return (cloud_meshes[0]->save(filename));
+    return cloud_meshes[0]->save(filename);
 
   CloudMesh cloud_mesh;
-  for (const auto &mesh : cloud_meshes)
-  {
-    if (filename.rfind(".obj") == (filename.length()-4))
-    {
+  for (const auto& mesh : cloud_meshes) {
+    if (filename.rfind(".obj") == (filename.length() - 4)) {
       std::size_t delta = cloud_mesh.cloud_->size();
-      for (auto polygon : mesh->polygons_)
-      {
-        for (unsigned int &vertice : polygon.vertices)
-          vertice += static_cast<unsigned int> (delta);
+      for (auto polygon : mesh->polygons_) {
+        for (unsigned int& vertice : polygon.vertices)
+          vertice += static_cast<unsigned int>(delta);
         cloud_mesh.polygons_.push_back(polygon);
       }
     }
@@ -131,31 +126,29 @@ pcl::modeler::CloudMesh::save(const std::vector<const CloudMesh*>& cloud_meshes,
     *cloud_mesh.cloud_ += *(mesh->cloud_);
   }
 
-  return (cloud_mesh.save(filename));
+  return cloud_mesh.save(filename);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::CloudMesh::getColorScalarsFromField(vtkSmartPointer<vtkDataArray> &scalars, const std::string& field) const
+pcl::modeler::CloudMesh::getColorScalarsFromField(
+    vtkSmartPointer<vtkDataArray>& scalars, const std::string& field) const
 {
-  if (field == "rgb" || field == "rgba")
-  {
+  if (field == "rgb" || field == "rgba") {
     pcl::visualization::PointCloudColorHandlerRGBField<PointT> color_handler(cloud_);
     scalars = color_handler.getColor();
     return;
   }
 
-  if (field == "random")
-  {
+  if (field == "random") {
     pcl::visualization::PointCloudColorHandlerRandom<PointT> color_handler(cloud_);
     scalars = color_handler.getColor();
     return;
   }
 
-  pcl::visualization::PointCloudColorHandlerGenericField<PointT> color_handler(cloud_, field);
+  pcl::visualization::PointCloudColorHandlerGenericField<PointT> color_handler(cloud_,
+                                                                               field);
   scalars = color_handler.getColor();
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -163,43 +156,37 @@ void
 pcl::modeler::CloudMesh::updateVtkPoints()
 {
   if (vtk_points_->GetData() == nullptr)
-    vtk_points_->SetData(vtkSmartPointer<vtkFloatArray>::New ());
+    vtk_points_->SetData(vtkSmartPointer<vtkFloatArray>::New());
 
   vtkFloatArray* data = dynamic_cast<vtkFloatArray*>(vtk_points_->GetData());
-  data->SetNumberOfComponents (3);
+  data->SetNumberOfComponents(3);
 
   // If the dataset has no invalid values, just copy all of them
-  if (cloud_->is_dense)
-  {
-    vtkIdType nr_points = cloud_->points.size ();
-    data->SetNumberOfValues(3*nr_points);
-
-    for (vtkIdType i = 0; i < nr_points; ++i)
-    {
-      data->SetValue(i*3+0, cloud_->points[i].x);
-      data->SetValue(i*3+1, cloud_->points[i].y);
-      data->SetValue(i*3+2, cloud_->points[i].z);
+  if (cloud_->is_dense) {
+    vtkIdType nr_points = cloud_->points.size();
+    data->SetNumberOfValues(3 * nr_points);
+
+    for (vtkIdType i = 0; i < nr_points; ++i) {
+      data->SetValue(i * 3 + 0, cloud_->points[i].x);
+      data->SetValue(i * 3 + 1, cloud_->points[i].y);
+      data->SetValue(i * 3 + 2, cloud_->points[i].z);
     }
   }
   // Need to check for NaNs, Infs, ec
-  else
-  {
+  else {
     pcl::IndicesPtr indices(new std::vector<int>());
     pcl::removeNaNFromPointCloud(*cloud_, *indices);
 
-    data->SetNumberOfValues(3*indices->size());
+    data->SetNumberOfValues(3 * indices->size());
 
-    for (vtkIdType i = 0, i_end = indices->size(); i < i_end; ++i)
-    {
+    for (vtkIdType i = 0, i_end = indices->size(); i < i_end; ++i) {
       vtkIdType idx = (*indices)[i];
-      data->SetValue(i*3+0, cloud_->points[idx].x);
-      data->SetValue(i*3+1, cloud_->points[idx].y);
-      data->SetValue(i*3+2, cloud_->points[idx].z);
+      data->SetValue(i * 3 + 0, cloud_->points[idx].x);
+      data->SetValue(i * 3 + 1, cloud_->points[idx].y);
+      data->SetValue(i * 3 + 2, cloud_->points[idx].z);
     }
   }
   data->Squeeze();
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -208,34 +195,29 @@ pcl::modeler::CloudMesh::updateVtkPolygons()
 {
   vtk_polygons_->Reset();
 
-  if (cloud_->is_dense)
-  {
-    for (const auto &polygon : polygons_)
-    {
-      vtk_polygons_->InsertNextCell (polygon.vertices.size());
-      for (const unsigned int &vertex : polygon.vertices)
-        vtk_polygons_->InsertCellPoint (vertex);
+  if (cloud_->is_dense) {
+    for (const auto& polygon : polygons_) {
+      vtk_polygons_->InsertNextCell(polygon.vertices.size());
+      for (const unsigned int& vertex : polygon.vertices)
+        vtk_polygons_->InsertCellPoint(vertex);
     }
   }
-  else
-  {
+  else {
     pcl::IndicesPtr indices(new std::vector<int>());
     pcl::removeNaNFromPointCloud(*cloud_, *indices);
 
-    for (const auto &polygon : polygons_)
-    {
-      vtk_polygons_->InsertNextCell (polygon.vertices.size());
-         for (const unsigned int &vertex : polygon.vertices)
-        vtk_polygons_->InsertCellPoint ((*indices)[vertex]);
+    for (const auto& polygon : polygons_) {
+      vtk_polygons_->InsertNextCell(polygon.vertices.size());
+      for (const unsigned int& vertex : polygon.vertices)
+        vtk_polygons_->InsertCellPoint((*indices)[vertex]);
     }
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::CloudMesh::transform(double tx, double ty, double tz, double rx, double ry, double rz)
+pcl::modeler::CloudMesh::transform(
+    double tx, double ty, double tz, double rx, double ry, double rz)
 {
   Eigen::Vector4f centroid;
   pcl::compute3DCentroid(*cloud_, centroid);
@@ -243,15 +225,15 @@ pcl::modeler::CloudMesh::transform(double tx, double ty, double tz, double rx, d
   CloudMesh::PointCloud mean_cloud = *cloud_;
   pcl::demeanPointCloud(*cloud_, centroid, mean_cloud);
 
-  rx *= M_PI/180;
-  ry *= M_PI/180;
-  rz *= M_PI/180;
-  Eigen::Affine3f affine_transform = pcl::getTransformation (float (tx), float (ty), float (tz), float (rx), float (ry), float (rz));
+  rx *= M_PI / 180;
+  ry *= M_PI / 180;
+  rz *= M_PI / 180;
+  Eigen::Affine3f affine_transform = pcl::getTransformation(
+      float(tx), float(ty), float(tz), float(rx), float(ry), float(rz));
   CloudMesh::PointCloud transform_cloud = mean_cloud;
-  pcl::transformPointCloudWithNormals(mean_cloud, transform_cloud, affine_transform.matrix());
+  pcl::transformPointCloudWithNormals(
+      mean_cloud, transform_cloud, affine_transform.matrix());
 
   centroid = -centroid;
   pcl::demeanPointCloud(transform_cloud, centroid, *cloud_);
-
-  return;
 }
index 14fb6b4f2f0e49af7c41a27d67f8d714d9ec21d8..30905030802a886a73e3340ff75355a536cd5903 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/cloud_mesh_item.h>
-#include <pcl/apps/modeler/render_window.h>
-#include <pcl/apps/modeler/render_window_item.h>
-#include <pcl/apps/modeler/points_actor_item.h>
-#include <pcl/apps/modeler/normals_actor_item.h>
-#include <pcl/apps/modeler/surface_actor_item.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
+#include <pcl/apps/modeler/cloud_mesh_item.h>
 #include <pcl/apps/modeler/main_window.h>
+#include <pcl/apps/modeler/normals_actor_item.h>
 #include <pcl/apps/modeler/parameter.h>
 #include <pcl/apps/modeler/parameter_dialog.h>
+#include <pcl/apps/modeler/points_actor_item.h>
+#include <pcl/apps/modeler/render_window.h>
+#include <pcl/apps/modeler/render_window_item.h>
+#include <pcl/apps/modeler/surface_actor_item.h>
 #include <pcl/common/common.h>
-#include <vtkRenderWindow.h>
 
+#include <vtkRenderWindow.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMeshItem::CloudMeshItem (QTreeWidgetItem* parent, const std::string& filename)
-  :QTreeWidgetItem(parent),
-  filename_(filename),
-  cloud_mesh_(new CloudMesh),
-  translation_x_(new DoubleParameter("Translation X", "Translation X", 0.0, -1.0, 1.0)),
-  translation_y_(new DoubleParameter("Translation Y", "Translation Y", 0.0, -1.0, 1.0)),
-  translation_z_(new DoubleParameter("Translation Z", "Translation Z", 0.0, -1.0, 1.0)),
-  rotation_x_(new DoubleParameter("Rotation X", "Rotation X", 0.0, -180.0, 180.0)),
-  rotation_y_(new DoubleParameter("Rotation Y", "Rotation Y", 0.0, -180.0, 180.0)),
-  rotation_z_(new DoubleParameter("Rotation Z", "Rotation Z", 0.0, -180.0, 180.0))
+pcl::modeler::CloudMeshItem::CloudMeshItem(QTreeWidgetItem* parent,
+                                           const std::string& filename)
+: QTreeWidgetItem(parent)
+, filename_(filename)
+, cloud_mesh_(new CloudMesh)
+, translation_x_(new DoubleParameter("Translation X", "Translation X", 0.0, -1.0, 1.0))
+, translation_y_(new DoubleParameter("Translation Y", "Translation Y", 0.0, -1.0, 1.0))
+, translation_z_(new DoubleParameter("Translation Z", "Translation Z", 0.0, -1.0, 1.0))
+, rotation_x_(new DoubleParameter("Rotation X", "Rotation X", 0.0, -180.0, 180.0))
+, rotation_y_(new DoubleParameter("Rotation Y", "Rotation Y", 0.0, -180.0, 180.0))
+, rotation_z_(new DoubleParameter("Rotation Z", "Rotation Z", 0.0, -180.0, 180.0))
 {
-  setFlags(flags()&(~Qt::ItemIsDropEnabled));
+  setFlags(flags() & (~Qt::ItemIsDropEnabled));
   setText(0, QString(filename.c_str()));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMeshItem::CloudMeshItem (QTreeWidgetItem* parent, CloudMesh::PointCloudPtr cloud)
-  :QTreeWidgetItem(parent),
-  filename_("unnamed point cloud"),
-  cloud_mesh_(new CloudMesh (std::move(cloud))),
-  translation_x_(new DoubleParameter("Translation X", "Translation X", 0.0, -1.0, 1.0)),
-  translation_y_(new DoubleParameter("Translation Y", "Translation Y", 0.0, -1.0, 1.0)),
-  translation_z_(new DoubleParameter("Translation Z", "Translation Z", 0.0, -1.0, 1.0)),
-  rotation_x_(new DoubleParameter("Rotation X", "Rotation X", 0.0, -180.0, 180.0)),
-  rotation_y_(new DoubleParameter("Rotation Y", "Rotation Y", 0.0, -180.0, 180.0)),
-  rotation_z_(new DoubleParameter("Rotation Z", "Rotation Z", 0.0, -180.0, 180.0))
+pcl::modeler::CloudMeshItem::CloudMeshItem(QTreeWidgetItem* parent,
+                                           CloudMesh::PointCloudPtr cloud)
+: QTreeWidgetItem(parent)
+, filename_("unnamed point cloud")
+, cloud_mesh_(new CloudMesh(std::move(cloud)))
+, translation_x_(new DoubleParameter("Translation X", "Translation X", 0.0, -1.0, 1.0))
+, translation_y_(new DoubleParameter("Translation Y", "Translation Y", 0.0, -1.0, 1.0))
+, translation_z_(new DoubleParameter("Translation Z", "Translation Z", 0.0, -1.0, 1.0))
+, rotation_x_(new DoubleParameter("Rotation X", "Rotation X", 0.0, -180.0, 180.0))
+, rotation_y_(new DoubleParameter("Rotation Y", "Rotation Y", 0.0, -180.0, 180.0))
+, rotation_z_(new DoubleParameter("Rotation Z", "Rotation Z", 0.0, -180.0, 180.0))
 {
-  setFlags(flags()&(~Qt::ItemIsDropEnabled));
+  setFlags(flags() & (~Qt::ItemIsDropEnabled));
   setText(0, QString(filename_.c_str()));
 
   createChannels();
@@ -85,18 +87,19 @@ pcl::modeler::CloudMeshItem::CloudMeshItem (QTreeWidgetItem* parent, CloudMesh::
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMeshItem::CloudMeshItem(QTreeWidgetItem* parent,  const CloudMeshItem& cloud_mesh_item)
-  :QTreeWidgetItem(parent),
-  filename_(cloud_mesh_item.filename_),
-  cloud_mesh_(cloud_mesh_item.cloud_mesh_),
-  translation_x_(new DoubleParameter("Translation X", "Translation X", 0.0, -1.0, 1.0)),
-  translation_y_(new DoubleParameter("Translation Y", "Translation Y", 0.0, -1.0, 1.0)),
-  translation_z_(new DoubleParameter("Translation Z", "Translation Z", 0.0, -1.0, 1.0)),
-  rotation_x_(new DoubleParameter("Rotation X", "Rotation X", 0.0, -180.0, 180.0)),
-  rotation_y_(new DoubleParameter("Rotation Y", "Rotation Y", 0.0, -180.0, 180.0)),
-  rotation_z_(new DoubleParameter("Rotation Z", "Rotation Z", 0.0, -180.0, 180.0))
+pcl::modeler::CloudMeshItem::CloudMeshItem(QTreeWidgetItem* parent,
+                                           const CloudMeshItem& cloud_mesh_item)
+: QTreeWidgetItem(parent)
+, filename_(cloud_mesh_item.filename_)
+, cloud_mesh_(cloud_mesh_item.cloud_mesh_)
+, translation_x_(new DoubleParameter("Translation X", "Translation X", 0.0, -1.0, 1.0))
+, translation_y_(new DoubleParameter("Translation Y", "Translation Y", 0.0, -1.0, 1.0))
+, translation_z_(new DoubleParameter("Translation Z", "Translation Z", 0.0, -1.0, 1.0))
+, rotation_x_(new DoubleParameter("Rotation X", "Rotation X", 0.0, -180.0, 180.0))
+, rotation_y_(new DoubleParameter("Rotation Y", "Rotation Y", 0.0, -180.0, 180.0))
+, rotation_z_(new DoubleParameter("Rotation Z", "Rotation Z", 0.0, -180.0, 180.0))
 {
-  setFlags(flags()&(~Qt::ItemIsDropEnabled));
+  setFlags(flags() & (~Qt::ItemIsDropEnabled));
   setText(0, QString(filename_.c_str()));
 
   createChannels();
@@ -105,38 +108,36 @@ pcl::modeler::CloudMeshItem::CloudMeshItem(QTreeWidgetItem* parent,  const Cloud
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMeshItem::~CloudMeshItem ()
-{
-}
+pcl::modeler::CloudMeshItem::~CloudMeshItem() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 bool
-pcl::modeler::CloudMeshItem::savePointCloud(const QList<CloudMeshItem*>& items, const QString& filename)
+pcl::modeler::CloudMeshItem::savePointCloud(const QList<CloudMeshItem*>& items,
+                                            const QString& filename)
 {
   if (items.size() == 1)
-    return (items.first()->getCloudMesh()->save(filename.toStdString()));
+    return items.first()->getCloudMesh()->save(filename.toStdString());
 
   std::vector<const CloudMesh*> cloud_meshes;
-  for (const auto &item : items)
-  {
+  for (const auto& item : items) {
     cloud_meshes.push_back(item->getCloudMesh().get());
   }
 
-  return (CloudMesh::save(cloud_meshes, filename.toStdString()));
+  return CloudMesh::save(cloud_meshes, filename.toStdString());
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 bool
 pcl::modeler::CloudMeshItem::open()
 {
-  if(!cloud_mesh_->open(filename_))
-    return (false);
+  if (!cloud_mesh_->open(filename_))
+    return false;
 
   createChannels();
 
   treeWidget()->expandItem(this);
 
-  return (true);
+  return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -155,22 +156,21 @@ void
 pcl::modeler::CloudMeshItem::createChannels()
 {
   RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(parent());
-  addChild(new PointsActorItem(this, cloud_mesh_, render_window_item->getRenderWindow()->GetRenderWindow()));
-  addChild(new NormalsActorItem(this, cloud_mesh_, render_window_item->getRenderWindow()->GetRenderWindow()));
-  addChild(new SurfaceActorItem(this, cloud_mesh_, render_window_item->getRenderWindow()->GetRenderWindow()));
-  for (int i = 0, i_end = childCount(); i < i_end; ++ i)
-  {
+  addChild(new PointsActorItem(
+      this, cloud_mesh_, render_window_item->getRenderWindow()->GetRenderWindow()));
+  addChild(new NormalsActorItem(
+      this, cloud_mesh_, render_window_item->getRenderWindow()->GetRenderWindow()));
+  addChild(new SurfaceActorItem(
+      this, cloud_mesh_, render_window_item->getRenderWindow()->GetRenderWindow()));
+  for (int i = 0, i_end = childCount(); i < i_end; ++i) {
     ChannelActorItem* child_item = dynamic_cast<ChannelActorItem*>(child(i));
     child_item->init();
   }
 
   render_window_item->getRenderWindow()->updateAxes();
   render_window_item->getRenderWindow()->resetCamera();
-
-  return;
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::CloudMeshItem::updateChannels()
@@ -178,16 +178,13 @@ pcl::modeler::CloudMeshItem::updateChannels()
   cloud_mesh_->updateVtkPoints();
   cloud_mesh_->updateVtkPolygons();
 
-  for (int i = 0, i_end = childCount(); i < i_end; ++ i)
-  {
+  for (int i = 0, i_end = childCount(); i < i_end; ++i) {
     ChannelActorItem* child_item = dynamic_cast<ChannelActorItem*>(child(i));
     child_item->update();
   }
 
   RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(parent());
   render_window_item->getRenderWindow()->updateAxes();
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -212,23 +209,27 @@ pcl::modeler::CloudMeshItem::prepareProperties(ParameterDialog* parameter_dialog
   double x_range = max_pt.x() - min_pt.x();
   double y_range = max_pt.y() - min_pt.y();
   double z_range = max_pt.z() - min_pt.z();
-  translation_x_->setLow(-x_range/2);
-  translation_x_->setHigh(x_range/2);
-  translation_x_->setStep(x_range/1000);
-  translation_y_->setLow(-y_range/2);
-  translation_y_->setHigh(y_range/2);
-  translation_y_->setStep(y_range/1000);
-  translation_z_->setLow(-z_range/2);
-  translation_z_->setHigh(z_range/2);
-  translation_z_->setStep(z_range/1000);
+  translation_x_->setLow(-x_range / 2);
+  translation_x_->setHigh(x_range / 2);
+  translation_x_->setStep(x_range / 1000);
+  translation_y_->setLow(-y_range / 2);
+  translation_y_->setHigh(y_range / 2);
+  translation_y_->setStep(y_range / 1000);
+  translation_z_->setLow(-z_range / 2);
+  translation_z_->setHigh(z_range / 2);
+  translation_z_->setStep(z_range / 1000);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::CloudMeshItem::setProperties()
 {
-  cloud_mesh_->transform(*translation_x_, *translation_y_, *translation_z_,
-    *rotation_x_, *rotation_y_, *rotation_z_);
+  cloud_mesh_->transform(*translation_x_,
+                         *translation_y_,
+                         *translation_z_,
+                         *rotation_x_,
+                         *rotation_y_,
+                         *rotation_z_);
 
   updateChannels();
 }
@@ -238,14 +239,12 @@ void
 pcl::modeler::CloudMeshItem::updateRenderWindow()
 {
   RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(parent());
-  for (int i = 0, i_end = childCount(); i < i_end; ++ i)
-  {
+  for (int i = 0, i_end = childCount(); i < i_end; ++i) {
     ChannelActorItem* child_item = dynamic_cast<ChannelActorItem*>(child(i));
-    child_item->switchRenderWindow(render_window_item->getRenderWindow()->GetRenderWindow());
+    child_item->switchRenderWindow(
+        render_window_item->getRenderWindow()->GetRenderWindow());
   }
 
   render_window_item->getRenderWindow()->updateAxes();
   render_window_item->getRenderWindow()->resetCamera();
-
-  return;
 }
index 3bbe5c050bb26b1ee0be867d856838f543640d83..9f933ca10bf8d0e7501b68d573f78aadedf4ec80 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/cloud_mesh_item_updater.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
-
+#include <pcl/apps/modeler/cloud_mesh_item_updater.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMeshItemUpdater::CloudMeshItemUpdater (CloudMeshItem* cloud_mesh_item)
-  :cloud_mesh_item_(cloud_mesh_item)
-{
-}
+pcl::modeler::CloudMeshItemUpdater::CloudMeshItemUpdater(CloudMeshItem* cloud_mesh_item)
+: cloud_mesh_item_(cloud_mesh_item)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::CloudMeshItemUpdater::~CloudMeshItemUpdater ()
-{
-
-}
+pcl::modeler::CloudMeshItemUpdater::~CloudMeshItemUpdater() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
index a4e9286e80a178c3b23503f5e2f7c010ecde2d79..ae73f9d2ad70d2547470df64f841731a0ea76e4c 100755 (executable)
  */
 
 #include <pcl/apps/modeler/dock_widget.h>
-#include <pcl/apps/modeler/render_window.h>
 #include <pcl/apps/modeler/main_window.h>
-
+#include <pcl/apps/modeler/render_window.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::DockWidget::DockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) : 
-  QDockWidget(title, parent, flags)
+pcl::modeler::DockWidget::DockWidget(const QString& title,
+                                     QWidget* parent,
+                                     Qt::WindowFlags flags)
+: QDockWidget(title, parent, flags)
 {
   setStyleSheet("QDockWidget::title {text-align: center;}");
   setFocusPolicy(Qt::StrongFocus);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::DockWidget::DockWidget(QWidget *parent, Qt::WindowFlags flags) : 
-  QDockWidget(parent, flags) 
+pcl::modeler::DockWidget::DockWidget(QWidget* parent, Qt::WindowFlags flags)
+: QDockWidget(parent, flags)
 {
   setStyleSheet("QDockWidget::title {text-align: center;}");
   setFocusPolicy(Qt::StrongFocus);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::DockWidget::~DockWidget()
-{
-}
+pcl::modeler::DockWidget::~DockWidget() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::DockWidget::focusInEvent ( QFocusEvent * event )
+pcl::modeler::DockWidget::focusInEvent(QFocusEvent* event)
 {
   QDockWidget::focusInEvent(event);
 }
@@ -71,14 +70,10 @@ pcl::modeler::DockWidget::focusInEvent ( QFocusEvent * event )
 void
 pcl::modeler::DockWidget::setFocusBasedStyle(bool focused)
 {
-  if (focused)
-  {
+  if (focused) {
     setStyleSheet("QDockWidget::title {text-align: center; background: #87CEFA;}");
   }
-  else
-  {
+  else {
     setStyleSheet("QDockWidget::title {text-align: center;}");
   }
-
-  return;
 }
index a6e31886857dc15561beef54454d61eec816b78f..7628ed81d6e6def0b2c9eb8f9809567c08a713ca 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/icp_registration_worker.h>
-#include <pcl/apps/modeler/parameter_dialog.h>
-#include <pcl/apps/modeler/parameter.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
-#include <pcl/registration/icp.h>
+#include <pcl/apps/modeler/icp_registration_worker.h>
+#include <pcl/apps/modeler/parameter.h>
+#include <pcl/apps/modeler/parameter_dialog.h>
 #include <pcl/common/common.h>
+#include <pcl/registration/icp.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ICPRegistrationWorker::ICPRegistrationWorker(CloudMesh::PointCloudPtr cloud, const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent)
-  : AbstractWorker(cloud_mesh_items, parent),
-  cloud_(std::move(cloud)),
-  x_min_(std::numeric_limits<double>::max()), x_max_(std::numeric_limits<double>::min()),
-  y_min_(std::numeric_limits<double>::max()), y_max_(std::numeric_limits<double>::min()),
-  z_min_(std::numeric_limits<double>::max()), z_max_(std::numeric_limits<double>::min()),
-  max_correspondence_distance_(nullptr),
-  max_iterations_(nullptr),
-  transformation_epsilon_(nullptr),
-  euclidean_fitness_epsilon_(nullptr)
-{
-
-}
+pcl::modeler::ICPRegistrationWorker::ICPRegistrationWorker(
+    CloudMesh::PointCloudPtr cloud,
+    const QList<CloudMeshItem*>& cloud_mesh_items,
+    QWidget* parent)
+: AbstractWorker(cloud_mesh_items, parent)
+, cloud_(std::move(cloud))
+, x_min_(std::numeric_limits<double>::max())
+, x_max_(std::numeric_limits<double>::min())
+, y_min_(std::numeric_limits<double>::max())
+, y_max_(std::numeric_limits<double>::min())
+, z_min_(std::numeric_limits<double>::max())
+, z_max_(std::numeric_limits<double>::min())
+, max_correspondence_distance_(nullptr)
+, max_iterations_(nullptr)
+, transformation_epsilon_(nullptr)
+, euclidean_fitness_epsilon_(nullptr)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ICPRegistrationWorker::~ICPRegistrationWorker()
-{
-}
+pcl::modeler::ICPRegistrationWorker::~ICPRegistrationWorker() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -79,8 +81,6 @@ pcl::modeler::ICPRegistrationWorker::initParameters(CloudMeshItem* cloud_mesh_it
 
   z_min_ = std::min(double(min_pt.z()), z_min_);
   z_max_ = std::max(double(max_pt.z()), z_max_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -92,51 +92,60 @@ pcl::modeler::ICPRegistrationWorker::setupParameters()
   double z_range = z_max_ - z_min_;
 
   double range_max = std::max(x_range, std::max(y_range, z_range));
-  double max_correspondence_distance = range_max/2;
-  double step = range_max/1000;
-
-  max_correspondence_distance_ = new DoubleParameter("Max Correspondence Distance",
-    "If the distance is larger than this threshold, the points will be ignored in the alignment process.", max_correspondence_distance, 0, x_max_-x_min_, step);
-
-  max_iterations_ = new IntParameter("Max Iterations",
-    "Set the maximum number of iterations the internal optimization should run for.", 10, 0, 256);
-
-  double transformation_epsilon = range_max/2;
-  transformation_epsilon_ = new DoubleParameter("Transformation Epsilon",
-    "Maximum allowable difference between two consecutive transformations.", 0.0, 0, transformation_epsilon, step);
-
-  double euclidean_fitness_epsilon = range_max/2;
-  euclidean_fitness_epsilon_ = new DoubleParameter("Euclidean Fitness Epsilon",
-    "Maximum allowed Euclidean error between two consecutive steps in the ICP loop.", 0.0, 0, euclidean_fitness_epsilon, step);
+  double max_correspondence_distance = range_max / 2;
+  double step = range_max / 1000;
+
+  // clang-format off
+  max_correspondence_distance_ =
+      new DoubleParameter("Max Correspondence Distance",
+                          "If the distance is larger than this threshold, the points "
+                          "will be ignored in the alignment process.",
+                          max_correspondence_distance, 0, x_max_ - x_min_, step);
+
+  max_iterations_ = new IntParameter(
+      "Max Iterations",
+      "Set the maximum number of iterations the internal optimization should run for.",
+      10, 0, 256);
+
+  double transformation_epsilon = range_max / 2;
+  transformation_epsilon_ = new DoubleParameter(
+      "Transformation Epsilon",
+      "Maximum allowable difference between two consecutive transformations.",
+      0.0, 0, transformation_epsilon, step);
+
+  double euclidean_fitness_epsilon = range_max / 2;
+  euclidean_fitness_epsilon_ = new DoubleParameter(
+      "Euclidean Fitness Epsilon",
+      "Maximum allowed Euclidean error between two consecutive steps in the ICP loop.",
+      0.0, 0, euclidean_fitness_epsilon, step);
+  // clang-format on
 
   parameter_dialog_->addParameter(max_correspondence_distance_);
   parameter_dialog_->addParameter(max_iterations_);
   parameter_dialog_->addParameter(transformation_epsilon_);
   parameter_dialog_->addParameter(euclidean_fitness_epsilon_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::ICPRegistrationWorker::processImpl(CloudMeshItem* cloud_mesh_item)
 {
-  if (cloud_->empty())
-  {
+  if (cloud_->empty()) {
     *cloud_ = *(cloud_mesh_item->getCloudMesh()->getCloud());
     return;
   }
 
   pcl::IterativeClosestPoint<CloudMesh::PointT, CloudMesh::PointT> icp;
 
-  // Set the max correspondence distance to 5cm (e.g., correspondences with higher distances will be ignored)
-  icp.setMaxCorrespondenceDistance (*max_correspondence_distance_);
+  // Set the max correspondence distance to 5cm (e.g., correspondences with higher
+  // distances will be ignored)
+  icp.setMaxCorrespondenceDistance(*max_correspondence_distance_);
   // Set the maximum number of iterations (criterion 1)
-  icp.setMaximumIterations (*max_iterations_);
+  icp.setMaximumIterations(*max_iterations_);
   // Set the transformation epsilon (criterion 2)
-  icp.setTransformationEpsilon (*transformation_epsilon_);
+  icp.setTransformationEpsilon(*transformation_epsilon_);
   // Set the euclidean distance difference epsilon (criterion 3)
-  icp.setEuclideanFitnessEpsilon (*euclidean_fitness_epsilon_);
+  icp.setEuclideanFitnessEpsilon(*euclidean_fitness_epsilon_);
 
   icp.setInputSource(cloud_mesh_item->getCloudMesh()->getCloud());
   icp.setInputTarget(cloud_);
@@ -144,10 +153,9 @@ pcl::modeler::ICPRegistrationWorker::processImpl(CloudMeshItem* cloud_mesh_item)
   icp.align(result);
 
   result.sensor_origin_ = cloud_mesh_item->getCloudMesh()->getCloud()->sensor_origin_;
-  result.sensor_orientation_ = cloud_mesh_item->getCloudMesh()->getCloud()->sensor_orientation_;
+  result.sensor_orientation_ =
+      cloud_mesh_item->getCloudMesh()->getCloud()->sensor_orientation_;
 
   *(cloud_mesh_item->getCloudMesh()->getCloud()) = result;
   *cloud_ += result;
-
-  return;
 }
index db2aa82db3bb9f724a531bb7fe03b2080fcfb3b8..27764dd1d58767dcbbd6bd0425ff944384f27fee 100755 (executable)
 
 #include <pcl/apps/modeler/main_window.h>
 
-extern int qInitResources_resources();
+extern int
+qInitResources_resources();
 
-int main( int argc, char** argv )
+int
+main(int argc, char** argv)
 {
-  QApplication app( argc, argv );
+  QApplication app(argc, argv);
 
   qInitResources_resources();
 
index 3b4145bd55062f83873f8a759ab111547e6b556d..b674cadf182886f2c488e48e7b038ad904d6d838 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/main_window.h>
-
-#include <pcl/apps/modeler/scene_tree.h>
 #include <pcl/apps/modeler/dock_widget.h>
+#include <pcl/apps/modeler/main_window.h>
 #include <pcl/apps/modeler/render_window.h>
 #include <pcl/apps/modeler/render_window_item.h>
+#include <pcl/apps/modeler/scene_tree.h>
 
 #include <QFileInfo>
 #include <QSettings>
+
 #include <vtkActor.h>
 #include <vtkRenderer.h>
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::MainWindow::MainWindow()
-  : ui_(new Ui::MainWindow)
+pcl::modeler::MainWindow::MainWindow() : ui_(new Ui::MainWindow)
 {
   ui_->setupUi(this);
 
@@ -68,20 +66,32 @@ pcl::modeler::MainWindow::MainWindow()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::MainWindow::~MainWindow()
-{
-  saveGlobalSettings();
-}
+pcl::modeler::MainWindow::~MainWindow() { saveGlobalSettings(); }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::connectFileMenuActions()
 {
-  connect(ui_->actionOpenPointCloud, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotOpenPointCloud()));
-  connect(ui_->actionImportPointCloud, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotImportPointCloud()));
-  connect(ui_->actionSavePointCloud, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotSavePointCloud()));
-  connect(ui_->actionClosePointCloud, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotClosePointCloud()));
-  connect(ui_->scene_tree_, SIGNAL(fileOpened(QString)), this, SLOT(slotUpdateRecentFile(QString)));
+  connect(ui_->actionOpenPointCloud,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotOpenPointCloud()));
+  connect(ui_->actionImportPointCloud,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotImportPointCloud()));
+  connect(ui_->actionSavePointCloud,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotSavePointCloud()));
+  connect(ui_->actionClosePointCloud,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotClosePointCloud()));
+  connect(ui_->scene_tree_,
+          SIGNAL(fileOpened(QString)),
+          this,
+          SLOT(slotUpdateRecentFile(QString)));
   createRecentPointCloudActions();
 
   connect(ui_->actionOpenProject, SIGNAL(triggered()), this, SLOT(slotOpenProject()));
@@ -93,50 +103,66 @@ pcl::modeler::MainWindow::connectFileMenuActions()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::connectViewMenuActions()
 {
-  connect(ui_->actionCreateRenderWindow, SIGNAL(triggered()), this, SLOT(slotCreateRenderWindow()));
-  connect(ui_->actionCloseRenderWindow, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotCloseRenderWindow()));
+  connect(ui_->actionCreateRenderWindow,
+          SIGNAL(triggered()),
+          this,
+          SLOT(slotCreateRenderWindow()));
+  connect(ui_->actionCloseRenderWindow,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotCloseRenderWindow()));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::connectEditMenuActions()
 {
-  connect(ui_->actionICPRegistration, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotICPRegistration()));
-  connect(ui_->actionVoxelGridDownsample, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotVoxelGridDownsampleFilter()));
-  connect(ui_->actionStatisticalOutlierRemoval, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotStatisticalOutlierRemovalFilter()));
-  connect(ui_->actionEstimateNormals, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotEstimateNormal()));
-  connect(ui_->actionPoissonReconstruction, SIGNAL(triggered()), ui_->scene_tree_, SLOT(slotPoissonReconstruction()));
+  connect(ui_->actionICPRegistration,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotICPRegistration()));
+  connect(ui_->actionVoxelGridDownsample,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotVoxelGridDownsampleFilter()));
+  connect(ui_->actionStatisticalOutlierRemoval,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotStatisticalOutlierRemovalFilter()));
+  connect(ui_->actionEstimateNormals,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotEstimateNormal()));
+  connect(ui_->actionPoissonReconstruction,
+          SIGNAL(triggered()),
+          ui_->scene_tree_,
+          SLOT(slotPoissonReconstruction()));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotOpenProject()
-{
-
-}
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotSaveProject()
-{
-
-}
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotCloseProject()
-{
-
-}
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::MainWindow::slotExit() {
-    saveGlobalSettings();
-    qApp->exit();
+pcl::modeler::MainWindow::slotExit()
+{
+  saveGlobalSettings();
+  qApp->exit();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -161,8 +187,9 @@ pcl::modeler::MainWindow::createRenderWindow()
   ui_->scene_tree_->addTopLevelItem(render_window_item);
 
   // add the toggle action to view menu
-  QList<QAction *> actions = ui_->menuView->actions();
-  ui_->menuView->insertAction(actions[actions.size()-2], dock_widget->toggleViewAction());
+  QList<QAction*> actions = ui_->menuView->actions();
+  ui_->menuView->insertAction(actions[actions.size() - 2],
+                              dock_widget->toggleViewAction());
 
   return render_window_item;
 }
@@ -172,117 +199,106 @@ void
 pcl::modeler::MainWindow::slotCreateRenderWindow()
 {
   createRenderWindow();
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotOpenRecentPointCloud()
 {
   QAction* action = qobject_cast<QAction*>(sender());
   if (action)
     ui_->scene_tree_->openPointCloud(action->data().toString());
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotOpenRecentProject()
 {
   QAction* action = qobject_cast<QAction*>(sender());
   if (action)
     openProjectImpl(action->data().toString());
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::createRecentPointCloudActions()
 {
-  for (std::size_t i = 0; i < MAX_RECENT_NUMBER; ++ i)
-  {
+  for (std::size_t i = 0; i < MAX_RECENT_NUMBER; ++i) {
     recent_pointcloud_actions_.push_back(std::shared_ptr<QAction>(new QAction(this)));
     ui_->menuRecentPointClouds->addAction(recent_pointcloud_actions_[i].get());
     recent_pointcloud_actions_[i]->setVisible(false);
-    connect(recent_pointcloud_actions_[i].get(), SIGNAL(triggered()), this, SLOT(slotOpenRecentPointCloud()));
+    connect(recent_pointcloud_actions_[i].get(),
+            SIGNAL(triggered()),
+            this,
+            SLOT(slotOpenRecentPointCloud()));
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::updateRecentPointCloudActions()
 {
   updateRecentActions(recent_pointcloud_actions_, recent_files_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::createRecentProjectActions()
 {
-  for (std::size_t i = 0; i < MAX_RECENT_NUMBER; ++ i)
-  {
+  for (std::size_t i = 0; i < MAX_RECENT_NUMBER; ++i) {
     recent_project_actions_.push_back(std::shared_ptr<QAction>(new QAction(this)));
     ui_->menuRecentPointClouds->addAction(recent_project_actions_[i].get());
     recent_project_actions_[i]->setVisible(false);
-    connect(recent_project_actions_[i].get(), SIGNAL(triggered()), this, SLOT(slotOpenRecentProject()));
+    connect(recent_project_actions_[i].get(),
+            SIGNAL(triggered()),
+            this,
+            SLOT(slotOpenRecentProject()));
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::updateRecentProjectActions()
 {
   updateRecentActions(recent_project_actions_, recent_projects_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-bool 
-pcl::modeler::MainWindow::openProjectImpl (const QString&)
+bool
+pcl::modeler::MainWindow::openProjectImpl(const QString&)
 {
-  return (true);
+  return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
-pcl::modeler::MainWindow::updateRecentActions (std::vector<std::shared_ptr<QAction>>& recent_actions, QStringList& recent_items)
+void
+pcl::modeler::MainWindow::updateRecentActions(
+    std::vector<std::shared_ptr<QAction>>& recent_actions, QStringList& recent_items)
 {
-  QMutableStringListIterator recent_items_it (recent_items);
-  while (recent_items_it.hasNext ())
-  {
-    if (!QFile::exists (recent_items_it.next ()))
-      recent_items_it.remove ();
+  QMutableStringListIterator recent_items_it(recent_items);
+  while (recent_items_it.hasNext()) {
+    if (!QFile::exists(recent_items_it.next()))
+      recent_items_it.remove();
   }
 
-  recent_items.removeDuplicates ();
-  int recent_number = std::min (int (MAX_RECENT_NUMBER), recent_items.size ());
-  for (int i = 0; i < recent_number; ++ i)
-  {
-    QString text = tr ("%1 %2").arg (i + 1).arg (recent_items[i]);
-    recent_actions[i]->setText (text);
-    recent_actions[i]->setData (recent_items[i]);
-    recent_actions[i]->setVisible (true);
+  recent_items.removeDuplicates();
+  int recent_number = std::min(int(MAX_RECENT_NUMBER), recent_items.size());
+  for (int i = 0; i < recent_number; ++i) {
+    QString text = tr("%1 %2").arg(i + 1).arg(recent_items[i]);
+    recent_actions[i]->setText(text);
+    recent_actions[i]->setData(recent_items[i]);
+    recent_actions[i]->setVisible(true);
   }
 
-  for (std::size_t i = recent_number, i_end = recent_actions.size (); i < i_end; ++ i)
-    recent_actions[i]->setVisible (false);
+  for (std::size_t i = recent_number, i_end = recent_actions.size(); i < i_end; ++i)
+    recent_actions[i]->setVisible(false);
 
-  while (recent_items.size () > recent_number)
-    recent_items.pop_back ();
+  while (recent_items.size() > recent_number)
+    recent_items.pop_back();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-QString 
+QString
 pcl::modeler::MainWindow::getRecentFolder()
 {
   QString recent_filename;
@@ -294,11 +310,11 @@ pcl::modeler::MainWindow::getRecentFolder()
   if (!recent_filename.isEmpty())
     return QFileInfo(recent_filename).path();
 
-  return (QString("."));
+  return ".";
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::loadGlobalSettings()
 {
   QSettings global_settings("PCL", "Modeler");
@@ -308,12 +324,10 @@ pcl::modeler::MainWindow::loadGlobalSettings()
 
   recent_projects_ = global_settings.value("recent_projects").toStringList();
   updateRecentProjectActions();
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::saveGlobalSettings()
 {
   QSettings global_settings("PCL", "Modeler");
@@ -321,19 +335,17 @@ pcl::modeler::MainWindow::saveGlobalSettings()
   global_settings.setValue("recent_pointclouds", recent_files_);
 
   global_settings.setValue("recent_projects", recent_projects_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotOnWorkerStarted()
 {
   statusBar()->showMessage(QString("Working thread running..."));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::MainWindow::slotOnWorkerFinished()
 {
   statusBar()->showMessage(QString("Working thread finished..."));
index 7165b5b09292283b75921807c2258016d346562b..c3b3700e348202b08e44b26ceedc2b6d4b56d923 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/normal_estimation_worker.h>
-#include <pcl/apps/modeler/parameter_dialog.h>
-#include <pcl/apps/modeler/parameter.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
-#include <pcl/filters/filter_indices.h>
+#include <pcl/apps/modeler/normal_estimation_worker.h>
+#include <pcl/apps/modeler/parameter.h>
+#include <pcl/apps/modeler/parameter_dialog.h>
+#include <pcl/common/common.h>
 #include <pcl/features/normal_3d.h>
+#include <pcl/filters/filter_indices.h>
 #include <pcl/filters/voxel_grid.h>
-#include <pcl/common/common.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::NormalEstimationWorker::NormalEstimationWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent) :
-  AbstractWorker(cloud_mesh_items, parent),
-  x_min_(std::numeric_limits<double>::max()), x_max_(std::numeric_limits<double>::min()),
-  y_min_(std::numeric_limits<double>::max()), y_max_(std::numeric_limits<double>::min()),
-  z_min_(std::numeric_limits<double>::max()), z_max_(std::numeric_limits<double>::min()),
-  search_radius_(nullptr)
-{
-
-}
+pcl::modeler::NormalEstimationWorker::NormalEstimationWorker(
+    const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent)
+: AbstractWorker(cloud_mesh_items, parent)
+, x_min_(std::numeric_limits<double>::max())
+, x_max_(std::numeric_limits<double>::min())
+, y_min_(std::numeric_limits<double>::max())
+, y_max_(std::numeric_limits<double>::min())
+, z_min_(std::numeric_limits<double>::max())
+, z_max_(std::numeric_limits<double>::min())
+, search_radius_(nullptr)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::NormalEstimationWorker::~NormalEstimationWorker()
@@ -76,8 +78,6 @@ pcl::modeler::NormalEstimationWorker::initParameters(CloudMeshItem* cloud_mesh_i
 
   z_min_ = std::min(double(min_pt.z()), z_min_);
   z_max_ = std::max(double(max_pt.z()), z_max_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -89,15 +89,17 @@ pcl::modeler::NormalEstimationWorker::setupParameters()
   double z_range = z_max_ - z_min_;
 
   double range_max = std::max(x_range, std::max(y_range, z_range));
-  double radius = range_max/100;
-  double step = range_max/1000;
+  double radius = range_max / 100;
+  double step = range_max / 1000;
 
-  search_radius_ = new DoubleParameter("Search Radius",
-    "The sphere radius that is to be used for determining the nearest neighbors", radius, 0, x_max_-x_min_, step);
+  // clang-format off
+  search_radius_ = new DoubleParameter(
+      "Search Radius",
+      "The sphere radius that is to be used for determining the nearest neighbors",
+      radius, 0, x_max_ - x_min_, step);
+  // clang-format on
 
   parameter_dialog_->addParameter(search_radius_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -115,23 +117,22 @@ pcl::modeler::NormalEstimationWorker::processImpl(CloudMeshItem* cloud_mesh_item
   normal_estimator.setIndices(indices);
 
   // Create an empty kdtree representation, and pass it to the normal estimation object.
-  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
-  pcl::search::KdTree<pcl::PointSurfel>::Ptr tree (new pcl::search::KdTree<pcl::PointSurfel> ());
-  normal_estimator.setSearchMethod (tree);
+  // Its content will be filled inside the object, based on the given input dataset (as
+  // no other search surface is given).
+  pcl::search::KdTree<pcl::PointSurfel>::Ptr tree(
+      new pcl::search::KdTree<pcl::PointSurfel>());
+  normal_estimator.setSearchMethod(tree);
 
   // Use all neighbors in a sphere of the search radius
-  normal_estimator.setRadiusSearch (*search_radius_);
+  normal_estimator.setRadiusSearch(*search_radius_);
 
   pcl::PointCloud<pcl::PointNormal> normals;
   normal_estimator.compute(normals);
 
-  for (std::size_t i = 0, i_end = indices->size(); i < i_end; ++ i)
-  {
+  for (std::size_t i = 0, i_end = indices->size(); i < i_end; ++i) {
     std::size_t dest = (*indices)[i];
     cloud->points[dest].normal_x = normals.points[i].normal_x;
     cloud->points[dest].normal_y = normals.points[i].normal_y;
     cloud->points[dest].normal_z = normals.points[i].normal_z;
   }
-
-  return;
 }
index bc223918b8d3f7c75a9c04a00cc1d35bd34ac0df..4fc576b83e99c9fc256c2c55e06c2f9cb45e13cd 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/normals_actor_item.h>
-
 #include <pcl/apps/modeler/cloud_mesh.h>
+#include <pcl/apps/modeler/normals_actor_item.h>
 #include <pcl/filters/filter_indices.h>
 
-#include <vtkLODActor.h>
-#include <vtkPolyData.h>
 #include <vtkCellArray.h>
 #include <vtkDataSetMapper.h>
+#include <vtkLODActor.h>
 #include <vtkPointData.h>
+#include <vtkPolyData.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::NormalsActorItem::NormalsActorItem(QTreeWidgetItem* parent,
-                                                 const CloudMesh::Ptr& cloud_mesh,
-                                                 const vtkSmartPointer<vtkRenderWindow>& render_window)
-  :ChannelActorItem(parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Normals"),
-  level_(10), scale_(0.1)
-{
-}
+pcl::modeler::NormalsActorItem::NormalsActorItem(
+    QTreeWidgetItem* parent,
+    const CloudMesh::Ptr& cloud_mesh,
+    const vtkSmartPointer<vtkRenderWindow>& render_window)
+: ChannelActorItem(
+      parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Normals")
+, level_(10)
+, scale_(0.1)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::NormalsActorItem::~NormalsActorItem ()
-{
-
-}
+pcl::modeler::NormalsActorItem::~NormalsActorItem() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -73,54 +71,51 @@ pcl::modeler::NormalsActorItem::createNormalLines()
     return;
 
   if (points->GetData() == nullptr)
-    points->SetData(vtkSmartPointer<vtkFloatArray>::New ());
+    points->SetData(vtkSmartPointer<vtkFloatArray>::New());
 
   vtkFloatArray* data = dynamic_cast<vtkFloatArray*>(points->GetData());
-  data->SetNumberOfComponents (3);
-
-  if (cloud->is_dense)
-  {
-    vtkIdType nr_normals = static_cast<vtkIdType> ((cloud->points.size () - 1) / level_ + 1);
-    data->SetNumberOfValues(2*3*nr_normals);
-    for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = static_cast<vtkIdType> (j * level_))
-    {
+  data->SetNumberOfComponents(3);
+
+  if (cloud->is_dense) {
+    vtkIdType nr_normals =
+        static_cast<vtkIdType>((cloud->points.size() - 1) / level_ + 1);
+    data->SetNumberOfValues(2 * 3 * nr_normals);
+    for (vtkIdType i = 0, j = 0; j < nr_normals;
+         j++, i = static_cast<vtkIdType>(j * level_)) {
       const CloudMesh::PointT& p = cloud->points[i];
-      data->SetValue(2*j*3 + 0, p.x);
-      data->SetValue(2*j*3 + 1, p.y);
-      data->SetValue(2*j*3 + 2, p.z);
-      data->SetValue(2*j*3 + 3, float (p.x + p.normal_x*scale_));
-      data->SetValue(2*j*3 + 4, float (p.y + p.normal_y*scale_));
-      data->SetValue(2*j*3 + 5, float (p.z + p.normal_z*scale_));
+      data->SetValue(2 * j * 3 + 0, p.x);
+      data->SetValue(2 * j * 3 + 1, p.y);
+      data->SetValue(2 * j * 3 + 2, p.z);
+      data->SetValue(2 * j * 3 + 3, float(p.x + p.normal_x * scale_));
+      data->SetValue(2 * j * 3 + 4, float(p.y + p.normal_y * scale_));
+      data->SetValue(2 * j * 3 + 5, float(p.z + p.normal_z * scale_));
 
       lines->InsertNextCell(2);
-      lines->InsertCellPoint(2*j);
-      lines->InsertCellPoint(2*j + 1);
+      lines->InsertCellPoint(2 * j);
+      lines->InsertCellPoint(2 * j + 1);
     }
   }
-  else
-  {
+  else {
     pcl::IndicesPtr indices(new std::vector<int>());
     pcl::removeNaNFromPointCloud(*cloud, *indices);
 
-    vtkIdType nr_normals = static_cast<vtkIdType> ((indices->size () - 1) / level_ + 1);
-    data->SetNumberOfValues(2*3*nr_normals);
-    for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = static_cast<vtkIdType> (j * level_))
-    {
-      const CloudMesh::PointT& p= cloud->points[(*indices)[i]];
-      data->SetValue (2*j*3 + 0, p.x);
-      data->SetValue (2*j*3 + 1, p.y);
-      data->SetValue (2*j*3 + 2, p.z);
-      data->SetValue (2*j*3 + 3, float (p.x + p.normal_x*scale_));
-      data->SetValue (2*j*3 + 4, float (p.y + p.normal_y*scale_));
-      data->SetValue (2*j*3 + 5, float (p.z + p.normal_z*scale_));
+    vtkIdType nr_normals = static_cast<vtkIdType>((indices->size() - 1) / level_ + 1);
+    data->SetNumberOfValues(2 * 3 * nr_normals);
+    for (vtkIdType i = 0, j = 0; j < nr_normals;
+         j++, i = static_cast<vtkIdType>(j * level_)) {
+      const CloudMesh::PointT& p = cloud->points[(*indices)[i]];
+      data->SetValue(2 * j * 3 + 0, p.x);
+      data->SetValue(2 * j * 3 + 1, p.y);
+      data->SetValue(2 * j * 3 + 2, p.z);
+      data->SetValue(2 * j * 3 + 3, float(p.x + p.normal_x * scale_));
+      data->SetValue(2 * j * 3 + 4, float(p.y + p.normal_y * scale_));
+      data->SetValue(2 * j * 3 + 5, float(p.z + p.normal_z * scale_));
 
       lines->InsertNextCell(2);
-      lines->InsertCellPoint(2*j);
-      lines->InsertCellPoint(2*j + 1);
+      lines->InsertCellPoint(2 * j);
+      lines->InsertCellPoint(2 * j + 1);
     }
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -128,7 +123,7 @@ void
 pcl::modeler::NormalsActorItem::initImpl()
 {
   vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
-  points->SetDataTypeToFloat ();
+  points->SetDataTypeToFloat();
   vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
 
   poly_data_->SetPoints(points);
@@ -137,11 +132,11 @@ pcl::modeler::NormalsActorItem::initImpl()
   createNormalLines();
 
   vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
-  mapper->SetInputData (poly_data_);
+  mapper->SetInputData(poly_data_);
 
   vtkSmartPointer<vtkDataArray> scalars;
   cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
-  poly_data_->GetPointData ()->SetScalars (scalars);
+  poly_data_->GetPointData()->SetScalars(scalars);
   double minmax[2];
   scalars->GetRange(minmax);
   mapper->SetScalarRange(minmax);
@@ -149,7 +144,8 @@ pcl::modeler::NormalsActorItem::initImpl()
   mapper->SetColorModeToMapScalars();
   mapper->SetScalarModeToUsePointData();
 
-  vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
+  vtkSmartPointer<vtkLODActor> actor =
+      vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
   actor->SetMapper(mapper);
 }
 
@@ -161,31 +157,23 @@ pcl::modeler::NormalsActorItem::updateImpl()
 
   vtkSmartPointer<vtkDataArray> scalars;
   cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
-  poly_data_->GetPointData ()->SetScalars (scalars);
+  poly_data_->GetPointData()->SetScalars(scalars);
   double minmax[2];
   scalars->GetRange(minmax);
   actor_->GetMapper()->SetScalarRange(minmax);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::NormalsActorItem::prepareContextMenu(QMenu* ) const
-{
-
-}
+pcl::modeler::NormalsActorItem::prepareContextMenu(QMenu*) const
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::NormalsActorItem::prepareProperties(ParameterDialog* )
-{
-
-}
+pcl::modeler::NormalsActorItem::prepareProperties(ParameterDialog*)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::NormalsActorItem::setProperties()
-{
-
-}
+{}
index 8d639d5f3d19de30ca3057fe3663e4589fbf15ad..c7117d6d570764dd14bc351438709bebecd7cf8b 100755 (executable)
 
 #include <pcl/apps/modeler/parameter.h>
 
-#include <cassert>
-#include <fstream>
-#include <iomanip>
-
 #include <QAbstractItemModel>
 #include <QCheckBox>
 #include <QColorDialog>
 #include <QSpinBox>
 
+#include <cassert>
+#include <fstream>
+#include <iomanip>
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::Parameter::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index)
+pcl::modeler::Parameter::setModelData(QWidget* editor,
+                                      QAbstractItemModel* model,
+                                      const QModelIndex& index)
 {
   getEditorData(editor);
   std::pair<QVariant, int> model_data = toModelData();
   model->setData(index, model_data.first, model_data.second);
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
 std::string
-pcl::modeler::IntParameter::valueTip() 
+pcl::modeler::IntParameter::valueTip()
 {
   return QString("value range: [%1, %3]").arg(low_).arg(high_).toStdString();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-QWidget *
-pcl::modeler::IntParameter::createEditor(QWidget *parent)
+QWidget*
+pcl::modeler::IntParameter::createEditor(QWidgetparent)
 {
-  QSpinBox *editor = new QSpinBox(parent);
+  QSpinBoxeditor = new QSpinBox(parent);
   editor->setMinimum(low_);
   editor->setMaximum(high_);
   editor->setSingleStep(step_);
@@ -76,20 +77,20 @@ pcl::modeler::IntParameter::createEditor(QWidget *parent)
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::IntParameter::setEditorData(QWidget *editor)
+pcl::modeler::IntParameter::setEditorData(QWidgeteditor)
 {
-  QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
+  QSpinBoxspinBox = static_cast<QSpinBox*>(editor);
   spinBox->setAlignment(Qt::AlignHCenter);
 
-  int value = int (*this);
+  int value = int(*this);
   spinBox->setValue(value);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::IntParameter::getEditorData(QWidget *editor)
+pcl::modeler::IntParameter::getEditorData(QWidgeteditor)
 {
-  QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
+  QSpinBoxspinBox = static_cast<QSpinBox*>(editor);
   int value = spinBox->text().toInt();
   current_value_ = value;
 }
@@ -99,42 +100,42 @@ std::pair<QVariant, int>
 pcl::modeler::IntParameter::toModelData()
 {
   std::pair<QVariant, int> model_data;
-  model_data.first = int (*this);
+  model_data.first = int(*this);
   model_data.second = Qt::EditRole;
-  return (model_data);
+  return model_data;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 std::string
-pcl::modeler::BoolParameter::valueTip() 
+pcl::modeler::BoolParameter::valueTip()
 {
   return QString("bool value").toStdString();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-QWidget *
-pcl::modeler::BoolParameter::createEditor(QWidget *parent)
+QWidget*
+pcl::modeler::BoolParameter::createEditor(QWidgetparent)
 {
-  QCheckBox *editor = new QCheckBox(parent);
+  QCheckBoxeditor = new QCheckBox(parent);
 
   return editor;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::BoolParameter::setEditorData(QWidget *editor)
+pcl::modeler::BoolParameter::setEditorData(QWidgeteditor)
 {
-  QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
+  QCheckBoxcheckBox = static_cast<QCheckBox*>(editor);
 
-  bool value = bool (*this);
-  checkBox->setCheckState(value?(Qt::Checked):(Qt::Unchecked));
+  bool value = bool(*this);
+  checkBox->setCheckState(value ? (Qt::Checked) : (Qt::Unchecked));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-  pcl::modeler::BoolParameter::getEditorData(QWidget *editor)
+pcl::modeler::BoolParameter::getEditorData(QWidget* editor)
 {
-  QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
+  QCheckBoxcheckBox = static_cast<QCheckBox*>(editor);
   bool value = (checkBox->checkState() == Qt::Checked);
   current_value_ = value;
 }
@@ -144,23 +145,23 @@ std::pair<QVariant, int>
 pcl::modeler::BoolParameter::toModelData()
 {
   std::pair<QVariant, int> model_data;
-  model_data.first = bool (*this);
+  model_data.first = bool(*this);
   model_data.second = Qt::EditRole;
-  return (model_data);
+  return model_data;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 std::string
-pcl::modeler::DoubleParameter::valueTip() 
+pcl::modeler::DoubleParameter::valueTip()
 {
   return QString("value range: [%1, %3]").arg(low_).arg(high_).toStdString();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-QWidget *
-pcl::modeler::DoubleParameter::createEditor(QWidget *parent)
+QWidget*
+pcl::modeler::DoubleParameter::createEditor(QWidgetparent)
 {
-  QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
+  QDoubleSpinBoxeditor = new QDoubleSpinBox(parent);
   editor->setMinimum(low_);
   editor->setMaximum(high_);
   editor->setSingleStep(step_);
@@ -171,20 +172,20 @@ pcl::modeler::DoubleParameter::createEditor(QWidget *parent)
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::DoubleParameter::setEditorData(QWidget *editor)
+pcl::modeler::DoubleParameter::setEditorData(QWidgeteditor)
 {
-  QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
+  QDoubleSpinBoxspinBox = static_cast<QDoubleSpinBox*>(editor);
   spinBox->setAlignment(Qt::AlignHCenter);
 
-  double value = double (*this);
+  double value = double(*this);
   spinBox->setValue(value);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::DoubleParameter::getEditorData(QWidget *editor)
+pcl::modeler::DoubleParameter::getEditorData(QWidgeteditor)
 {
-  QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
+  QDoubleSpinBoxspinBox = static_cast<QDoubleSpinBox*>(editor);
   double value = spinBox->text().toDouble();
   current_value_ = value;
 }
@@ -194,44 +195,42 @@ std::pair<QVariant, int>
 pcl::modeler::DoubleParameter::toModelData()
 {
   std::pair<QVariant, int> model_data;
-  model_data.first = double (*this);
+  model_data.first = double(*this);
   model_data.second = Qt::EditRole;
-  return (model_data);
+  return model_data;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 std::string
-pcl::modeler::ColorParameter::valueTip() 
+pcl::modeler::ColorParameter::valueTip()
 {
-  return ("Color");
+  return "Color";
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-QWidget *
-pcl::modeler::ColorParameter::createEditor(QWidget *parent)
+QWidget*
+pcl::modeler::ColorParameter::createEditor(QWidgetparent)
 {
-  QColorDialog *editor = new QColorDialog(parent);
+  QColorDialogeditor = new QColorDialog(parent);
 
   return editor;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ColorParameter::setEditorData(QWidget *editor)
+pcl::modeler::ColorParameter::setEditorData(QWidgeteditor)
 {
-  QColorDialog *color_dialog = static_cast<QColorDialog*>(editor);
+  QColorDialogcolor_dialog = static_cast<QColorDialog*>(editor);
 
-  QColor value = QColor (*this);
+  QColor value = QColor(*this);
   color_dialog->setCurrentColor(value);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ColorParameter::getEditorData(QWidget *editor)
+pcl::modeler::ColorParameter::getEditorData(QWidgeteditor)
 {
-  QColorDialog *color_dialog = static_cast<QColorDialog*>(editor);
+  QColorDialogcolor_dialog = static_cast<QColorDialog*>(editor);
 
   QColor value = color_dialog->currentColor();
   current_value_ = value;
@@ -244,5 +243,5 @@ pcl::modeler::ColorParameter::toModelData()
   std::pair<QVariant, int> model_data;
   model_data.first = QBrush(QColor(*this));
   model_data.second = Qt::BackgroundRole;
-  return (model_data);
+  return model_data;
 }
index fcdca246eda7767a0158125d7e1d7e70484c9e4a..dfa6c2156c5a587cabb2c7738ab0e83c70d7e360 100755 (executable)
@@ -1,44 +1,41 @@
 /*
-* Software License Agreement (BSD License)
-*
-*  Point Cloud Library (PCL) - www.pointclouds.org
-*  Copyright (c) 2012, Willow Garage, Inc.
-*  All rights reserved.
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*   * Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*   * Redistributions in binary form must reproduce the above
-*     copyright notice, this list of conditions and the following
-*     disclaimer in the documentation and/or other materials provided
-*     with the distribution.
-*   * Neither the name of Willow Garage, Inc. nor the names of its
-*     contributors may be used to endorse or promote products derived
-*     from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-*  POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2012, Willow Garage, Inc.
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Willow Garage, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
 
-#include <pcl/apps/modeler/parameter_dialog.h>
 #include <pcl/apps/modeler/parameter.h>
-
-#include <cassert>
-#include <fstream>
+#include <pcl/apps/modeler/parameter_dialog.h>
 
 #include <QCheckBox>
 #include <QColorDialog>
 #include <QPushButton>
 #include <QTableView>
 
+#include <cassert>
+#include <fstream>
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::ParameterDialog::addParameter(pcl::modeler::Parameter* parameter)
 {
-  if (name_parameter_map_.find(parameter->getName()) == name_parameter_map_.end())
-  {
+  if (name_parameter_map_.find(parameter->getName()) == name_parameter_map_.end()) {
     name_parameter_map_.insert(std::make_pair(parameter->getName(), parameter));
   }
-  else
-  {
+  else {
     assert(false);
   }
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, QWidget* parent) : QDialog(parent), parameter_model_(nullptr)
+pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title,
+                                               QWidget* parent)
+: QDialog(parent), parameter_model_(nullptr)
 {
   setModal(false);
-  setWindowTitle(QString(title.c_str())+" Parameters");
+  setWindowTitle(QString(title.c_str()) + " Parameters");
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 int
 pcl::modeler::ParameterDialog::exec()
 {
-  pcl::modeler::ParameterModel parameterModel (int (name_parameter_map_.size ()), 2, this);
+  pcl::modeler::ParameterModel parameterModel(int(name_parameter_map_.size()), 2, this);
   parameter_model_ = &parameterModel;
 
   QStringList headerLabels;
@@ -85,16 +84,15 @@ pcl::modeler::ParameterDialog::exec()
   tableView.setModel(&parameterModel);
 
   std::size_t currentRow = 0;
-  for(const auto &name_parameter : name_parameter_map_)
-  {
-    QModelIndex name = parameterModel.index(int (currentRow), 0, QModelIndex());
+  for (const auto& name_parameter : name_parameter_map_) {
+    QModelIndex name = parameterModel.index(int(currentRow), 0, QModelIndex());
     parameterModel.setData(name, QVariant(name_parameter.first.c_str()));
 
-    QModelIndex value = parameterModel.index(int (currentRow), 1, QModelIndex());
+    QModelIndex value = parameterModel.index(int(currentRow), 1, QModelIndex());
     std::pair<QVariant, int> model_data = name_parameter.second->toModelData();
     parameterModel.setData(value, model_data.first, model_data.second);
 
-    currentRow ++;
+    currentRow++;
   }
 
   ParameterDelegate parameterDelegate(name_parameter_map_);
@@ -107,7 +105,8 @@ pcl::modeler::ParameterDialog::exec()
   tableView.setSelectionBehavior(QAbstractItemView::SelectRows);
   tableView.resizeColumnsToContents();
 
-  int totlen = tableView.columnWidth(0) + tableView.columnWidth(1) + frameSize().width();
+  int totlen =
+      tableView.columnWidth(0) + tableView.columnWidth(1) + frameSize().width();
   setMinimumWidth(totlen);
 
   QPushButton* pushButtonReset = new QPushButton("Reset", this);
@@ -135,29 +134,28 @@ void
 pcl::modeler::ParameterDialog::reset()
 {
   std::size_t currentRow = 0;
-  for (auto &name_parameter : name_parameter_map_)
-  {
+  for (auto& name_parameter : name_parameter_map_) {
     name_parameter.second->reset();
 
-    QModelIndex value = parameter_model_->index(int (currentRow), 1, QModelIndex());
+    QModelIndex value = parameter_model_->index(int(currentRow), 1, QModelIndex());
     std::pair<QVariant, int> model_data = name_parameter.second->toModelData();
     parameter_model_->setData(value, model_data.first, model_data.second);
 
-    currentRow ++;
+    currentRow++;
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::Parameter* pcl::modeler::ParameterDelegate::getCurrentParameter(const QModelIndex &index) const
+pcl::modeler::Parameter*
+pcl::modeler::ParameterDelegate::getCurrentParameter(const QModelIndex& index) const
 {
   std::map<std::string, Parameter*>::iterator currentParameter = parameter_map_.begin();
 
   std::size_t currentRow = 0;
-  while(currentRow < (std::size_t) index.row() && currentParameter != parameter_map_.end()) {
-    ++ currentParameter;
-    ++ currentRow;
+  while (currentRow < (std::size_t)index.row() &&
+         currentParameter != parameter_map_.end()) {
+    ++currentParameter;
+    ++currentRow;
   }
 
   assert(currentParameter != parameter_map_.end());
@@ -166,43 +164,49 @@ pcl::modeler::Parameter* pcl::modeler::ParameterDelegate::getCurrentParameter(co
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ParameterDelegate::ParameterDelegate(std::map<std::string, Parameter*>& parameterMap, QObject *parent):
-  QStyledItemDelegate(parent),
-  parameter_map_(parameterMap)
-{
-}
+pcl::modeler::ParameterDelegate::ParameterDelegate(
+    std::map<std::string, Parameter*>& parameterMap, QObject* parent)
+: QStyledItemDelegate(parent), parameter_map_(parameterMap)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-QWidget *
-pcl::modeler::ParameterDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
+QWidget*
+pcl::modeler::ParameterDelegate::createEditor(QWidget* parent,
+                                              const QStyleOptionViewItem&,
+                                              const QModelIndex& index) const
 {
   return getCurrentParameter(index)->createEditor(parent);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ParameterDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
+pcl::modeler::ParameterDelegate::setEditorData(QWidget* editor,
+                                               const QModelIndex& index) const
 {
   getCurrentParameter(index)->setEditorData(editor);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ParameterDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
+pcl::modeler::ParameterDelegate::setModelData(QWidget* editor,
+                                              QAbstractItemModel* model,
+                                              const QModelIndex& index) const
 {
   getCurrentParameter(index)->setModelData(editor, model, index);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ParameterDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const
+pcl::modeler::ParameterDelegate::updateEditorGeometry(
+    QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const
 {
   editor->setGeometry(option.rect);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ParameterDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
+pcl::modeler::ParameterDelegate::initStyleOption(QStyleOptionViewItem* option,
+                                                 const QModelIndex& index) const
 {
   option->displayAlignment |= Qt::AlignHCenter;
   QStyledItemDelegate::initStyleOption(option, index);
index 97aae6916a7ebdc144427058e9841370d0044409..c9adf0624e233ec2550a794b37bec74ec84ad6bc 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/points_actor_item.h>
-
 #include <pcl/apps/modeler/cloud_mesh.h>
+#include <pcl/apps/modeler/points_actor_item.h>
 
-#include <vtkVertexGlyphFilter.h>
-#include <vtkLODActor.h>
 #include <vtkDataSetMapper.h>
+#include <vtkLODActor.h>
 #include <vtkPointData.h>
 #include <vtkProperty.h>
-
+#include <vtkVertexGlyphFilter.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::PointsActorItem::PointsActorItem(QTreeWidgetItem* parent,
-                                               const CloudMesh::Ptr& cloud_mesh,
-                                               const vtkSmartPointer<vtkRenderWindow>& render_window)
-  :ChannelActorItem(parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Points")
-{
-}
+pcl::modeler::PointsActorItem::PointsActorItem(
+    QTreeWidgetItem* parent,
+    const CloudMesh::Ptr& cloud_mesh,
+    const vtkSmartPointer<vtkRenderWindow>& render_window)
+: ChannelActorItem(
+      parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Points")
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::PointsActorItem::~PointsActorItem ()
-{
-
-}
+pcl::modeler::PointsActorItem::~PointsActorItem() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -65,8 +61,9 @@ pcl::modeler::PointsActorItem::initImpl()
 {
   poly_data_->SetPoints(cloud_mesh_->getVtkPoints());
 
-  vtkSmartPointer<vtkVertexGlyphFilter> vertex_glyph_filter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
-  vertex_glyph_filter->AddInputData (poly_data_);
+  vtkSmartPointer<vtkVertexGlyphFilter> vertex_glyph_filter =
+      vtkSmartPointer<vtkVertexGlyphFilter>::New();
+  vertex_glyph_filter->AddInputData(poly_data_);
   vertex_glyph_filter->Update();
 
   vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
@@ -74,7 +71,7 @@ pcl::modeler::PointsActorItem::initImpl()
 
   vtkSmartPointer<vtkDataArray> scalars;
   cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
-  poly_data_->GetPointData ()->SetScalars (scalars);
+  poly_data_->GetPointData()->SetScalars(scalars);
 
   double minmax[2];
   scalars->GetRange(minmax);
@@ -87,10 +84,12 @@ pcl::modeler::PointsActorItem::initImpl()
   mapper->ImmediateModeRenderingOff();
 #endif
 
-  vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
+  vtkSmartPointer<vtkLODActor> actor =
+      vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
   actor->SetMapper(mapper);
 
-  actor->SetNumberOfCloudPoints(int(std::max<vtkIdType> (1, poly_data_->GetNumberOfPoints () / 10)));
+  actor->SetNumberOfCloudPoints(
+      int(std::max<vtkIdType>(1, poly_data_->GetNumberOfPoints() / 10)));
   actor->GetProperty()->SetInterpolationToFlat();
 }
 
@@ -100,33 +99,24 @@ pcl::modeler::PointsActorItem::updateImpl()
 {
   vtkSmartPointer<vtkDataArray> scalars;
   cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
-  poly_data_->GetPointData ()->SetScalars (scalars);
+  poly_data_->GetPointData()->SetScalars(scalars);
 
   double minmax[2];
   scalars->GetRange(minmax);
   actor_->GetMapper()->SetScalarRange(minmax);
-
-  return;
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::PointsActorItem::prepareContextMenu(QMenu*) const
-{
-
-}
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::PointsActorItem::prepareProperties(ParameterDialog*)
-{
-
-}
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::PointsActorItem::setProperties()
-{
-
-}
+{}
index 64bc2f837537fb150c59b4b3985235b9935e581d..49b2e750497001c2493400067fb2651a2a1d2dac 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/poisson_worker.h>
-#include <pcl/apps/modeler/parameter_dialog.h>
-#include <pcl/apps/modeler/parameter.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
-#include <pcl/surface/poisson.h>
+#include <pcl/apps/modeler/parameter.h>
+#include <pcl/apps/modeler/parameter_dialog.h>
+#include <pcl/apps/modeler/poisson_worker.h>
 #include <pcl/surface/impl/poisson.hpp>
+#include <pcl/surface/poisson.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::PoissonReconstructionWorker::PoissonReconstructionWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent) :
-  AbstractWorker(cloud_mesh_items, parent),
-  depth_(nullptr), solver_divide_(nullptr), iso_divide_(nullptr), degree_(nullptr), scale_(nullptr), samples_per_node_(nullptr)
-{
-
-}
+pcl::modeler::PoissonReconstructionWorker::PoissonReconstructionWorker(
+    const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent)
+: AbstractWorker(cloud_mesh_items, parent)
+, depth_(nullptr)
+, solver_divide_(nullptr)
+, iso_divide_(nullptr)
+, degree_(nullptr)
+, scale_(nullptr)
+, samples_per_node_(nullptr)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::PoissonReconstructionWorker::~PoissonReconstructionWorker()
@@ -66,43 +70,52 @@ void
 pcl::modeler::PoissonReconstructionWorker::setupParameters()
 {
   pcl::Poisson<pcl::PointSurfel> poisson;
-  depth_ = new IntParameter("Maximum Tree Depth",
-    "Maximum depth of the tree that will be used for surface reconstruction. \
-    Running at depth d corresponds to solving on a voxel grid whose resolution \
-    is no larger than 2^d x 2^d x 2^d. Note that since the reconstructor adapts \
-    the octree to the sampling density, the specified reconstruction depth \
-    is only an upper bound.",
-    poisson.getDepth(), 2, 16);
-
-  solver_divide_ = new IntParameter("Solver Divide",
-    "The depth at which a block Gauss-Seidel solver is used to solve the Laplacian \
-    equation. Using this parameter helps reduce the memory overhead at the cost of \
-    a small increase in reconstruction time. (In practice, we have found that for \
-    reconstructions of depth 9 or higher a subdivide depth of 7 or 8 can greatly \
-    reduce the memory usage.)",
-    poisson.getSolverDivide(), 2, 16);
 
-  iso_divide_ = new IntParameter("Iso Divide",
-    "Depth at which a block iso-surface extractor should be used to extract the \
-    iso-surface. Using this parameter helps reduce the memory overhead at the cost \
-    of a small increase in extraction time. (In practice, we have found that for \
-    reconstructions of depth 9 or higher a subdivide depth of 7 or 8 can greatly \
-    reduce the memory usage.)",
-    poisson.getIsoDivide(), 2, 16);
+  // clang-format off
+  depth_ = new IntParameter(
+      "Maximum Tree Depth",
+      "Maximum depth of the tree that will be used for surface reconstruction. "
+      "Running at depth d corresponds to solving on a voxel grid whose resolution "
+      "is no larger than 2^d x 2^d x 2^d. Note that since the reconstructor adapts "
+      "the octree to the sampling density, the specified reconstruction depth "
+      "is only an upper bound.",
+      poisson.getDepth(), 2, 16);
+
+  solver_divide_ = new IntParameter(
+      "Solver Divide",
+      "The depth at which a block Gauss-Seidel solver is used to solve the Laplacian "
+      "equation. Using this parameter helps reduce the memory overhead at the cost of "
+      "a small increase in reconstruction time. (In practice, we have found that for "
+      "reconstructions of depth 9 or higher a subdivide depth of 7 or 8 can greatly "
+      "reduce the memory usage.)",
+      poisson.getSolverDivide(), 2, 16);
+
+  iso_divide_ = new IntParameter(
+      "Iso Divide",
+      "Depth at which a block iso-surface extractor should be used to extract the "
+      "iso-surface. Using this parameter helps reduce the memory overhead at the cost "
+      "of a small increase in extraction time. (In practice, we have found that for "
+      "reconstructions of depth 9 or higher a subdivide depth of 7 or 8 can greatly "
+      "reduce the memory usage.)",
+      poisson.getIsoDivide(), 2, 16);
 
   degree_ = new IntParameter("Degree", "Degree", poisson.getDegree(), 1, 5);
 
-  scale_ = new DoubleParameter("Scale",
-    "The ratio between the diameter of the cube used for reconstruction and the \
-    diameter of the samples' bounding cube.",
-    poisson.getScale(), 0.1, 10.0, 0.01);
-
-  samples_per_node_ = new DoubleParameter("Samples Per Node",
-    "The minimum number of sample points that should fall within an octree node as \
-    the octree construction is adapted to sampling density. For noise-free samples, small \
-    values in the range [1.0 - 5.0] can be used. For more noisy samples, larger values in \
-    the range [15.0 - 20.0] may be needed to provide a smoother, noise-reduced, reconstruction.",
-    poisson.getScale(), 0.1, 10.0, 0.01);
+  scale_ = new DoubleParameter(
+      "Scale",
+      "The ratio between the diameter of the cube used for reconstruction and the "
+      "diameter of the samples' bounding cube.",
+      poisson.getScale(), 0.1, 10.0, 0.01);
+
+  samples_per_node_ = new DoubleParameter(
+      "Samples Per Node",
+      "The minimum number of sample points that should fall within an octree node as "
+      "the octree construction is adapted to sampling density. For noise-free samples, "
+      "small values in the range [1.0 - 5.0] can be used. For more noisy samples, "
+      "larger values in the range [15.0 - 20.0] may be needed to provide a smoother, "
+      "noise-reduced, reconstruction.",
+      poisson.getScale(), 0.1, 10.0, 0.01);
+  // clang-format on
 
   parameter_dialog_->addParameter(depth_);
   parameter_dialog_->addParameter(solver_divide_);
@@ -110,8 +123,6 @@ pcl::modeler::PoissonReconstructionWorker::setupParameters()
   parameter_dialog_->addParameter(degree_);
   parameter_dialog_->addParameter(scale_);
   parameter_dialog_->addParameter(samples_per_node_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -123,8 +134,8 @@ pcl::modeler::PoissonReconstructionWorker::processImpl(CloudMeshItem* cloud_mesh
   poisson.setSolverDivide(*solver_divide_);
   poisson.setIsoDivide(*iso_divide_);
   poisson.setDegree(*degree_);
-  poisson.setScale (float (*scale_));
-  poisson.setScale (float (*samples_per_node_));
+  poisson.setScale(float(*scale_));
+  poisson.setScale(float(*samples_per_node_));
 
   poisson.setConfidence(true);
   poisson.setManifold(true);
@@ -134,6 +145,4 @@ pcl::modeler::PoissonReconstructionWorker::processImpl(CloudMeshItem* cloud_mesh
   CloudMesh::PointCloudPtr cloud(new CloudMesh::PointCloud());
   poisson.reconstruct(*cloud, cloud_mesh_item->getCloudMesh()->getPolygons());
   cloud_mesh_item->getCloudMesh()->getCloud() = cloud;
-
-  return;
 }
index e72575dab54d4c6b717b264b0ea948e6feb0b861..73c5fd0647b418682145d35d96fdac9889292e63 100755 (executable)
  *
  */
 
+#include <pcl/apps/modeler/dock_widget.h>
+#include <pcl/apps/modeler/main_window.h>
 #include <pcl/apps/modeler/render_window.h>
 #include <pcl/apps/modeler/render_window_item.h>
 #include <pcl/apps/modeler/scene_tree.h>
-#include <pcl/apps/modeler/dock_widget.h>
-#include <pcl/apps/modeler/main_window.h>
-#include <vtkProp.h>
-#include <vtkRenderer.h>
+
 #include <vtkBoundingBox.h>
-#include <vtkSmartPointer.h>
-#include <vtkRenderWindow.h>
 #include <vtkCubeAxesActor.h>
+#include <vtkProp.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderer.h>
 #include <vtkRendererCollection.h>
-
+#include <vtkSmartPointer.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::RenderWindow::RenderWindow(RenderWindowItem* render_window_item, QWidget *parent, Qt::WindowFlags flags)
-  : QVTKWidget(parent, flags),
-  axes_(vtkSmartPointer<vtkCubeAxesActor>::New()),
-  render_window_item_(render_window_item)
+pcl::modeler::RenderWindow::RenderWindow(RenderWindowItem* render_window_item,
+                                         QWidget* parent,
+                                         Qt::WindowFlags flags)
+: QVTKWidget(parent, flags)
+, axes_(vtkSmartPointer<vtkCubeAxesActor>::New())
+, render_window_item_(render_window_item)
 {
   setFocusPolicy(Qt::StrongFocus);
   initRenderer();
@@ -64,13 +66,10 @@ pcl::modeler::RenderWindow::RenderWindow(RenderWindowItem* render_window_item, Q
 pcl::modeler::RenderWindow::~RenderWindow()
 {
   DockWidget* dock_widget = dynamic_cast<DockWidget*>(parent());
-  if (dock_widget != nullptr)
-  {
+  if (dock_widget != nullptr) {
     MainWindow::getInstance().removeDockWidget(dock_widget);
     dock_widget->deleteLater();
   }
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
@@ -82,30 +81,29 @@ pcl::modeler::RenderWindow::initRenderer()
   win->AddRenderer(renderer);
 
   // FPS callback
-  //vtkSmartPointer<vtkTextActor> txt = vtkSmartPointer<vtkTextActor>::New ();
-  //using FPSCallback = pcl::visualization::FPSCallback;
-  //vtkSmartPointer<FPSCallback> update_fps = vtkSmartPointer<FPSCallback>::New ();
-  //update_fps->setTextActor (txt);
-  //renderer->AddObserver (vtkCommand::EndEvent, update_fps);
-  //renderer->AddActor (txt);
+  // vtkSmartPointer<vtkTextActor> txt = vtkSmartPointer<vtkTextActor>::New ();
+  // using FPSCallback = pcl::visualization::FPSCallback;
+  // vtkSmartPointer<FPSCallback> update_fps = vtkSmartPointer<FPSCallback>::New ();
+  // update_fps->setTextActor (txt);
+  // renderer->AddObserver (vtkCommand::EndEvent, update_fps);
+  // renderer->AddActor (txt);
 
   // Set up render window
-  win->AlphaBitPlanesOff ();
-  win->PointSmoothingOff ();
-  win->LineSmoothingOff ();
-  win->PolygonSmoothingOff ();
-  win->SwapBuffersOn ();
-  win->SetStereoTypeToAnaglyph ();
-  win->GetInteractor()->SetDesiredUpdateRate (30.0);
-
-  return;
+  win->AlphaBitPlanesOff();
+  win->PointSmoothingOff();
+  win->LineSmoothingOff();
+  win->PolygonSmoothingOff();
+  win->SwapBuffersOn();
+  win->SetStereoTypeToAnaglyph();
+  win->GetInteractor()->SetDesiredUpdateRate(30.0);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::RenderWindow::focusInEvent(QFocusEvent * event)
+pcl::modeler::RenderWindow::focusInEvent(QFocusEvent* event)
 {
-  dynamic_cast<SceneTree*>(render_window_item_->treeWidget())->selectRenderWindowItem(render_window_item_);
+  dynamic_cast<SceneTree*>(render_window_item_->treeWidget())
+      ->selectRenderWindowItem(render_window_item_);
 
   QVTKWidget::focusInEvent(event);
 }
@@ -117,8 +115,6 @@ pcl::modeler::RenderWindow::setActive(bool flag)
   DockWidget* dock_widget = dynamic_cast<DockWidget*>(parent());
   if (dock_widget != nullptr)
     dock_widget->setFocusBasedStyle(flag);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -128,8 +124,6 @@ pcl::modeler::RenderWindow::setTitle(const QString& title)
   DockWidget* dock_widget = dynamic_cast<DockWidget*>(parent());
   if (dock_widget != nullptr)
     dock_widget->setWindowTitle(title);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -144,7 +138,8 @@ void
 pcl::modeler::RenderWindow::resetCamera()
 {
   double bounds[6];
-  GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ComputeVisiblePropBounds(bounds);
+  GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ComputeVisiblePropBounds(
+      bounds);
   GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera(bounds);
   render();
 }
@@ -163,18 +158,17 @@ pcl::modeler::RenderWindow::setBackground(double r, double g, double b)
   GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(r, g, b);
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::RenderWindow::updateAxes()
 {
   vtkBoundingBox bb;
 
-  vtkActorCollection* actors = GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActors();
+  vtkActorCollection* actors =
+      GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActors();
 
   actors->InitTraversal();
-  for (int i = 0, i_end = actors->GetNumberOfItems(); i < i_end; ++ i)
-  {
+  for (int i = 0, i_end = actors->GetNumberOfItems(); i < i_end; ++i) {
     vtkActor* actor = actors->GetNextActor();
     if (actor == axes_.GetPointer())
       continue;
@@ -187,7 +181,8 @@ pcl::modeler::RenderWindow::updateAxes()
   double bounds[6];
   bb.GetBounds(bounds);
   axes_->SetBounds(bounds);
-  axes_->SetCamera(GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera());
+  axes_->SetCamera(
+      GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera());
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -198,6 +193,4 @@ pcl::modeler::RenderWindow::setShowAxes(bool flag)
     GetRenderWindow()->GetRenderers()->GetFirstRenderer()->AddActor(axes_);
   else
     GetRenderWindow()->GetRenderers()->GetFirstRenderer()->RemoveActor(axes_);
-
-  return;
 }
index 1c9e6cfb026d8ae41739bba83811c530bddffa94..0b24410b341f04f67df40e5cfdf974c1c1b93858 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/render_window_item.h>
-#include <pcl/apps/modeler/render_window.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
 #include <pcl/apps/modeler/main_window.h>
 #include <pcl/apps/modeler/parameter.h>
 #include <pcl/apps/modeler/parameter_dialog.h>
-
+#include <pcl/apps/modeler/render_window.h>
+#include <pcl/apps/modeler/render_window_item.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::RenderWindowItem::RenderWindowItem(QTreeWidget * parent)
-  : QTreeWidgetItem(parent),
-  render_window_(new RenderWindow(this)),
-  background_color_(new ColorParameter("Background Color", "The background color of the render window", QColor(0, 0, 0))),
-  show_axes_(new BoolParameter("Show Axes", "Show Axes", true))
+pcl::modeler::RenderWindowItem::RenderWindowItem(QTreeWidget* parent)
+: QTreeWidgetItem(parent)
+, render_window_(new RenderWindow(this))
+, background_color_(new ColorParameter(
+      "Background Color", "The background color of the render window", QColor(0, 0, 0)))
+, show_axes_(new BoolParameter("Show Axes", "Show Axes", true))
 {
-  setFlags(flags()&(~Qt::ItemIsDragEnabled));
+  setFlags(flags() & (~Qt::ItemIsDragEnabled));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::RenderWindowItem::~RenderWindowItem()
-{
-  render_window_->deleteLater();
-}
+pcl::modeler::RenderWindowItem::~RenderWindowItem() { render_window_->deleteLater(); }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 bool
@@ -65,16 +62,15 @@ pcl::modeler::RenderWindowItem::openPointCloud(const QString& filename)
   CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, filename.toStdString());
   addChild(cloud_mesh_item);
 
-  if (!cloud_mesh_item->open())
-  {
+  if (!cloud_mesh_item->open()) {
     removeChild(cloud_mesh_item);
     delete cloud_mesh_item;
-    return (false);
+    return false;
   }
 
   treeWidget()->setCurrentItem(cloud_mesh_item);
 
-  return (true);
+  return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -86,7 +82,7 @@ pcl::modeler::RenderWindowItem::addPointCloud(CloudMesh::PointCloudPtr cloud)
 
   treeWidget()->setCurrentItem(cloud_mesh_item);
 
-  return (cloud_mesh_item);
+  return cloud_mesh_item;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -105,7 +101,8 @@ pcl::modeler::RenderWindowItem::prepareProperties(ParameterDialog* parameter_dia
 {
   double r, g, b;
   render_window_->getBackground(r, g, b);
-  QColor color(static_cast<int> (r*255), static_cast<int> (g*255), static_cast<int> (b*255));
+  QColor color(
+      static_cast<int>(r * 255), static_cast<int>(g * 255), static_cast<int>(b * 255));
   background_color_->setDefaultValue(color);
   parameter_dialog->addParameter(background_color_);
   parameter_dialog->addParameter(show_axes_);
@@ -116,9 +113,8 @@ void
 pcl::modeler::RenderWindowItem::setProperties()
 {
   QColor color = *background_color_;
-  render_window_->setBackground(color.red()/255.0, color.green()/255.0, color.blue()/255.0);
+  render_window_->setBackground(
+      color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0);
 
   render_window_->setShowAxes(*show_axes_);
-
-  return;
 }
index 274629581b71fb9189e3056c37c2fced0bd9ab9e..c923ee3b915bb86ab13a7ed29d2c2d03ceb2a187 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/scene_tree.h>
-
-#include <set>
-
-#include <QContextMenuEvent>
-#include <QFileDialog>
-#include <QMessageBox>
-
+#include <pcl/apps/modeler/cloud_mesh_item.h>
+#include <pcl/apps/modeler/cloud_mesh_item_updater.h>
+#include <pcl/apps/modeler/icp_registration_worker.h>
 #include <pcl/apps/modeler/main_window.h>
+#include <pcl/apps/modeler/normal_estimation_worker.h>
+#include <pcl/apps/modeler/poisson_worker.h>
 #include <pcl/apps/modeler/render_window.h>
 #include <pcl/apps/modeler/render_window_item.h>
-#include <pcl/apps/modeler/cloud_mesh_item.h>
-#include <pcl/apps/modeler/cloud_mesh_item_updater.h>
+#include <pcl/apps/modeler/scene_tree.h>
+#include <pcl/apps/modeler/statistical_outlier_removal_worker.h>
 #include <pcl/apps/modeler/thread_controller.h>
 #include <pcl/apps/modeler/voxel_grid_downsample_worker.h>
-#include <pcl/apps/modeler/statistical_outlier_removal_worker.h>
-#include <pcl/apps/modeler/normal_estimation_worker.h>
-#include <pcl/apps/modeler/icp_registration_worker.h>
-#include <pcl/apps/modeler/poisson_worker.h>
 #include <pcl/io/pcd_io.h>
 
+#include <QContextMenuEvent>
+#include <QFileDialog>
+#include <QMessageBox>
+
+#include <set>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::SceneTree::SceneTree(QWidget * parent)
-  : QTreeWidget(parent)
+pcl::modeler::SceneTree::SceneTree(QWidget* parent) : QTreeWidget(parent)
 {
   setDragEnabled(true);
   setAcceptDrops(true);
@@ -67,18 +64,22 @@ pcl::modeler::SceneTree::SceneTree(QWidget * parent)
 
   setSelectionMode(QAbstractItemView::ExtendedSelection);
 
-  connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
-    this, SLOT(slotUpdateOnSelectionChange(QItemSelection, const QItemSelection)));
+  connect(selectionModel(),
+          SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+          this,
+          SLOT(slotUpdateOnSelectionChange(QItemSelection, const QItemSelection)));
 
-  connect(this, SIGNAL(itemInsertedOrRemoved()),this, SLOT(slotUpdateOnInsertOrRemove()));
+  connect(
+      this, SIGNAL(itemInsertedOrRemoved()), this, SLOT(slotUpdateOnInsertOrRemove()));
 
-  connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),this, SLOT(slotOnItemDoubleClicked(QTreeWidgetItem*)));
+  connect(this,
+          SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
+          this,
+          SLOT(slotOnItemDoubleClicked(QTreeWidgetItem*)));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::SceneTree::~SceneTree()
-{
-}
+pcl::modeler::SceneTree::~SceneTree() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 QSize
@@ -93,175 +94,165 @@ pcl::modeler::SceneTree::selectedRenderWindowItems() const
 {
   QList<RenderWindowItem*> selected_render_window_items;
   if (topLevelItemCount() == 1)
-    selected_render_window_items.push_back(dynamic_cast<RenderWindowItem*>(topLevelItem(0)));
+    selected_render_window_items.push_back(
+        dynamic_cast<RenderWindowItem*>(topLevelItem(0)));
   else
     selected_render_window_items = selectedTypeItems<RenderWindowItem>();
 
-  return (selected_render_window_items);
+  return selected_render_window_items;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::SceneTree::contextMenuEvent(QContextMenuEvent *event)
+pcl::modeler::SceneTree::contextMenuEvent(QContextMenuEventevent)
 {
   AbstractItem* item = dynamic_cast<AbstractItem*>(currentItem());
   item->showContextMenu(&(event->globalPos()));
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::SceneTree::slotOnItemDoubleClicked(QTreeWidgetItem * item)
+pcl::modeler::SceneTree::slotOnItemDoubleClicked(QTreeWidgetItem* item)
 {
   AbstractItem* abstract_item = dynamic_cast<AbstractItem*>(item);
   abstract_item->showPropertyEditor();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-bool 
+bool
 pcl::modeler::SceneTree::openPointCloud(const QString& filename)
 {
   QList<RenderWindowItem*> selected_render_window_items = selectedRenderWindowItems();
 
-  for (auto &selected_render_window_item : selected_render_window_items)
-  {
-    if(!selected_render_window_item->openPointCloud(filename))
-      return (false);
+  for (auto& selected_render_window_item : selected_render_window_items) {
+    if (!selected_render_window_item->openPointCloud(filename))
+      return false;
     expandItem(selected_render_window_item);
   }
 
   emit fileOpened(filename);
 
-  return (true);
+  return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-bool 
+bool
 pcl::modeler::SceneTree::savePointCloud(const QString& filename)
 {
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
 
-  return (CloudMeshItem::savePointCloud(selected_cloud_mesh_items, filename));
+  return CloudMeshItem::savePointCloud(selected_cloud_mesh_items, filename);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::SceneTree::slotOpenPointCloud()
 {
   MainWindow* main_window = &MainWindow::getInstance();
   QList<RenderWindowItem*> selected_render_window_items = selectedRenderWindowItems();
 
-  if (selected_render_window_items.empty())
-  {
-    QMessageBox::warning(main_window, 
-    tr("Failed to Open Point Cloud"), 
-    tr("Please specify in which render window(s) you want to open the point cloud(s)"));
+  if (selected_render_window_items.empty()) {
+    QMessageBox::warning(main_window,
+                         tr("Failed to Open Point Cloud"),
+                         tr("Please specify in which render window(s) you want to open "
+                            "the point cloud(s)"));
     return;
   }
 
   QStringList filenames = QFileDialog::getOpenFileNames(main_window,
-    tr("Open Point Cloud"),
-    main_window->getRecentFolder(),
-    tr("Point Cloud(*.pcd)\n")
-    );
+                                                        tr("Open Point Cloud"),
+                                                        main_window->getRecentFolder(),
+                                                        tr("Point Cloud(*.pcd)\n"));
 
   if (filenames.isEmpty())
     return;
 
-  for (const auto &render_window_item : selected_render_window_items)
-  {
+  for (const auto& render_window_item : selected_render_window_items) {
     QList<CloudMeshItem*> cloud_mesh_items;
-    for (int i = 0, i_end = render_window_item->childCount(); i < i_end; ++ i)
-      cloud_mesh_items.push_back(dynamic_cast<CloudMeshItem*>(render_window_item->child(i)));
+    for (int i = 0, i_end = render_window_item->childCount(); i < i_end; ++i)
+      cloud_mesh_items.push_back(
+          dynamic_cast<CloudMeshItem*>(render_window_item->child(i)));
 
     closePointCloud(cloud_mesh_items);
   }
 
   for (QStringList::const_iterator filenames_it = filenames.begin();
-    filenames_it != filenames.end();
-    ++ filenames_it)
-  {
+       filenames_it != filenames.end();
+       ++filenames_it) {
     if (!openPointCloud(*filenames_it))
-      QMessageBox::warning(main_window, 
-      tr("Failed to Open Point Cloud"), 
-      tr("Can not open point cloud file %1, please check if it's in valid .pcd format!").arg(*filenames_it));
+      QMessageBox::warning(main_window,
+                           tr("Failed to Open Point Cloud"),
+                           tr("Can not open point cloud file %1, please check if it's "
+                              "in valid .pcd format!")
+                               .arg(*filenames_it));
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::SceneTree::slotImportPointCloud()
 {
   MainWindow* main_window = &MainWindow::getInstance();
 
-  if (selectedRenderWindowItems().empty())
-  {
-    QMessageBox::warning(main_window, 
-      tr("Failed to Import Point Cloud"), 
-      tr("Please specify in which render window(s) you want to import the point cloud(s)"));
+  if (selectedRenderWindowItems().empty()) {
+    QMessageBox::warning(main_window,
+                         tr("Failed to Import Point Cloud"),
+                         tr("Please specify in which render window(s) you want to "
+                            "import the point cloud(s)"));
     return;
   }
 
   QStringList filenames = QFileDialog::getOpenFileNames(main_window,
-    tr("Import Point Cloud"),
-    main_window->getRecentFolder(),
-    tr("Point Cloud(*.pcd)\n")
-    );
+                                                        tr("Import Point Cloud"),
+                                                        main_window->getRecentFolder(),
+                                                        tr("Point Cloud(*.pcd)\n"));
   if (filenames.isEmpty())
     return;
 
   for (QStringList::const_iterator filenames_it = filenames.begin();
-    filenames_it != filenames.end();
-    ++ filenames_it)
-  {
+       filenames_it != filenames.end();
+       ++filenames_it) {
     if (!openPointCloud(*filenames_it))
-      QMessageBox::warning(main_window, 
-      tr("Failed to Import Point Cloud"), 
-      tr("Can not import point cloud file %1, please check if it's in valid .pcd format!").arg(*filenames_it));
+      QMessageBox::warning(
+          main_window,
+          tr("Failed to Import Point Cloud"),
+          tr("Can not import point cloud file %1 as .pcd file!").arg(*filenames_it));
   }
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::SceneTree::slotSavePointCloud()
 {
   MainWindow* main_window = &MainWindow::getInstance();
 
-  if (selectedTypeItems<CloudMeshItem>().empty())
-  {
-    QMessageBox::warning(main_window, 
-      tr("Failed to Save Point Cloud"), 
-      tr("Please specify the point cloud(s) you want to save"));
+  if (selectedTypeItems<CloudMeshItem>().empty()) {
+    QMessageBox::warning(main_window,
+                         tr("Failed to Save Point Cloud"),
+                         tr("Please specify the point cloud(s) you want to save"));
     return;
   }
 
   QString filename = QFileDialog::getSaveFileName(main_window,
-    tr("Save Point Cloud"),
-    main_window->getRecentFolder(),
-    tr("Save Cloud(*.pcd)\n"));
+                                                  tr("Save Point Cloud"),
+                                                  main_window->getRecentFolder(),
+                                                  tr("Save Cloud(*.pcd)\n"));
 
   if (filename.isEmpty())
     return;
 
   savePointCloud(filename);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::SceneTree::closePointCloud(const QList<CloudMeshItem*>& items)
 {
   QList<RenderWindowItem*> render_window_items;
 
-  for (const auto &item : items)
-  {
-    RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(item->parent());
+  for (const auto& item : items) {
+    RenderWindowItem* render_window_item =
+        dynamic_cast<RenderWindowItem*>(item->parent());
     if (render_window_item != nullptr)
       render_window_items.push_back(render_window_item);
 
@@ -269,34 +260,29 @@ pcl::modeler::SceneTree::closePointCloud(const QList<CloudMeshItem*>& items)
     delete item;
   }
 
-  for (QList<RenderWindowItem*>::const_iterator render_window_items_it = render_window_items.begin();
-    render_window_items_it != render_window_items.end();
-    ++ render_window_items_it)
-  {
+  for (QList<RenderWindowItem*>::const_iterator render_window_items_it =
+           render_window_items.begin();
+       render_window_items_it != render_window_items.end();
+       ++render_window_items_it) {
     (*render_window_items_it)->getRenderWindow()->render();
   }
-  
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::modeler::SceneTree::slotClosePointCloud()
 {
   MainWindow* main_window = &MainWindow::getInstance();
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
 
-  if (selected_cloud_mesh_items.empty())
-  {
-    QMessageBox::warning(main_window, 
-      tr("Failed to Close Point Cloud"), 
-      tr("Please specify the point cloud(s) you want to close"));
+  if (selected_cloud_mesh_items.empty()) {
+    QMessageBox::warning(main_window,
+                         tr("Failed to Close Point Cloud"),
+                         tr("Please specify the point cloud(s) you want to close"));
     return;
   }
 
   closePointCloud(selected_cloud_mesh_items);
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
@@ -306,20 +292,21 @@ pcl::modeler::SceneTree::slotICPRegistration()
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
   CloudMesh::PointCloudPtr result(new CloudMesh::PointCloud());
 
-  AbstractWorker* worker = new ICPRegistrationWorker(result, selected_cloud_mesh_items,&MainWindow::getInstance());
+  AbstractWorker* worker = new ICPRegistrationWorker(
+      result, selected_cloud_mesh_items, &MainWindow::getInstance());
   ThreadController* thread_controller = new ThreadController();
 
   QList<RenderWindowItem*> selected_render_window_items = selectedRenderWindowItems();
-  for (auto &selected_render_window_item : selected_render_window_items)
-  {
+  for (auto& selected_render_window_item : selected_render_window_items) {
     CloudMeshItem* cloud_mesh_item = selected_render_window_item->addPointCloud(result);
     expandItem(selected_render_window_item);
-    connect(worker, SIGNAL(finished()), new CloudMeshItemUpdater(cloud_mesh_item), SLOT(updateCloudMeshItem()));
+    connect(worker,
+            SIGNAL(finished()),
+            new CloudMeshItemUpdater(cloud_mesh_item),
+            SLOT(updateCloudMeshItem()));
   }
-  
-  thread_controller->runWorker(worker);
 
-  return;
+  thread_controller->runWorker(worker);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
@@ -327,12 +314,14 @@ void
 pcl::modeler::SceneTree::slotVoxelGridDownsampleFilter()
 {
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
-  AbstractWorker* worker = new VoxelGridDownampleWorker(selected_cloud_mesh_items,&MainWindow::getInstance());
+  AbstractWorker* worker = new VoxelGridDownampleWorker(selected_cloud_mesh_items,
+                                                        &MainWindow::getInstance());
   ThreadController* thread_controller = new ThreadController();
-  connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
+  connect(worker,
+          SIGNAL(dataUpdated(CloudMeshItem*)),
+          thread_controller,
+          SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
   thread_controller->runWorker(worker);
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
@@ -340,12 +329,14 @@ void
 pcl::modeler::SceneTree::slotStatisticalOutlierRemovalFilter()
 {
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
-  AbstractWorker* worker = new StatisticalOutlierRemovalWorker(selected_cloud_mesh_items,&MainWindow::getInstance());
+  AbstractWorker* worker = new StatisticalOutlierRemovalWorker(
+      selected_cloud_mesh_items, &MainWindow::getInstance());
   ThreadController* thread_controller = new ThreadController();
-  connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
+  connect(worker,
+          SIGNAL(dataUpdated(CloudMeshItem*)),
+          thread_controller,
+          SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
   thread_controller->runWorker(worker);
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
@@ -353,12 +344,14 @@ void
 pcl::modeler::SceneTree::slotEstimateNormal()
 {
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
-  AbstractWorker* worker = new NormalEstimationWorker(selected_cloud_mesh_items,&MainWindow::getInstance());
+  AbstractWorker* worker =
+      new NormalEstimationWorker(selected_cloud_mesh_items, &MainWindow::getInstance());
   ThreadController* thread_controller = new ThreadController();
-  connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
+  connect(worker,
+          SIGNAL(dataUpdated(CloudMeshItem*)),
+          thread_controller,
+          SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
   thread_controller->runWorker(worker);
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
@@ -366,67 +359,66 @@ void
 pcl::modeler::SceneTree::slotPoissonReconstruction()
 {
   QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>();
-  AbstractWorker* worker = new PoissonReconstructionWorker(selected_cloud_mesh_items,&MainWindow::getInstance());
+  AbstractWorker* worker = new PoissonReconstructionWorker(selected_cloud_mesh_items,
+                                                           &MainWindow::getInstance());
   ThreadController* thread_controller = new ThreadController();
-  connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
+  connect(worker,
+          SIGNAL(dataUpdated(CloudMeshItem*)),
+          thread_controller,
+          SLOT(slotOnCloudMeshItemUpdate(CloudMeshItem*)));
   thread_controller->runWorker(worker);
-
-  return;
 }
 
-
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::SceneTree::selectRenderWindowItem(RenderWindowItem* render_window_item)
 {
   selectionModel()->clearSelection();
-  selectionModel()->select(indexFromItem(render_window_item), QItemSelectionModel::SelectCurrent);
+  selectionModel()->select(indexFromItem(render_window_item),
+                           QItemSelectionModel::SelectCurrent);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::SceneTree::slotUpdateOnSelectionChange(const QItemSelection & selected, const QItemSelection & deselected)
+pcl::modeler::SceneTree::slotUpdateOnSelectionChange(const QItemSelection& selected,
+                                                     const QItemSelection& deselected)
 {
   QModelIndexList selected_indices = selected.indexes();
   for (QModelIndexList::const_iterator selected_indices_it = selected_indices.begin();
-    selected_indices_it != selected_indices.end();
-    ++ selected_indices_it)
-  {
+       selected_indices_it != selected_indices.end();
+       ++selected_indices_it) {
     QTreeWidgetItem* item = itemFromIndex(*selected_indices_it);
     RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(item);
-    if (render_window_item != nullptr)
-    {
+    if (render_window_item != nullptr) {
       render_window_item->getRenderWindow()->setActive(true);
     }
   }
 
   QModelIndexList deselected_indices = deselected.indexes();
-  for (QModelIndexList::const_iterator deselected_indices_it = deselected_indices.begin();
-    deselected_indices_it != deselected_indices.end();
-    ++ deselected_indices_it)
-  {
+  for (QModelIndexList::const_iterator deselected_indices_it =
+           deselected_indices.begin();
+       deselected_indices_it != deselected_indices.end();
+       ++deselected_indices_it) {
     QTreeWidgetItem* item = itemFromIndex(*deselected_indices_it);
     RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(item);
-    if (render_window_item != nullptr)
-    {
+    if (render_window_item != nullptr) {
       render_window_item->getRenderWindow()->setActive(false);
     }
   }
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::SceneTree::slotUpdateOnInsertOrRemove()
 {
-  for (int i = 0, i_end = topLevelItemCount(); i < i_end; ++ i)
-  {
-    RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(topLevelItem(i));
+  for (int i = 0, i_end = topLevelItemCount(); i < i_end; ++i) {
+    RenderWindowItem* render_window_item =
+        dynamic_cast<RenderWindowItem*>(topLevelItem(i));
     if (render_window_item == nullptr)
       continue;
 
-    QString title = (i == 0)?("Central Render Window"):(QString("Render Window #%1").arg(i));
+    QString title =
+        (i == 0) ? ("Central Render Window") : (QString("Render Window #%1").arg(i));
     render_window_item->setText(0, title);
 
     render_window_item->getRenderWindow()->setTitle(title);
@@ -440,7 +432,8 @@ pcl::modeler::SceneTree::addTopLevelItem(RenderWindowItem* render_window_item)
   QTreeWidget::addTopLevelItem(render_window_item);
 
   selectionModel()->clearSelection();
-  selectionModel()->select(indexFromItem(render_window_item), QItemSelectionModel::SelectCurrent);
+  selectionModel()->select(indexFromItem(render_window_item),
+                           QItemSelectionModel::SelectCurrent);
 
   emit itemInsertedOrRemoved();
 }
@@ -449,29 +442,27 @@ pcl::modeler::SceneTree::addTopLevelItem(RenderWindowItem* render_window_item)
 void
 pcl::modeler::SceneTree::slotCloseRenderWindow()
 {
-  QList<RenderWindowItem*> selected_render_window_items = selectedTypeItems<RenderWindowItem>();
+  QList<RenderWindowItem*> selected_render_window_items =
+      selectedTypeItems<RenderWindowItem>();
 
-  for (auto &selected_render_window_item : selected_render_window_items)
-  {
+  for (auto& selected_render_window_item : selected_render_window_items) {
     removeItemWidget(selected_render_window_item, 0);
     delete selected_render_window_item;
   }
 
   emit itemInsertedOrRemoved();
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::SceneTree::dropEvent(QDropEvent * event)
+pcl::modeler::SceneTree::dropEvent(QDropEvent* event)
 {
   QList<CloudMeshItem*> selected_cloud_meshes = selectedTypeItems<CloudMeshItem>();
 
   std::set<RenderWindowItem*> previous_parents;
-  for (const auto &cloud_mesh_item : selected_cloud_meshes)
-  {
-    RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent());
+  for (const auto& cloud_mesh_item : selected_cloud_meshes) {
+    RenderWindowItem* render_window_item =
+        dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent());
     if (render_window_item != nullptr)
       previous_parents.insert(render_window_item);
   }
@@ -479,8 +470,7 @@ pcl::modeler::SceneTree::dropEvent(QDropEvent * event)
   QTreeWidget::dropEvent(event);
 
   std::vector<CloudMeshItem*> cloud_mesh_items;
-  for (const auto &cloud_mesh_item : selected_cloud_meshes)
-  {
+  for (const auto& cloud_mesh_item : selected_cloud_meshes) {
     if (dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent()) == nullptr)
       cloud_mesh_items.push_back(cloud_mesh_item);
     else
@@ -488,37 +478,38 @@ pcl::modeler::SceneTree::dropEvent(QDropEvent * event)
   }
 
   // put the cloud mesh items in a new render window
-  if (!cloud_mesh_items.empty())
-  {
-    for (const auto &cloud_mesh_item : cloud_mesh_items)
+  if (!cloud_mesh_items.empty()) {
+    for (const auto& cloud_mesh_item : cloud_mesh_items)
       takeTopLevelItem(indexFromItem(cloud_mesh_item).row());
-    RenderWindowItem* render_window_item = MainWindow::getInstance().createRenderWindow();
-    for (const auto &cloud_mesh_item : cloud_mesh_items)
+    RenderWindowItem* render_window_item =
+        MainWindow::getInstance().createRenderWindow();
+    for (const auto& cloud_mesh_item : cloud_mesh_items)
       render_window_item->addChild(cloud_mesh_item);
     render_window_item->setExpanded(true);
   }
 
-  for (const auto &previous_parent : previous_parents)
-  {
+  for (const auto& previous_parent : previous_parents) {
     previous_parent->getRenderWindow()->updateAxes();
     previous_parent->getRenderWindow()->render();
   }
-
-  return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 bool
-pcl::modeler::SceneTree::dropMimeData(QTreeWidgetItem * parent, int, const QMimeData *, Qt::DropAction)
+pcl::modeler::SceneTree::dropMimeData(QTreeWidgetItem* parent,
+                                      int,
+                                      const QMimeData*,
+                                      Qt::DropAction)
 {
   QList<CloudMeshItem*> selected_cloud_meshes = selectedTypeItems<CloudMeshItem>();
 
   RenderWindowItem* render_window_item =
-    (parent == nullptr)?(MainWindow::getInstance().createRenderWindow()):(dynamic_cast<RenderWindowItem*>(parent));
+      (parent == nullptr) ? (MainWindow::getInstance().createRenderWindow())
+                          : (dynamic_cast<RenderWindowItem*>(parent));
 
-  for (auto &selected_cloud_mesh : selected_cloud_meshes)
-  {
-    CloudMeshItem* cloud_mesh_item_copy = new CloudMeshItem(render_window_item, *selected_cloud_mesh);
+  for (auto& selected_cloud_mesh : selected_cloud_meshes) {
+    CloudMeshItem* cloud_mesh_item_copy =
+        new CloudMeshItem(render_window_item, *selected_cloud_mesh);
     render_window_item->addChild(cloud_mesh_item_copy);
     setCurrentItem(cloud_mesh_item_copy);
   }
index b476da50901c999d34d15d0e0ffe0b7c8f9e0633..2d8272427f36589ee17088fdf91163e29d8d4f29 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/statistical_outlier_removal_worker.h>
-#include <pcl/apps/modeler/parameter.h>
-#include <pcl/apps/modeler/parameter_dialog.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
+#include <pcl/apps/modeler/parameter.h>
+#include <pcl/apps/modeler/parameter_dialog.h>
+#include <pcl/apps/modeler/statistical_outlier_removal_worker.h>
 #include <pcl/filters/statistical_outlier_removal.h>
 
-
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::StatisticalOutlierRemovalWorker::StatisticalOutlierRemovalWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent) :
-  AbstractWorker(cloud_mesh_items, parent),
-  mean_k_(nullptr), stddev_mul_thresh_(nullptr)
-{
-}
+pcl::modeler::StatisticalOutlierRemovalWorker::StatisticalOutlierRemovalWorker(
+    const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent)
+: AbstractWorker(cloud_mesh_items, parent)
+, mean_k_(nullptr)
+, stddev_mul_thresh_(nullptr)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::StatisticalOutlierRemovalWorker::~StatisticalOutlierRemovalWorker()
@@ -58,27 +58,35 @@ pcl::modeler::StatisticalOutlierRemovalWorker::~StatisticalOutlierRemovalWorker(
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::StatisticalOutlierRemovalWorker::initParameters(CloudMeshItem *)
-{
-  return;
-}
+pcl::modeler::StatisticalOutlierRemovalWorker::initParameters(CloudMeshItem*)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::StatisticalOutlierRemovalWorker::setupParameters()
 {
-  mean_k_ = new IntParameter("Mean K", "The number of nearest neighbors to use for mean distance estimation", 8, 1, 1024, 1);
-  stddev_mul_thresh_ = new DoubleParameter("Standard Deviation Multiplier", "The distance threshold will be equal to: mean + stddev_mult * stddev. Points will be classified as inlier or outlier if their average neighbor distance is below or above this threshold respectively.", 1.0, 0.1, 10, 0.1);
+  // clang-format off
+  mean_k_ = new IntParameter(
+      "Mean K",
+      "The number of nearest neighbors to use for mean distance estimation",
+      8, 1, 1024, 1);
+
+  stddev_mul_thresh_ = new DoubleParameter(
+      "Standard Deviation Multiplier",
+      "The distance threshold will be equal to: mean + stddev_mult * stddev. Points "
+      "will be classified as inlier or outlier if their average neighbor distance is "
+      "below or above this threshold respectively.",
+      1.0, 0.1, 10, 0.1);
+  // clang-format on
 
   parameter_dialog_->addParameter(mean_k_);
   parameter_dialog_->addParameter(stddev_mul_thresh_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::StatisticalOutlierRemovalWorker::processImpl(CloudMeshItem* cloud_mesh_item)
+pcl::modeler::StatisticalOutlierRemovalWorker::processImpl(
+    CloudMeshItem* cloud_mesh_item)
 {
   pcl::StatisticalOutlierRemoval<pcl::PointSurfel> sor;
   sor.setInputCloud(cloud_mesh_item->getCloudMesh()->getCloud());
@@ -91,6 +99,4 @@ pcl::modeler::StatisticalOutlierRemovalWorker::processImpl(CloudMeshItem* cloud_
   cloud_mesh_item->getCloudMesh()->getCloud() = cloud;
 
   emitDataUpdated(cloud_mesh_item);
-
-  return;
 }
index 6681f496004859378bcc57adeced22be19f72751..067aa5669c1c049bbf9b648b5db1f2499a115537 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/surface_actor_item.h>
-
 #include <pcl/apps/modeler/cloud_mesh.h>
+#include <pcl/apps/modeler/surface_actor_item.h>
 
-#include <vtkLODActor.h>
-#include <vtkPolyData.h>
 #include <vtkCellArray.h>
 #include <vtkDataSetMapper.h>
+#include <vtkLODActor.h>
 #include <vtkPointData.h>
+#include <vtkPolyData.h>
 #include <vtkProperty.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::SurfaceActorItem::SurfaceActorItem(QTreeWidgetItem* parent,
-                                                 const CloudMesh::Ptr& cloud_mesh,
-                                                 const vtkSmartPointer<vtkRenderWindow>& render_window)
-  :ChannelActorItem(parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Surface")
-{
-}
+pcl::modeler::SurfaceActorItem::SurfaceActorItem(
+    QTreeWidgetItem* parent,
+    const CloudMesh::Ptr& cloud_mesh,
+    const vtkSmartPointer<vtkRenderWindow>& render_window)
+: ChannelActorItem(
+      parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Surface")
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::SurfaceActorItem::~SurfaceActorItem ()
-{
-
-}
+pcl::modeler::SurfaceActorItem::~SurfaceActorItem() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
@@ -68,34 +65,34 @@ pcl::modeler::SurfaceActorItem::initImpl()
 
   vtkSmartPointer<vtkDataArray> scalars;
   cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
-  poly_data_->GetPointData ()->SetScalars (scalars);
+  poly_data_->GetPointData()->SetScalars(scalars);
 
   vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
-  mapper->SetInputData (poly_data_);
+  mapper->SetInputData(poly_data_);
 
   double minmax[2];
   scalars->GetRange(minmax);
   mapper->SetScalarRange(minmax);
 
-  mapper->SetScalarModeToUsePointData ();
-  mapper->InterpolateScalarsBeforeMappingOn ();
-  mapper->ScalarVisibilityOn ();
+  mapper->SetScalarModeToUsePointData();
+  mapper->InterpolateScalarsBeforeMappingOn();
+  mapper->ScalarVisibilityOn();
 #if VTK_RENDERING_BACKEND_OPENGL_VERSION < 2
-  mapper->ImmediateModeRenderingOff ();
+  mapper->ImmediateModeRenderingOff();
 #endif
 
-  vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
+  vtkSmartPointer<vtkLODActor> actor =
+      vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
   actor->SetMapper(mapper);
 
-  actor->SetNumberOfCloudPoints(int(std::max<vtkIdType> (1, poly_data_->GetNumberOfPoints () / 10)));
-  actor->GetProperty ()->SetInterpolationToFlat ();
+  actor->SetNumberOfCloudPoints(
+      int(std::max<vtkIdType>(1, poly_data_->GetNumberOfPoints() / 10)));
+  actor->GetProperty()->SetInterpolationToFlat();
 
-  actor->GetProperty ()->SetRepresentationToSurface ();
-  actor->GetProperty ()->BackfaceCullingOn ();
-  actor->GetProperty ()->EdgeVisibilityOff ();
-  actor->GetProperty ()->ShadingOff ();
-
-  return;
+  actor->GetProperty()->SetRepresentationToSurface();
+  actor->GetProperty()->BackfaceCullingOn();
+  actor->GetProperty()->EdgeVisibilityOff();
+  actor->GetProperty()->ShadingOff();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -104,31 +101,23 @@ pcl::modeler::SurfaceActorItem::updateImpl()
 {
   vtkSmartPointer<vtkDataArray> scalars;
   cloud_mesh_->getColorScalarsFromField(scalars, "random");
-  poly_data_->GetPointData ()->SetScalars (scalars);
+  poly_data_->GetPointData()->SetScalars(scalars);
   double minmax[2];
   scalars->GetRange(minmax);
   actor_->GetMapper()->SetScalarRange(minmax);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::SurfaceActorItem::prepareContextMenu(QMenu *) const
-{
-
-}
+pcl::modeler::SurfaceActorItem::prepareContextMenu(QMenu*) const
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::SurfaceActorItem::prepareProperties(ParameterDialog *)
-{
-
-}
+pcl::modeler::SurfaceActorItem::prepareProperties(ParameterDialog*)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::modeler::SurfaceActorItem::setProperties()
-{
-
-}
+{}
index 8a2693a79af77ca2fc00866da43326e203c0780e..9d391b2df594ccf3353ccf1e6a5b1b7857d28479 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/thread_controller.h>
-
 #include <pcl/apps/modeler/abstract_worker.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
 #include <pcl/apps/modeler/main_window.h>
+#include <pcl/apps/modeler/thread_controller.h>
 
 #include <QDialog>
 #include <QThread>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::ThreadController::ThreadController()
-{
-
-}
+pcl::modeler::ThreadController::ThreadController() {}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::ThreadController::~ThreadController()
@@ -59,14 +55,13 @@ pcl::modeler::ThreadController::~ThreadController()
 bool
 pcl::modeler::ThreadController::runWorker(AbstractWorker* worker)
 {
-  if (worker->exec() != QDialog::Accepted)
-  {
+  if (worker->exec() != QDialog::Accepted) {
     delete worker;
     deleteLater();
 
-    return (false);
+    return false;
   }
-  
+
   QThread* thread = new QThread;
 
   connect(this, SIGNAL(prepared()), worker, SLOT(process()));
@@ -85,12 +80,13 @@ pcl::modeler::ThreadController::runWorker(AbstractWorker* worker)
 
   emit prepared();
 
-   return (true);
+  return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::modeler::ThreadController::slotOnCloudMeshItemUpdate(CloudMeshItem* cloud_mesh_item)
+pcl::modeler::ThreadController::slotOnCloudMeshItemUpdate(
+    CloudMeshItem* cloud_mesh_item)
 {
   cloud_mesh_item->updateChannels();
 }
index 6959e69dfcc845e1937afbce14fbcfa45e7ea714..cf3ea73fb2a2e9a4559a98ed6df646db71177fc5 100755 (executable)
  *
  */
 
-#include <pcl/apps/modeler/voxel_grid_downsample_worker.h>
-#include <pcl/apps/modeler/parameter.h>
-#include <pcl/apps/modeler/parameter_dialog.h>
 #include <pcl/apps/modeler/cloud_mesh.h>
 #include <pcl/apps/modeler/cloud_mesh_item.h>
-#include <pcl/filters/voxel_grid.h>
+#include <pcl/apps/modeler/parameter.h>
+#include <pcl/apps/modeler/parameter_dialog.h>
+#include <pcl/apps/modeler/voxel_grid_downsample_worker.h>
 #include <pcl/common/common.h>
-
+#include <pcl/filters/voxel_grid.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-pcl::modeler::VoxelGridDownampleWorker::VoxelGridDownampleWorker(const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent) :
-  AbstractWorker(cloud_mesh_items, parent),
-  x_min_(std::numeric_limits<double>::max()), x_max_(std::numeric_limits<double>::min()),
-  y_min_(std::numeric_limits<double>::max()), y_max_(std::numeric_limits<double>::min()),
-  z_min_(std::numeric_limits<double>::max()), z_max_(std::numeric_limits<double>::min()),
-  leaf_size_x_(nullptr), leaf_size_y_(nullptr), leaf_size_z_(nullptr)
-{
-}
+pcl::modeler::VoxelGridDownampleWorker::VoxelGridDownampleWorker(
+    const QList<CloudMeshItem*>& cloud_mesh_items, QWidget* parent)
+: AbstractWorker(cloud_mesh_items, parent)
+, x_min_(std::numeric_limits<double>::max())
+, x_max_(std::numeric_limits<double>::min())
+, y_min_(std::numeric_limits<double>::max())
+, y_max_(std::numeric_limits<double>::min())
+, z_min_(std::numeric_limits<double>::max())
+, z_max_(std::numeric_limits<double>::min())
+, leaf_size_x_(nullptr)
+, leaf_size_y_(nullptr)
+, leaf_size_z_(nullptr)
+{}
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 pcl::modeler::VoxelGridDownampleWorker::~VoxelGridDownampleWorker()
@@ -76,8 +80,6 @@ pcl::modeler::VoxelGridDownampleWorker::initParameters(CloudMeshItem* cloud_mesh
 
   z_min_ = std::min(double(min_pt.z()), z_min_);
   z_max_ = std::max(double(max_pt.z()), z_max_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -89,18 +91,19 @@ pcl::modeler::VoxelGridDownampleWorker::setupParameters()
   double z_range = z_max_ - z_min_;
 
   double range_max = std::max(x_range, std::max(y_range, z_range));
-  double size = range_max/1000;
-  double step = range_max/1000;
+  double size = range_max / 1000;
+  double step = range_max / 1000;
 
-  leaf_size_x_ = new DoubleParameter("Leaf Size X", "The X size of the voxel grid", size, 0, x_max_-x_min_, step);
-  leaf_size_y_ = new DoubleParameter("Leaf Size Y", "The Y size of the voxel grid", size, 0, y_max_-y_min_, step);
-  leaf_size_z_ = new DoubleParameter("Leaf Size Z", "The Z size of the voxel grid", size, 0, z_max_-z_min_, step);
+  leaf_size_x_ = new DoubleParameter(
+      "Leaf Size X", "The X size of the voxel grid", size, 0, x_max_ - x_min_, step);
+  leaf_size_y_ = new DoubleParameter(
+      "Leaf Size Y", "The Y size of the voxel grid", size, 0, y_max_ - y_min_, step);
+  leaf_size_z_ = new DoubleParameter(
+      "Leaf Size Z", "The Z size of the voxel grid", size, 0, z_max_ - z_min_, step);
 
   parameter_dialog_->addParameter(leaf_size_x_);
   parameter_dialog_->addParameter(leaf_size_y_);
   parameter_dialog_->addParameter(leaf_size_z_);
-
-  return;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -109,7 +112,8 @@ pcl::modeler::VoxelGridDownampleWorker::processImpl(CloudMeshItem* cloud_mesh_it
 {
   pcl::VoxelGrid<pcl::PointSurfel> voxel_grid;
   voxel_grid.setInputCloud(cloud_mesh_item->getCloudMesh()->getCloud());
-  voxel_grid.setLeafSize (float (*leaf_size_x_), float (*leaf_size_y_), float (*leaf_size_z_));
+  voxel_grid.setLeafSize(
+      float(*leaf_size_x_), float(*leaf_size_y_), float(*leaf_size_z_));
 
   CloudMesh::PointCloudPtr cloud(new CloudMesh::PointCloud());
   voxel_grid.filter(*cloud);
@@ -117,6 +121,4 @@ pcl::modeler::VoxelGridDownampleWorker::processImpl(CloudMeshItem* cloud_mesh_it
   cloud_mesh_item->getCloudMesh()->getCloud() = cloud;
 
   emitDataUpdated(cloud_mesh_item);
-
-  return;
 }
index c2c38a990e650cceb223a84690d55802dd4370d9..fc66674ec2688a3a5d5076cd372d18aefe12f39a 100644 (file)
@@ -44,6 +44,9 @@
 #include <QtGui/QColor>
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 #include <pcl/apps/point_cloud_editor/statistics.h>
+
+#include <pcl/memory.h>  // for pcl::weak_ptr
+
 #ifdef OPENGL_IS_A_FRAMEWORK
 # include <OpenGL/gl.h>
 # include <OpenGL/glu.h>
 class Cloud : public Statistics
 {
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
+    /// The type for weak pointer pointing to a selection buffer
+    using SelectionWeakPtr = pcl::weak_ptr<Selection>;
+
     /// @brief Default Constructor
     Cloud ();
 
@@ -412,7 +421,7 @@ class Cloud : public Statistics
     /// @brief A weak pointer pointing to the selection object.
     /// @details This implementation uses the weak pointer to allow for a lazy
     /// update of the cloud if the selection object is destroyed.
-    std::weak_ptr<Selection> selection_wk_ptr_;
+    SelectionWeakPtr selection_wk_ptr_;
 
     /// Flag that indicates whether a color ramp should be used (true) or not
     /// (false) when displaying the cloud
index 9c2002ee676941e8084266316ecd24169a780f96..de5b3b771d2232a4c40475d7e337449f114c9025 100644 (file)
 #include <pcl/apps/point_cloud_editor/statisticsDialog.h>
 #include <pcl/apps/point_cloud_editor/toolInterface.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
 #include <QGLWidget>
 
 #include <functional>
 
+class Selection;
+
 /// @brief class declaration for the widget for editing and viewing
 /// point clouds.
 class CloudEditorWidget : public QGLWidget
 {
   Q_OBJECT
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
     /// @brief Constructor
     /// @param parent a pointer which points to the parent widget
     CloudEditorWidget (QWidget *parent = nullptr);
index e3c38f1acd20607c5c09231aee6e6f7db9ea84de..101556d5d5ddd5cb91042ac18a862d26f9faf608 100644 (file)
@@ -116,7 +116,7 @@ class CloudTransformTool : public ToolInterface
 
     /// generate scale matrix
     void
-    getScaleMatrix (int dy, float* matrix);
+    getScaleMatrix (int dy, float* matrix) const;
 
     /// the transform matrix to be used for updating the coordinates of all
     /// the points in the cloud
index d7dc85cb05246432b942b1bb8b41b804c2e1b8de..2da976ab0971a4f696bbc8517f4114c8b05c2290 100644 (file)
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 #include <pcl/apps/point_cloud_editor/copyBuffer.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
+class Selection;
+
 class CopyCommand : public Command
 {
   public:
+    /// The type for shared pointer pointing to a constant selection buffer
+    using ConstSelectionPtr = pcl::shared_ptr<const Selection>;
+
     /// @brief Constructor
     /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer.
     /// @param selection_ptr a shared pointer pointing to the selection object.
index f5d28b3148d55a57c2b8891bf0a66159d5b3affc..438f11344da717d000bf9bd165a953d93c181ced 100644 (file)
 #include <pcl/apps/point_cloud_editor/copyBuffer.h>
 #include <pcl/apps/point_cloud_editor/selection.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
 class CutCommand : public Command
 {
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
     /// @brief Constructor
     /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer.
     /// @param selection_ptr a shared pointer pointing to the selection object.
index caebdb58f7e5e8046305fa50ef0c10186fc32b17..25c22ac08a538fe2f7e59c451e84d2bf24fd48bd 100644 (file)
 #include <pcl/apps/point_cloud_editor/copyBuffer.h>
 #include <pcl/apps/point_cloud_editor/selection.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
 class DeleteCommand : public Command
 {
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
     /// @brief Constructor
     /// @param selection_ptr A shared pointer pointing to the selection object.
     /// @param cloud_ptr A shared pointer pointing to the cloud object.
index b01f7cf342ad4ee737267fd15cca95402fd90ac6..73a1cd11b63bf5c93f0ce9898c26ab4ddf034898 100644 (file)
 #include <pcl/apps/point_cloud_editor/selection.h>
 #include <pcl/apps/point_cloud_editor/copyBuffer.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
 class DenoiseCommand : public Command
 {
 public:
+  /// The type for shared pointer pointing to a selection buffer
+  using SelectionPtr = pcl::shared_ptr<Selection>;
+
   /// @brief Constructor
   /// @param selection_ptr a shared pointer pointing to the selection object.
   /// @param cloud_ptr a shared pointer pointing to the cloud object.
index 2cc09ac2a35b6c437be7175362100b9828f031f4..787e6721dcde4bcc2fb3899fca7ccef28a8eb5de 100644 (file)
 #include <pcl/apps/point_cloud_editor/command.h>
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
 class PasteCommand : public Command
 {
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
     /// @brief Constructor
     /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer.
     /// @param selection_ptr a shared pointer pointing to the selection object.
index ee06d45b0a7a54e023b4b4e4af329dcaf9372f7e..679e97bd855a8b141fd08d54365fcc4d4fefcba5 100644 (file)
 #include <pcl/apps/point_cloud_editor/toolInterface.h>
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
+class Selection;
+
 class Select1DTool : public ToolInterface
 {
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
     /// @brief Constructor
     /// @param selection_ptr a shared pointer pointing to the selection object.
     /// @param cloud_ptr a shared pointer pointing to the cloud object.
index 1adb2486c8a43dfffa5dd81e37f0c17dd9c4bab7..aacbbfbe6eccec68c03522349537f9dfdfffccd9 100644 (file)
 #include <pcl/apps/point_cloud_editor/toolInterface.h>
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
+class Selection;
+
 class Select2DTool : public ToolInterface
 {
   public:
+    /// The type for shared pointer pointing to a selection buffer
+    using SelectionPtr = pcl::shared_ptr<Selection>;
+
     /// @brief Constructor
     /// @param selection_ptr a shared pointer pointing to the selection object.
     /// @param cloud_ptr a shared pointer pointing to the cloud object.
index a07f960b518c75259181519e3d659a7f41121b8a..976d1e984558c0312638dee949d0d15ff673e134 100644 (file)
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 #include <pcl/apps/point_cloud_editor/trackball.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
+class Selection;
+
 /// @brief The selection transform tool computes the transform matrix from
 /// mouse input.  It then updates the cloud's transform matrix for the
 /// selected points so that the transformed and selected points will be
@@ -53,6 +57,9 @@
 class SelectionTransformTool : public ToolInterface
 {
   public:
+    /// The type for shared pointer pointing to a constant selection buffer
+    using ConstSelectionPtr = pcl::shared_ptr<const Selection>;
+
     /// @brief Constructor
     /// @param selection_ptr a shared pointer pointing to the selection object.
     /// @param cloud_ptr a shared pointer pointing to the cloud object.
index 9f111760b749876964bcbdf0faf7a0fa0d8c0088..3856e84db7b55f63c99d9b3db0cedbd309259f9d 100644 (file)
@@ -62,7 +62,7 @@ class TrackBall
     
   private:
     
-    void getPointFromScreenPoint(int s_x, int s_y, float &x, float &y, float &z);
+    void getPointFromScreenPoint(int s_x, int s_y, float &x, float &y, float &z) const;
 
     /// the quaternion representing the current orientation of the trackball
     boost::math::quaternion<float> quat_;
index 0e2537cb4e001ef9c22600fb6bbb494ec5e4a8f2..19b302d9a8f3dd3c1d3e037cfd012124794fe4e8 100644 (file)
 #include <pcl/apps/point_cloud_editor/localTypes.h>
 #include <pcl/apps/point_cloud_editor/cloud.h>
 
+#include <pcl/memory.h>  // for pcl::shared_ptr
+
+class Selection;
+
 class TransformCommand : public Command
 {
   public:
+    /// The type for shared pointer pointing to a constant selection buffer
+    using ConstSelectionPtr = pcl::shared_ptr<const Selection>;
+
     /// @brief Constructor
     /// @param selection_ptr a shared pointer pointing to the selection object.
     /// @param cloud_ptr a shared pointer pointing to the cloud object.
index e368ec3b387619b5c00b8059a3806f8ce042dd4f..be754ee4237e20674718ba48a49d5d31cb35fa42 100644 (file)
@@ -114,7 +114,7 @@ CloudTransformTool::getZTranslateMatrix (int dy, float* matrix)
 }
 
 void
-CloudTransformTool::getScaleMatrix (int dy, float* matrix)
+CloudTransformTool::getScaleMatrix (int dy, float* matrix) const
 {
   setIdentity(matrix);
   float scale = dy > 0 ? scale_factor_ : 1.0 / scale_factor_;
index 2102fcc5b6712abf44dcd386baa5fa680f16247f..644630593921a79b53461cc776241729cf090858 100644 (file)
@@ -221,7 +221,7 @@ TrackBall::reset()
 
 void
 TrackBall::getPointFromScreenPoint(int s_x, int s_y,
-                                   float &x, float &y, float &z)
+                                   float &x, float &y, float &z) const
 {
   // See http://www.opengl.org/wiki/Trackball for more info
     
index 12b220318561731c59c8820cc149ebdc0f07a2c9..6bf42e7aed33ab732bf53cf52cac7ac639a57bab 100644 (file)
  * $Id$
  */
 
-#include <pcl/point_types.h>
-#include <pcl/io/pcd_io.h>
+#include <pcl/common/time.h>
 #include <pcl/console/parse.h>
 #include <pcl/console/print.h>
 #include <pcl/filters/convolution.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/common/time.h>
+#include <pcl/point_types.h>
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
+  // clang-format off
   pcl::console::print_info ("usage: %s <filename> <-r|-c|-s> [-p <borders policy>] [-t <number of threads>] [-d <distance>]\n\n", argv[0]);
-  pcl::console::print_info ("Where options are:\n");
-  pcl::console::print_info ("\t\t\t-r convolve rows\n");
-  pcl::console::print_info ("\t\t\t-c convolve columns\n");
-  pcl::console::print_info ("\t\t\t-s convolve separate\n");
-  pcl::console::print_info ("\t\t\t-p borders policy\n");
-  pcl::console::print_info ("\t\t\t\t Z zero padding, default\n");
-  pcl::console::print_info ("\t\t\t\t D duplicate borders\n");
-  pcl::console::print_info ("\t\t\t\t M mirror borders\n");
-  pcl::console::print_info ("\t\t\t-t optional, number of threads, default 1\n");
-  pcl::console::print_info ("\t\t\t-d optional, distance threshold, default 0.001\n");
+  // clang-format on
+  pcl::console::print_info("Where options are:\n");
+  pcl::console::print_info("\t\t\t-r convolve rows\n");
+  pcl::console::print_info("\t\t\t-c convolve columns\n");
+  pcl::console::print_info("\t\t\t-s convolve separate\n");
+  pcl::console::print_info("\t\t\t-p borders policy\n");
+  pcl::console::print_info("\t\t\t\t Z zero padding, default\n");
+  pcl::console::print_info("\t\t\t\t D duplicate borders\n");
+  pcl::console::print_info("\t\t\t\t M mirror borders\n");
+  pcl::console::print_info("\t\t\t-t optional, number of threads, default 1\n");
+  pcl::console::print_info("\t\t\t-d optional, distance threshold, default 0.001\n");
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   int viewport_source, viewport_convolved = 0;
   int direction = -1;
@@ -69,161 +71,162 @@ main (int argc, char ** argv)
   double threshold = 0.001;
   pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB> convolution;
   Eigen::ArrayXf gaussian_kernel(5);
-  gaussian_kernel << 1.f/16, 1.f/4, 3.f/8, 1.f/4, 1.f/16;
-  pcl::console::print_info ("convolution kernel:");
-  for (Eigen::Index i = 0; i < gaussian_kernel.size (); ++i)
-    pcl::console::print_info (" %f", gaussian_kernel[i]);
-  pcl::console::print_info ("\n");
+  gaussian_kernel << 1.f / 16, 1.f / 4, 3.f / 8, 1.f / 4, 1.f / 16;
+  pcl::console::print_info("convolution kernel:");
+  for (Eigen::Index i = 0; i < gaussian_kernel.size(); ++i)
+    pcl::console::print_info(" %f", gaussian_kernel[i]);
+  pcl::console::print_info("\n");
 
-  if (argc < 3)
-  {
-    usage (argv);
+  if (argc < 3) {
+    usage(argv);
     return 1;
   }
 
   // check if user is requesting help
-  std::string arg (argv[1]);
+  std::string arg(argv[1]);
 
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
   // user don't need help find convolving direction
   // convolve row
-  if (pcl::console::find_switch (argc, argv, "-r"))
+  if (pcl::console::find_switch(argc, argv, "-r"))
     direction = 0;
-  else
-  {
+  else {
     // convolve column
-    if (pcl::console::find_switch (argc, argv, "-c"))
+    if (pcl::console::find_switch(argc, argv, "-c"))
       direction = 1;
     else
-      // convolve both
-      if (pcl::console::find_switch (argc, argv, "-s"))
-        direction = 2;
-      else
-      {
-        // wrong direction given print usage
-        usage (argv);
-        return 1;
-      }
+        // convolve both
+        if (pcl::console::find_switch(argc, argv, "-s"))
+      direction = 2;
+    else {
+      // wrong direction given print usage
+      usage(argv);
+      return 1;
+    }
   }
 
   // number of threads if any
-  if (pcl::console::parse_argument (argc, argv, "-t", nb_threads) != -1 )
-  {
+  if (pcl::console::parse_argument(argc, argv, "-t", nb_threads) != -1) {
     if (nb_threads <= 0)
       nb_threads = 1;
 #ifndef _OPENMP
-    if (nb_threads > 1)
-    {
-      pcl::console::print_info ("OpenMP not activated. Number of threads: 1\n");
+    if (nb_threads > 1) {
+      pcl::console::print_info("OpenMP not activated. Number of threads: 1\n");
       nb_threads = 1;
     }
 #endif
   }
 #ifdef _OPENMP
-  else
-  {
+  else {
     nb_threads = omp_get_num_procs();
   }
 #endif
-  convolution.setNumberOfThreads (nb_threads);
+  convolution.setNumberOfThreads(nb_threads);
 
   // borders policy if any
-  if (pcl::console::parse_argument (argc, argv, "-p", border_policy) != -1 )
-  {
-    switch (border_policy)
-    {
-      case 'Z' : convolution.setBordersPolicy (pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::BORDERS_POLICY_IGNORE);
-        break;
-      case 'M' : convolution.setBordersPolicy (pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::BORDERS_POLICY_MIRROR);
-        break;
-      case 'D' : convolution.setBordersPolicy (pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::BORDERS_POLICY_DUPLICATE);
-        break;
-      default :
-      {
-        usage (argv);
-        return (1);
-      }
+  if (pcl::console::parse_argument(argc, argv, "-p", border_policy) != -1) {
+    switch (border_policy) {
+    case 'Z':
+      convolution.setBordersPolicy(
+          pcl::filters::Convolution<pcl::PointXYZRGB,
+                                    pcl::PointXYZRGB>::BORDERS_POLICY_IGNORE);
+      break;
+    case 'M':
+      convolution.setBordersPolicy(
+          pcl::filters::Convolution<pcl::PointXYZRGB,
+                                    pcl::PointXYZRGB>::BORDERS_POLICY_MIRROR);
+      break;
+    case 'D':
+      convolution.setBordersPolicy(
+          pcl::filters::Convolution<pcl::PointXYZRGB,
+                                    pcl::PointXYZRGB>::BORDERS_POLICY_DUPLICATE);
+      break;
+    default: {
+      usage(argv);
+      return 1;
+    }
     }
   }
   else
-    convolution.setBordersPolicy (pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::BORDERS_POLICY_IGNORE);
+    convolution.setBordersPolicy(
+        pcl::filters::Convolution<pcl::PointXYZRGB,
+                                  pcl::PointXYZRGB>::BORDERS_POLICY_IGNORE);
 
   // distance threshold if any
-  if (pcl::console::parse_argument (argc, argv, "-d", threshold) == -1 )
-  {
+  if (pcl::console::parse_argument(argc, argv, "-d", threshold) == -1) {
     threshold = 0.01;
   }
-  convolution.setDistanceThreshold (static_cast<float> (threshold));
+  convolution.setDistanceThreshold(static_cast<float>(threshold));
 
   // all set
   // we have file name and convolving direction
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB> ());
-  if (pcl::io::loadPCDFile (argv[1], *cloud) == -1)
-  {
-    pcl::console::print_error ("Couldn't read file %s \n", argv[1]);
-    return (-1);
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>());
+  if (pcl::io::loadPCDFile(argv[1], *cloud) == -1) {
+    pcl::console::print_error("Couldn't read file %s \n", argv[1]);
+    return -1;
   }
   cloud->is_dense = false;
-  convolution.setInputCloud (cloud);
-  convolution.setKernel (gaussian_kernel);
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr convolved (new pcl::PointCloud<pcl::PointXYZRGB> ());
+  convolution.setInputCloud(cloud);
+  convolution.setKernel(gaussian_kernel);
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr convolved(
+      new pcl::PointCloud<pcl::PointXYZRGB>());
   double t0;
-  pcl::console::print_info ("convolving %s along \n", argv[1]);
+  pcl::console::print_info("convolving %s along \n", argv[1]);
   std::ostringstream convolved_label;
   convolved_label << "convolved along ";
-  switch (direction)
-  {
-    case 0:
-    {
-      convolved_label << "rows... ";
-      t0 = pcl::getTime ();
-      convolution.convolveRows (*convolved);
-      break;
-    }
-    case 1:
-    {
-      convolved_label << "columns... ";
-      t0 = pcl::getTime ();
-      convolution.convolveCols (*convolved);
-      break;
-    }
-    case 2:
-    {
-      convolved_label << "rows and columns... ";
-      t0 = pcl::getTime ();
-      convolution.convolve (*convolved);
-      break;
-    }
+  switch (direction) {
+  case 0: {
+    convolved_label << "rows... ";
+    t0 = pcl::getTime();
+    convolution.convolveRows(*convolved);
+    break;
+  }
+  case 1: {
+    convolved_label << "columns... ";
+    t0 = pcl::getTime();
+    convolution.convolveCols(*convolved);
+    break;
+  }
+  case 2: {
+    convolved_label << "rows and columns... ";
+    t0 = pcl::getTime();
+    convolution.convolve(*convolved);
+    break;
   }
-  convolved_label << pcl::getTime () - t0 << "s";
+  }
+  convolved_label << pcl::getTime() - t0 << "s";
 #ifdef _OPENMP
   convolved_label << "\ncpu cores: " << omp_get_num_procs() << " ";
 #else
   convolved_label << "\n";
-#endif  
+#endif
   convolved_label << "threads: " << nb_threads;
   // Display
-  pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("Convolution"));
+  pcl::visualization::PCLVisualizer::Ptr viewer(
+      new pcl::visualization::PCLVisualizer("Convolution"));
   // viewport stuff
-  viewer->createViewPort (0, 0, 0.5, 1, viewport_source);
-  viewer->createViewPort (0.5, 0, 1, 1, viewport_convolved);
-  viewer->setBackgroundColor (0, 0, 0);
+  viewer->createViewPort(0, 0, 0.5, 1, viewport_source);
+  viewer->createViewPort(0.5, 0, 1, 1, viewport_convolved);
+  viewer->setBackgroundColor(0, 0, 0);
 
   // Source
-  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> color_handler_source (cloud);
-  viewer->addPointCloud<pcl::PointXYZRGB> (cloud, color_handler_source, "source", viewport_source);
-  viewer->addText ("source", 10, 10, "source_label", viewport_source);
+  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>
+      color_handler_source(cloud);
+  viewer->addPointCloud<pcl::PointXYZRGB>(
+      cloud, color_handler_source, "source", viewport_source);
+  viewer->addText("source", 10, 10, "source_label", viewport_source);
 
   // Convolved
-  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> color_handler_convolved (convolved);
-  viewer->addPointCloud<pcl::PointXYZRGB> (convolved, color_handler_convolved, "convolved", viewport_convolved);
-  viewer->addText (convolved_label.str (), 10, 10, "convolved_label", viewport_convolved);
-  viewer->spin ();
+  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>
+      color_handler_convolved(convolved);
+  viewer->addPointCloud<pcl::PointXYZRGB>(
+      convolved, color_handler_convolved, "convolved", viewport_convolved);
+  viewer->addText(convolved_label.str(), 10, 10, "convolved_label", viewport_convolved);
+  viewer->spin();
   pcl::PCDWriter writer;
-  writer.write<pcl::PointXYZRGB> ("convolved.pcd", *convolved, false);
+  writer.write<pcl::PointXYZRGB>("convolved.pcd", *convolved, false);
 }
index 1f752c41eadc65358f8beb3d33fdd9e9b6f83058..4dc29b317b6dbcc3312ed6412fa72da20075bc6c 100644 (file)
  *
  */
 
-#include <thread>
-
 #include <pcl/common/time.h>
-#include <pcl/point_types.h>
 #include <pcl/io/dinast_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_types.h>
+
+#include <thread>
 
 using namespace std::chrono_literals;
 
 template <typename PointType>
-class DinastProcessor
-{
-  public:
-    
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-    
-    DinastProcessor(pcl::Grabber& grabber) : interface(grabber), viewer("Dinast Cloud Viewer") {}
+class DinastProcessor {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudConstPtr = typename Cloud::ConstPtr;
 
-    void 
-    cloud_cb_ (CloudConstPtr cloud_cb)
-    {
-      static unsigned count = 0;
-      static double last = pcl::getTime ();
-      if (++count == 30)
-      {
-        double now = pcl::getTime ();
-        std::cout << "Average framerate: " << double(count)/double(now - last) << " Hz" <<  std::endl;
-        count = 0;
-        last = now;
-      }
-      if (!viewer.wasStopped())
-        viewer.showCloud(cloud_cb);
+  DinastProcessor(pcl::Grabber& grabber)
+  : interface(grabber), viewer("Dinast Cloud Viewer")
+  {}
+
+  void
+  cloud_cb_(CloudConstPtr cloud_cb)
+  {
+    static unsigned count = 0;
+    static double last = pcl::getTime();
+    if (++count == 30) {
+      double now = pcl::getTime();
+      std::cout << "Average framerate: " << double(count) / double(now - last) << " Hz"
+                << std::endl;
+      count = 0;
+      last = now;
     }
-    
-    int 
-    run ()
-    {
+    if (!viewer.wasStopped())
+      viewer.showCloud(cloud_cb);
+  }
+
+  int
+  run()
+  {
+
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
 
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      boost::signals2::connection c = interface.registerCallback (f);
+    interface.start();
 
-      interface.start ();
-      
-      while (!viewer.wasStopped())
-      {
-        std::this_thread::sleep_for(1s);
-      }
-      
-      interface.stop ();
-      
-      return(0);
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1s);
     }
-    
-    pcl::Grabber& interface;
-    pcl::visualization::CloudViewer viewer;  
-    
+
+    interface.stop();
+
+    return 0;
+  }
+
+  pcl::Grabber& interface;
+  pcl::visualization::CloudViewer viewer;
 };
 
 int
-main () 
+main()
 {
   pcl::DinastGrabber grabber;
-  DinastProcessor<pcl::PointXYZI> v (grabber);
-  v.run ();
-  return (0);
+  DinastProcessor<pcl::PointXYZI> v(grabber);
+  v.run();
+  return 0;
 }
index d29cf843782b9ef39e1ddfedc3a8a1c8a3534e28..395768f22a5b0929e00413c9f72063b8974ebf36 100644 (file)
 
 #ifndef PCL_NO_PRECOMPILE
 #include <pcl/apps/impl/dominant_plane_segmentation.hpp>
-#include <pcl/point_types.h>
 #include <pcl/impl/instantiate.hpp>
+#include <pcl/point_types.h>
 #ifdef PCL_ONLY_CORE_POINT_TYPES
-  PCL_INSTANTIATE(DominantPlaneSegmentation, (pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA)(pcl::PointXYZRGB))
+PCL_INSTANTIATE(DominantPlaneSegmentation,
+                (pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA)(pcl::PointXYZRGB))
 #else
-  PCL_INSTANTIATE(DominantPlaneSegmentation, PCL_XYZ_POINT_TYPES)
+PCL_INSTANTIATE(DominantPlaneSegmentation, PCL_XYZ_POINT_TYPES)
 #endif // PCL_ONLY_CORE_POINT_TYPES
 #endif // PCL_NO_PRECOMPILE
index 8e18eaff86c24c3837df9be18c164dc83bc238a8..0bb54399f563e1bd191fcbce171172fdfc84b259 100644 (file)
@@ -5,10 +5,11 @@
  *      Author: Aitor Aldoma
  */
 
-#include "pcl/recognition/face_detection/rf_face_detector_trainer.h"
 #include <pcl/console/parse.h>
+#include <pcl/recognition/face_detection/rf_face_detector_trainer.h>
 
-int main(int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
   int ntrees = 10;
   std::string forest_fn = "forest.txt";
@@ -17,23 +18,22 @@ int main(int argc, char ** argv)
   int use_normals = 0;
   int num_images = 3000;
 
-  pcl::console::parse_argument (argc, argv, "-ntrees", ntrees);
-  pcl::console::parse_argument (argc, argv, "-forest_fn", forest_fn);
-  pcl::console::parse_argument (argc, argv, "-n_features", n_features);
-  pcl::console::parse_argument (argc, argv, "-directory", directory);
-  pcl::console::parse_argument (argc, argv, "-use_normals", use_normals);
-  pcl::console::parse_argument (argc, argv, "-num_images", num_images);
+  pcl::console::parse_argument(argc, argv, "-ntrees", ntrees);
+  pcl::console::parse_argument(argc, argv, "-forest_fn", forest_fn);
+  pcl::console::parse_argument(argc, argv, "-n_features", n_features);
+  pcl::console::parse_argument(argc, argv, "-directory", directory);
+  pcl::console::parse_argument(argc, argv, "-use_normals", use_normals);
+  pcl::console::parse_argument(argc, argv, "-num_images", num_images);
 
   pcl::RFFaceDetectorTrainer fdrf;
-  fdrf.setForestFilename (forest_fn);
-  fdrf.setDirectory (directory);
-  fdrf.setWSize (80);
-  fdrf.setNumTrees (ntrees);
-  fdrf.setNumFeatures (n_features);
-  fdrf.setUseNormals (static_cast<bool> (use_normals));
-  fdrf.setNumTrainingImages (num_images);
+  fdrf.setForestFilename(forest_fn);
+  fdrf.setDirectory(directory);
+  fdrf.setWSize(80);
+  fdrf.setNumTrees(ntrees);
+  fdrf.setNumFeatures(n_features);
+  fdrf.setUseNormals(static_cast<bool>(use_normals));
+  fdrf.setNumTrainingImages(num_images);
 
-  //TODO: do some checks here..., fn file exists, directory exists, etc...
-  fdrf.trainWithDataProvider ();
+  // TODO: do some checks here..., fn file exists, directory exists, etc...
+  fdrf.trainWithDataProvider();
 }
-
index 2b023fd2290c1790880fd29698ec84be1b8259f8..f350acc83655f8c403f18aea81e02adda57ef309 100644 (file)
  *      Author: Aitor Aldoma
  */
 
-#include "pcl/recognition/face_detection/rf_face_detector_trainer.h"
 #include <pcl/console/parse.h>
 #include <pcl/io/pcd_io.h>
+#include <pcl/recognition/face_detection/rf_face_detector_trainer.h>
 #include <pcl/visualization/pcl_visualizer.h>
+// clang-format off
+#include <pcl/apps/face_detection/face_detection_apps_utils.h>
+// clang-format on
+
 #include <boost/filesystem.hpp>
-namespace bf = boost::filesystem;
 
-#include "pcl/apps/face_detection/face_detection_apps_utils.h"
+namespace bf = boost::filesystem;
 
 bool SHOW_GT = false;
 bool VIDEO = false;
 
-template<class PointInT>
-void run(pcl::RFFaceDetectorTrainer & fdrf, typename pcl::PointCloud<PointInT>::Ptr & scene_vis, pcl::visualization::PCLVisualizer & vis, bool heat_map,
-    bool show_votes, const std::string & filename)
+template <class PointInT>
+void
+run(pcl::RFFaceDetectorTrainer& fdrf,
+    typename pcl::PointCloud<PointInT>::Ptr& scene_vis,
+    pcl::visualization::PCLVisualizer& vis,
+    bool heat_map,
+    bool show_votes,
+    const std::string& filename)
 {
-  pcl::PointCloud<pcl::PointXYZ>::Ptr scene (new pcl::PointCloud<pcl::PointXYZ>);
-  pcl::copyPointCloud (*scene_vis, *scene);
+  pcl::PointCloud<pcl::PointXYZ>::Ptr scene(new pcl::PointCloud<pcl::PointXYZ>);
+  pcl::copyPointCloud(*scene_vis, *scene);
 
-  fdrf.setInputCloud (scene);
+  fdrf.setInputCloud(scene);
 
-  if (heat_map)
-  {
-    pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud (new pcl::PointCloud<pcl::PointXYZI>);
-    fdrf.setFaceHeatMapCloud (intensity_cloud);
+  if (heat_map) {
+    pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud(
+        new pcl::PointCloud<pcl::PointXYZI>);
+    fdrf.setFaceHeatMapCloud(intensity_cloud);
   }
 
-  fdrf.detectFaces ();
+  fdrf.detectFaces();
 
   using FieldListM = typename pcl::traits::fieldList<PointInT>::type;
 
   float rgb_m;
   bool exists_m;
-  pcl::for_each_type < FieldListM > (pcl::CopyIfFieldExists<PointInT, float> (scene_vis->points[0], "rgb", exists_m, rgb_m));
-
-  std::cout << "Color exists:" << static_cast<int> (exists_m) << std::endl;
-  if (exists_m)
-  {
-    pcl::PointCloud<pcl::PointXYZRGB>::Ptr to_visualize (new pcl::PointCloud<pcl::PointXYZRGB>);
-    pcl::copyPointCloud (*scene_vis, *to_visualize);
-
-    pcl::visualization::PointCloudColorHandlerRGBField < pcl::PointXYZRGB > handler_keypoints (to_visualize);
-    vis.addPointCloud < pcl::PointXYZRGB > (to_visualize, handler_keypoints, "scene_cloud");
-  } else
-  {
-    vis.addPointCloud (scene_vis, "scene_cloud");
+  pcl::for_each_type<FieldListM>(pcl::CopyIfFieldExists<PointInT, float>(
+      scene_vis->points[0], "rgb", exists_m, rgb_m));
+
+  std::cout << "Color exists:" << static_cast<int>(exists_m) << std::endl;
+  if (exists_m) {
+    pcl::PointCloud<pcl::PointXYZRGB>::Ptr to_visualize(
+        new pcl::PointCloud<pcl::PointXYZRGB>);
+    pcl::copyPointCloud(*scene_vis, *to_visualize);
+
+    pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>
+        handler_keypoints(to_visualize);
+    vis.addPointCloud<pcl::PointXYZRGB>(to_visualize, handler_keypoints, "scene_cloud");
+  }
+  else {
+    vis.addPointCloud(scene_vis, "scene_cloud");
   }
 
-  if (heat_map)
-  {
-    pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud (new pcl::PointCloud<pcl::PointXYZI>);
-    fdrf.getFaceHeatMap (intensity_cloud);
+  if (heat_map) {
+    pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud(
+        new pcl::PointCloud<pcl::PointXYZI>);
+    fdrf.getFaceHeatMap(intensity_cloud);
 
-    pcl::visualization::PointCloudColorHandlerGenericField < pcl::PointXYZI > handler_keypoints (intensity_cloud, "intensity");
-    vis.addPointCloud < pcl::PointXYZI > (intensity_cloud, handler_keypoints, "heat_map");
+    pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI>
+        handler_keypoints(intensity_cloud, "intensity");
+    vis.addPointCloud<pcl::PointXYZI>(intensity_cloud, handler_keypoints, "heat_map");
   }
 
-  if (show_votes)
-  {
-    //display votes_
-    /*pcl::PointCloud<pcl::PointXYZ>::Ptr votes_cloud(new pcl::PointCloud<pcl::PointXYZ>());
-     fdrf.getVotes(votes_cloud);
-     pcl::visualization::PointCloudColorHandlerCustom < pcl::PointXYZ > handler_votes(votes_cloud, 255, 0, 0);
-     vis.addPointCloud < pcl::PointXYZ > (votes_cloud, handler_votes, "votes_cloud");
-     vis.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 14, "votes_cloud");
-     vis.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "votes_cloud");
-     vis.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, 0.75, "votes_cloud");*/
-
-    pcl::PointCloud<pcl::PointXYZI>::Ptr votes_cloud (new pcl::PointCloud<pcl::PointXYZI> ());
-    fdrf.getVotes2 (votes_cloud);
-    pcl::visualization::PointCloudColorHandlerGenericField < pcl::PointXYZI > handler_votes (votes_cloud, "intensity");
-    vis.addPointCloud < pcl::PointXYZI > (votes_cloud, handler_votes, "votes_cloud");
-    vis.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 14, "votes_cloud");
+  if (show_votes) {
+
+    pcl::PointCloud<pcl::PointXYZI>::Ptr votes_cloud(
+        new pcl::PointCloud<pcl::PointXYZI>());
+    fdrf.getVotes2(votes_cloud);
+    pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI>
+        handler_votes(votes_cloud, "intensity");
+    vis.addPointCloud<pcl::PointXYZI>(votes_cloud, handler_votes, "votes_cloud");
+    vis.setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 14, "votes_cloud");
   }
 
-  vis.addCoordinateSystem (0.1, "global");
+  vis.addCoordinateSystem(0.1, "global");
 
   std::vector<Eigen::VectorXf> heads;
-  fdrf.getDetectedFaces (heads);
-  face_detection_apps_utils::displayHeads (heads, vis);
+  fdrf.getDetectedFaces(heads);
+  face_detection_apps_utils::displayHeads(heads, vis);
 
-  if (SHOW_GT)
-  {
-    //check if there is ground truth data
-    std::string pose_file (filename);
-    boost::replace_all (pose_file, ".pcd", "_pose.txt");
+  if (SHOW_GT) {
+    // check if there is ground truth data
+    std::string pose_file(filename);
+    boost::replace_all(pose_file, ".pcd", "_pose.txt");
 
     Eigen::Matrix4f pose_mat;
-    pose_mat.setIdentity (4, 4);
-    bool result = face_detection_apps_utils::readMatrixFromFile (pose_file, pose_mat);
+    pose_mat.setIdentity(4, 4);
+    bool result = face_detection_apps_utils::readMatrixFromFile(pose_file, pose_mat);
 
-    if (result)
-    {
-      Eigen::Vector3f ea = pose_mat.block<3, 3> (0, 0).eulerAngles (0, 1, 2);
-      Eigen::Vector3f trans_vector = Eigen::Vector3f (pose_mat (0, 3), pose_mat (1, 3), pose_mat (2, 3));
+    if (result) {
+      Eigen::Vector3f ea = pose_mat.block<3, 3>(0, 0).eulerAngles(0, 1, 2);
+      Eigen::Vector3f trans_vector =
+          Eigen::Vector3f(pose_mat(0, 3), pose_mat(1, 3), pose_mat(2, 3));
       std::cout << ea << std::endl;
       std::cout << trans_vector << std::endl;
 
@@ -107,10 +111,10 @@ void run(pcl::RFFaceDetectorTrainer & fdrf, typename pcl::PointCloud<PointInT>::
       center_point.x = trans_vector[0];
       center_point.y = trans_vector[1];
       center_point.z = trans_vector[2];
-      vis.addSphere (center_point, 0.05, 255, 0, 0, "sphere");
+      vis.addSphere(center_point, 0.05, 255, 0, 0, "sphere");
 
       pcl::ModelCoefficients cylinder_coeff;
-      cylinder_coeff.values.resize (7); // We need 7 values
+      cylinder_coeff.values.resize(7); // We need 7 values
       cylinder_coeff.values[0] = center_point.x;
       cylinder_coeff.values[1] = center_point.y;
       cylinder_coeff.values[2] = center_point.z;
@@ -119,13 +123,14 @@ void run(pcl::RFFaceDetectorTrainer & fdrf, typename pcl::PointCloud<PointInT>::
       cylinder_coeff.values[4] = ea[1];
       cylinder_coeff.values[5] = ea[2];
 
-      Eigen::Vector3f vec = Eigen::Vector3f::UnitZ () * -1.f;
+      Eigen::Vector3f vec = Eigen::Vector3f::UnitZ() * -1.f;
       Eigen::Matrix3f matrixxx;
 
-      matrixxx = Eigen::AngleAxisf (ea[0], Eigen::Vector3f::UnitX ()) * Eigen::AngleAxisf (ea[1], Eigen::Vector3f::UnitY ())
-          * Eigen::AngleAxisf (ea[2], Eigen::Vector3f::UnitZ ());
+      matrixxx = Eigen::AngleAxisf(ea[0], Eigen::Vector3f::UnitX()) *
+                 Eigen::AngleAxisf(ea[1], Eigen::Vector3f::UnitY()) *
+                 Eigen::AngleAxisf(ea[2], Eigen::Vector3f::UnitZ());
 
-      //matrixxx = pose_mat.block<3,3>(0,0);
+      // matrixxx = pose_mat.block<3,3>(0,0);
       vec = matrixxx * vec;
 
       cylinder_coeff.values[3] = vec[0];
@@ -133,25 +138,25 @@ void run(pcl::RFFaceDetectorTrainer & fdrf, typename pcl::PointCloud<PointInT>::
       cylinder_coeff.values[5] = vec[2];
 
       cylinder_coeff.values[6] = 0.01f;
-      vis.addCylinder (cylinder_coeff, "cylinder");
+      vis.addCylinder(cylinder_coeff, "cylinder");
     }
   }
 
-  vis.setRepresentationToSurfaceForAllActors ();
+  vis.setRepresentationToSurfaceForAllActors();
 
-  if (VIDEO)
-  {
-    vis.spinOnce (50, true);
-  } else
-  {
-    vis.spin ();
+  if (VIDEO) {
+    vis.spinOnce(50, true);
+  }
+  else {
+    vis.spin();
   }
 
-  vis.removeAllPointClouds ();
-  vis.removeAllShapes ();
+  vis.removeAllPointClouds();
+  vis.removeAllShapes();
 }
 
-int main(int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
   int STRIDE_SW = 5;
   std::string forest_fn = "forest.txt";
@@ -168,95 +173,91 @@ int main(int argc, char ** argv)
   int icp_iterations = 5;
   std::string model_path_;
 
-  pcl::console::parse_argument (argc, argv, "-forest_fn", forest_fn);
-  pcl::console::parse_argument (argc, argv, "-max_variance", trans_max_variance);
-  pcl::console::parse_argument (argc, argv, "-min_votes_size", min_votes_size);
-  pcl::console::parse_argument (argc, argv, "-use_normals", use_normals);
-  pcl::console::parse_argument (argc, argv, "-face_threshold", face_threshold);
-  pcl::console::parse_argument (argc, argv, "-stride_sw", STRIDE_SW);
-  pcl::console::parse_argument (argc, argv, "-heat_map", heat_map);
-  pcl::console::parse_argument (argc, argv, "-show_votes", show_votes);
-  pcl::console::parse_argument (argc, argv, "-test_directory", test_directory);
-  pcl::console::parse_argument (argc, argv, "-filename", filename);
-  pcl::console::parse_argument (argc, argv, "-rgb_exists", rgb_exists);
-  pcl::console::parse_argument (argc, argv, "-show_gt", SHOW_GT);
-  pcl::console::parse_argument (argc, argv, "-pose_refinement", pose_refinement_);
-  pcl::console::parse_argument (argc, argv, "-model_path", model_path_);
-  pcl::console::parse_argument (argc, argv, "-icp_iterations", icp_iterations);
-  pcl::console::parse_argument (argc, argv, "-video", VIDEO);
+  pcl::console::parse_argument(argc, argv, "-forest_fn", forest_fn);
+  pcl::console::parse_argument(argc, argv, "-max_variance", trans_max_variance);
+  pcl::console::parse_argument(argc, argv, "-min_votes_size", min_votes_size);
+  pcl::console::parse_argument(argc, argv, "-use_normals", use_normals);
+  pcl::console::parse_argument(argc, argv, "-face_threshold", face_threshold);
+  pcl::console::parse_argument(argc, argv, "-stride_sw", STRIDE_SW);
+  pcl::console::parse_argument(argc, argv, "-heat_map", heat_map);
+  pcl::console::parse_argument(argc, argv, "-show_votes", show_votes);
+  pcl::console::parse_argument(argc, argv, "-test_directory", test_directory);
+  pcl::console::parse_argument(argc, argv, "-filename", filename);
+  pcl::console::parse_argument(argc, argv, "-rgb_exists", rgb_exists);
+  pcl::console::parse_argument(argc, argv, "-show_gt", SHOW_GT);
+  pcl::console::parse_argument(argc, argv, "-pose_refinement", pose_refinement_);
+  pcl::console::parse_argument(argc, argv, "-model_path", model_path_);
+  pcl::console::parse_argument(argc, argv, "-icp_iterations", icp_iterations);
+  pcl::console::parse_argument(argc, argv, "-video", VIDEO);
 
   pcl::RFFaceDetectorTrainer fdrf;
-  fdrf.setForestFilename (forest_fn);
-  fdrf.setWSize (80);
-  fdrf.setUseNormals (static_cast<bool> (use_normals));
-  fdrf.setWStride (STRIDE_SW);
-  fdrf.setLeavesFaceMaxVariance (trans_max_variance);
-  fdrf.setLeavesFaceThreshold (face_threshold);
-  fdrf.setFaceMinVotes (min_votes_size);
-
-  if (pose_refinement_)
-  {
-    fdrf.setPoseRefinement (true, icp_iterations);
-    fdrf.setModelPath (model_path_);
+  fdrf.setForestFilename(forest_fn);
+  fdrf.setWSize(80);
+  fdrf.setUseNormals(static_cast<bool>(use_normals));
+  fdrf.setWStride(STRIDE_SW);
+  fdrf.setLeavesFaceMaxVariance(trans_max_variance);
+  fdrf.setLeavesFaceThreshold(face_threshold);
+  fdrf.setFaceMinVotes(min_votes_size);
+
+  if (pose_refinement_) {
+    fdrf.setPoseRefinement(true, icp_iterations);
+    fdrf.setModelPath(model_path_);
   }
 
-//load forest from file and pass it to the detector
+  // load forest from file and pass it to the detector
   std::filebuf fb;
-  fb.open (forest_fn.c_str (), std::ios::in);
-  std::istream os (&fb);
+  fb.open(forest_fn.c_str(), std::ios::in);
+  std::istream os(&fb);
 
   using NodeType = pcl::face_detection::RFTreeNode<pcl::face_detection::FeatureType>;
   pcl::DecisionForest<NodeType> forest;
-  forest.deserialize (os);
-  fb.close ();
+  forest.deserialize(os);
+  fb.close();
 
-  fdrf.setForest (forest);
+  fdrf.setForest(forest);
 
-  pcl::visualization::PCLVisualizer vis ("PCL Face detection");
+  pcl::visualization::PCLVisualizer vis("PCL Face detection");
 
-  if (!test_directory.empty())
-  {
-    //recognize all files in directory...
+  if (!test_directory.empty()) {
+    // recognize all files in directory...
     std::string start;
-    std::string ext = std::string ("pcd");
+    std::string ext = std::string("pcd");
     bf::path dir = test_directory;
 
     std::vector<std::string> files;
-    face_detection_apps_utils::getFilesInDirectory (dir, start, files, ext);
+    face_detection_apps_utils::getFilesInDirectory(dir, start, files, ext);
 
-    std::sort (files.begin (), files.end (), face_detection_apps_utils::sortFiles);
+    std::sort(files.begin(), files.end(), face_detection_apps_utils::sortFiles);
 
-    for (const auto &filename : files)
-    {
+    for (const auto& filename : files) {
       std::string file = test_directory + '/' + filename;
       std::cout << file << std::endl;
 
-      if (rgb_exists)
-      {
+      if (rgb_exists) {
         std::cout << "Loading a PointXYZRGBA cloud..." << std::endl;
-        pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
-        pcl::io::loadPCDFile (file, *cloud);
-        run<pcl::PointXYZRGB> (fdrf, cloud, vis, heat_map, show_votes, file);
-      } else
-      {
-        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
-        pcl::io::loadPCDFile (file, *cloud);
-        run<pcl::PointXYZ> (fdrf, cloud, vis, heat_map, show_votes, file);
+        pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
+            new pcl::PointCloud<pcl::PointXYZRGB>);
+        pcl::io::loadPCDFile(file, *cloud);
+        run<pcl::PointXYZRGB>(fdrf, cloud, vis, heat_map, show_votes, file);
+      }
+      else {
+        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
+        pcl::io::loadPCDFile(file, *cloud);
+        run<pcl::PointXYZ>(fdrf, cloud, vis, heat_map, show_votes, file);
       }
     }
-  } else
-  {
-    if (rgb_exists)
-    {
-      pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
-      pcl::io::loadPCDFile (filename, *cloud);
-      run<pcl::PointXYZRGB> (fdrf, cloud, vis, heat_map, show_votes, filename);
-    } else
-    {
-      pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
-      pcl::io::loadPCDFile (filename, *cloud);
-      run<pcl::PointXYZ> (fdrf, cloud, vis, heat_map, show_votes, filename);
+  }
+  else {
+    if (rgb_exists) {
+      pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
+          new pcl::PointCloud<pcl::PointXYZRGB>);
+      pcl::io::loadPCDFile(filename, *cloud);
+      run<pcl::PointXYZRGB>(fdrf, cloud, vis, heat_map, show_votes, filename);
+    }
+    else {
+      pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
+      pcl::io::loadPCDFile(filename, *cloud);
+      run<pcl::PointXYZ>(fdrf, cloud, vis, heat_map, show_votes, filename);
     }
   }
 }
-
index 8bb8cc570359a11049d3f6696df246efaae3d90c..39130057cd9161cb8113ad7b636cb63d675e3051 100644 (file)
@@ -5,85 +5,94 @@
  *      Author: Aitor Aldoma
  */
 
-#include "pcl/recognition/face_detection/rf_face_detector_trainer.h"
-#include "pcl/apps/face_detection/openni_frame_source.h"
-#include "pcl/apps/face_detection/face_detection_apps_utils.h"
+#include <pcl/apps/face_detection/openni_frame_source.h>
 #include <pcl/common/time.h>
 #include <pcl/console/parse.h>
 #include <pcl/features/integral_image_normal.h>
+#include <pcl/recognition/face_detection/rf_face_detector_trainer.h>
+// clang-format off
+#include <pcl/apps/face_detection/face_detection_apps_utils.h>
+// clang-format on
 
-void run(pcl::RFFaceDetectorTrainer & fdrf, bool heat_map = false, bool show_votes = false)
+void
+run(pcl::RFFaceDetectorTrainer& fdrf, bool heat_map = false, bool show_votes = false)
 {
   OpenNIFrameSource::OpenNIFrameSource camera;
   OpenNIFrameSource::PointCloudPtr scene_vis;
 
-  pcl::visualization::PCLVisualizer vis ("Face dection");
-  vis.addCoordinateSystem (0.1, "global");
+  pcl::visualization::PCLVisualizer vis("Face dection");
+  vis.addCoordinateSystem(0.1, "global");
 
-  //keyboard callback to stop getting frames and finalize application
-  std::function<void(const pcl::visualization::KeyboardEvent&)> keyboard_cb = [&] (const pcl::visualization::KeyboardEvent& event)
-  {
-    camera.onKeyboardEvent (event);
-  };
-  vis.registerKeyboardCallback (keyboard_cb);
+  // keyboard callback to stop getting frames and finalize application
+  std::function<void(const pcl::visualization::KeyboardEvent&)> keyboard_cb =
+      [&](const pcl::visualization::KeyboardEvent& event) {
+        camera.onKeyboardEvent(event);
+      };
+  vis.registerKeyboardCallback(keyboard_cb);
 
-  while (camera.isActive ())
-  {
-    scene_vis = camera.snap ();
+  while (camera.isActive()) {
+    scene_vis = camera.snap();
 
-    pcl::PointCloud<pcl::PointXYZ>::Ptr scene (new pcl::PointCloud<pcl::PointXYZ> ());
-    pcl::copyPointCloud (*scene_vis, *scene);
+    pcl::PointCloud<pcl::PointXYZ>::Ptr scene(new pcl::PointCloud<pcl::PointXYZ>());
+    pcl::copyPointCloud(*scene_vis, *scene);
 
-    fdrf.setInputCloud (scene);
+    fdrf.setInputCloud(scene);
 
-    if (heat_map)
-    {
-      pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud (new pcl::PointCloud<pcl::PointXYZI>);
-      fdrf.setFaceHeatMapCloud (intensity_cloud);
+    if (heat_map) {
+      pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud(
+          new pcl::PointCloud<pcl::PointXYZI>);
+      fdrf.setFaceHeatMapCloud(intensity_cloud);
     }
 
     {
-      pcl::ScopeTime t ("Detect faces...");
-      fdrf.detectFaces ();
+      pcl::ScopeTime t("Detect faces...");
+      fdrf.detectFaces();
     }
-    pcl::visualization::PointCloudColorHandlerRGBField<OpenNIFrameSource::PointT> handler_keypoints (scene_vis);
-    vis.addPointCloud < OpenNIFrameSource::PointT > (scene_vis, handler_keypoints, "scene_cloud");
-
-    if (heat_map)
-    {
-      pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud (new pcl::PointCloud<pcl::PointXYZI>);
-      fdrf.getFaceHeatMap (intensity_cloud);
-      pcl::visualization::PointCloudColorHandlerGenericField < pcl::PointXYZI > handler_keypoints (intensity_cloud, "intensity");
-      vis.addPointCloud < pcl::PointXYZI > (intensity_cloud, handler_keypoints, "heat_map");
+    pcl::visualization::PointCloudColorHandlerRGBField<OpenNIFrameSource::PointT>
+        handler_keypoints(scene_vis);
+    vis.addPointCloud<OpenNIFrameSource::PointT>(
+        scene_vis, handler_keypoints, "scene_cloud");
+
+    if (heat_map) {
+      pcl::PointCloud<pcl::PointXYZI>::Ptr intensity_cloud(
+          new pcl::PointCloud<pcl::PointXYZI>);
+      fdrf.getFaceHeatMap(intensity_cloud);
+      pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI>
+          handler_keypoints(intensity_cloud, "intensity");
+      vis.addPointCloud<pcl::PointXYZI>(intensity_cloud, handler_keypoints, "heat_map");
     }
 
-    if (show_votes)
-    {
-      //display votes_
-      pcl::PointCloud<pcl::PointXYZ>::Ptr votes_cloud (new pcl::PointCloud<pcl::PointXYZ> ());
-      fdrf.getVotes (votes_cloud);
-      pcl::visualization::PointCloudColorHandlerCustom < pcl::PointXYZ > handler_votes (votes_cloud, 255, 0, 0);
-      vis.addPointCloud < pcl::PointXYZ > (votes_cloud, handler_votes, "votes_cloud");
-      vis.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 14, "votes_cloud");
-      vis.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "votes_cloud");
-      vis.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.75, "votes_cloud");
+    if (show_votes) {
+      // display votes_
+      pcl::PointCloud<pcl::PointXYZ>::Ptr votes_cloud(
+          new pcl::PointCloud<pcl::PointXYZ>());
+      fdrf.getVotes(votes_cloud);
+      pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> handler_votes(
+          votes_cloud, 255, 0, 0);
+      vis.addPointCloud<pcl::PointXYZ>(votes_cloud, handler_votes, "votes_cloud");
+      vis.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 14, "votes_cloud");
+      vis.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "votes_cloud");
+      vis.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, 0.75, "votes_cloud");
     }
 
     std::vector<Eigen::VectorXf> heads;
-    fdrf.getDetectedFaces (heads);
+    fdrf.getDetectedFaces(heads);
 
-    face_detection_apps_utils::displayHeads (heads, vis);
+    face_detection_apps_utils::displayHeads(heads, vis);
 
-    vis.setRepresentationToSurfaceForAllActors ();
-    vis.spinOnce ();
+    vis.setRepresentationToSurfaceForAllActors();
+    vis.spinOnce();
 
-    vis.removeAllPointClouds ();
-    vis.removeAllShapes ();
+    vis.removeAllPointClouds();
+    vis.removeAllShapes();
   }
 }
 
-//./bin/pcl_openni_face_detector -face_threshold 0.99 -max_variance 2400 -min_votes_size 300 -stride_sw 4 -heat_map 0 -show_votes 1 -pose_refinement 1 -icp_iterations 5 -model_path face_model.pcd -forest_fn forest.txt
-int main(int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
   int STRIDE_SW = 4;
   int use_normals = 0;
@@ -98,45 +107,43 @@ int main(int argc, char ** argv)
   std::string forest_fn = "../data/forests/forest.txt";
   std::string model_path_ = "../data/ply_models/face.pcd";
 
-  pcl::console::parse_argument (argc, argv, "-forest_fn", forest_fn);
-  pcl::console::parse_argument (argc, argv, "-max_variance", trans_max_variance);
-  pcl::console::parse_argument (argc, argv, "-min_votes_size", min_votes_size);
-  pcl::console::parse_argument (argc, argv, "-use_normals", use_normals);
-  pcl::console::parse_argument (argc, argv, "-face_threshold", face_threshold);
-  pcl::console::parse_argument (argc, argv, "-stride_sw", STRIDE_SW);
-  pcl::console::parse_argument (argc, argv, "-heat_map", heat_map);
-  pcl::console::parse_argument (argc, argv, "-show_votes", show_votes);
-  pcl::console::parse_argument (argc, argv, "-pose_refinement", pose_refinement_);
-  pcl::console::parse_argument (argc, argv, "-model_path", model_path_);
-  pcl::console::parse_argument (argc, argv, "-icp_iterations", icp_iterations);
+  pcl::console::parse_argument(argc, argv, "-forest_fn", forest_fn);
+  pcl::console::parse_argument(argc, argv, "-max_variance", trans_max_variance);
+  pcl::console::parse_argument(argc, argv, "-min_votes_size", min_votes_size);
+  pcl::console::parse_argument(argc, argv, "-use_normals", use_normals);
+  pcl::console::parse_argument(argc, argv, "-face_threshold", face_threshold);
+  pcl::console::parse_argument(argc, argv, "-stride_sw", STRIDE_SW);
+  pcl::console::parse_argument(argc, argv, "-heat_map", heat_map);
+  pcl::console::parse_argument(argc, argv, "-show_votes", show_votes);
+  pcl::console::parse_argument(argc, argv, "-pose_refinement", pose_refinement_);
+  pcl::console::parse_argument(argc, argv, "-model_path", model_path_);
+  pcl::console::parse_argument(argc, argv, "-icp_iterations", icp_iterations);
 
   pcl::RFFaceDetectorTrainer fdrf;
-  fdrf.setForestFilename (forest_fn);
-  fdrf.setWSize (80);
-  fdrf.setUseNormals (static_cast<bool> (use_normals));
-  fdrf.setWStride (STRIDE_SW);
-  fdrf.setLeavesFaceMaxVariance (trans_max_variance);
-  fdrf.setLeavesFaceThreshold (face_threshold);
-  fdrf.setFaceMinVotes (min_votes_size);
-
-  if (pose_refinement_)
-  {
-    fdrf.setPoseRefinement (true, icp_iterations);
-    fdrf.setModelPath (model_path_);
+  fdrf.setForestFilename(forest_fn);
+  fdrf.setWSize(80);
+  fdrf.setUseNormals(static_cast<bool>(use_normals));
+  fdrf.setWStride(STRIDE_SW);
+  fdrf.setLeavesFaceMaxVariance(trans_max_variance);
+  fdrf.setLeavesFaceThreshold(face_threshold);
+  fdrf.setFaceMinVotes(min_votes_size);
+
+  if (pose_refinement_) {
+    fdrf.setPoseRefinement(true, icp_iterations);
+    fdrf.setModelPath(model_path_);
   }
 
-//load forest from file and pass it to the detector
+  // load forest from file and pass it to the detector
   std::filebuf fb;
-  fb.open (forest_fn.c_str (), std::ios::in);
-  std::istream os (&fb);
+  fb.open(forest_fn.c_str(), std::ios::in);
+  std::istream os(&fb);
 
   using NodeType = pcl::face_detection::RFTreeNode<pcl::face_detection::FeatureType>;
   pcl::DecisionForest<NodeType> forest;
-  forest.deserialize (os);
-  fb.close ();
+  forest.deserialize(os);
+  fb.close();
 
-  fdrf.setForest (forest);
+  fdrf.setForest(forest);
 
-  run (fdrf, heat_map, show_votes);
+  run(fdrf, heat_map, show_votes);
 }
-
index 1cfb7ae81ac0b85372f3140103777c0243c6bd3d..07991aeb096d1005275291943d2fbc3ab883c7ea 100644 (file)
@@ -1,51 +1,54 @@
-#include "pcl/apps/face_detection/openni_frame_source.h"
+#include <pcl/apps/face_detection/openni_frame_source.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
-namespace OpenNIFrameSource
-{
+namespace OpenNIFrameSource {
 
-  OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) :
-      grabber_ (device_id), frame_counter_ (0), active_ (true)
-  {
-    std::function<void(const PointCloudConstPtr&)> frame_cb = [this] (const PointCloudConstPtr& cloud) { onNewFrame (cloud); };
-    grabber_.registerCallback (frame_cb);
-    grabber_.start ();
-  }
+OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id)
+: grabber_(device_id), frame_counter_(0), active_(true)
+{
+  std::function<void(const PointCloudConstPtr&)> frame_cb =
+      [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); };
+  grabber_.registerCallback(frame_cb);
+  grabber_.start();
+}
 
-  OpenNIFrameSource::~OpenNIFrameSource()
-  {
-    // Stop the grabber when shutting down
-    grabber_.stop ();
-  }
+OpenNIFrameSource::~OpenNIFrameSource()
+{
+  // Stop the grabber when shutting down
+  grabber_.stop();
+}
 
-  bool OpenNIFrameSource::isActive()
-  {
-    return active_;
-  }
+bool
+OpenNIFrameSource::isActive() const
+{
+  return active_;
+}
 
-  const PointCloudPtr OpenNIFrameSource::snap()
-  {
-    return (most_recent_frame_);
-  }
+const PointCloudPtr
+OpenNIFrameSource::snap()
+{
+  return most_recent_frame_;
+}
 
-  void OpenNIFrameSource::onNewFrame(const PointCloudConstPtr &cloud)
-  {
-    mutex_.lock ();
-    ++frame_counter_;
-    most_recent_frame_ = pcl::make_shared<PointCloud> (*cloud); // Make a copy of the frame
-    mutex_.unlock ();
-  }
+void
+OpenNIFrameSource::onNewFrame(const PointCloudConstPtr& cloud)
+{
+  mutex_.lock();
+  ++frame_counter_;
+  most_recent_frame_ = pcl::make_shared<PointCloud>(*cloud); // Make a copy of the frame
+  mutex_.unlock();
+}
 
-  void OpenNIFrameSource::onKeyboardEvent(const pcl::visualization::KeyboardEvent & event)
-  {
-    // When the spacebar is pressed, trigger a frame capture
-    mutex_.lock ();
-    if (event.keyDown () && event.getKeySym () == "e")
-    {
-      active_ = false;
-    }
-    mutex_.unlock ();
+void
+OpenNIFrameSource::onKeyboardEvent(const pcl::visualization::KeyboardEvent& event)
+{
+  // When the spacebar is pressed, trigger a frame capture
+  mutex_.lock();
+  if (event.keyDown() && event.getKeySym() == "e") {
+    active_ = false;
   }
-
+  mutex_.unlock();
 }
+
+} // namespace OpenNIFrameSource
index db2eb1c571e53fa802c991025143609005bc3d02..bdf980c64e692ab3002144b4b7d21dc42e23cf3d 100644 (file)
-#include <vector>
-#include <string>
-#include <sstream>
+#include <pcl/common/transforms.h>
+#include <pcl/features/3dsc.h>
+#include <pcl/features/fpfh_omp.h>
+#include <pcl/features/pfh.h>
+#include <pcl/features/pfhrgb.h>
+#include <pcl/features/shot_omp.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/registration/transforms.h>
-#include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/keypoints/sift_keypoint.h>
 #include <pcl/keypoints/harris_3d.h>
-#include <pcl/ModelCoefficients.h>
+#include <pcl/keypoints/sift_keypoint.h>
+#include <pcl/registration/correspondence_rejection_sample_consensus.h>
+#include <pcl/registration/icp.h>
+#include <pcl/registration/transformation_estimation_svd.h>
+#include <pcl/registration/transforms.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
-#include <pcl/segmentation/sac_segmentation.h>
 #include <pcl/search/kdtree.h>
 #include <pcl/segmentation/extract_clusters.h>
-#include <pcl/features/fpfh_omp.h>
-#include <pcl/features/pfh.h>
-#include <pcl/features/pfhrgb.h>
-#include <pcl/features/3dsc.h>
-#include <pcl/features/shot_omp.h>
-#include <pcl/registration/transformation_estimation_svd.h>
-#include <pcl/registration/icp.h>
-#include <pcl/registration/correspondence_rejection_sample_consensus.h>
-#include <pcl/common/transforms.h>
-#include <pcl/surface/grid_projection.h>
+#include <pcl/segmentation/sac_segmentation.h>
 #include <pcl/surface/gp3.h>
+#include <pcl/surface/grid_projection.h>
 #include <pcl/surface/marching_cubes_hoppe.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/ModelCoefficients.h>
+#include <pcl/memory.h> // for pcl::dynamic_pointer_cast
 
-template<typename FeatureType>
-class ICCVTutorial
-{
-  public:
-    ICCVTutorial (pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector,
-                  typename pcl::Feature<pcl::PointXYZRGB, FeatureType>::Ptr feature_extractor,
-                  pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor,
-                  pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source,
-                  pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target);
-
-    /**
-     * @brief starts the event loop for the visualizer
-     */
-    void run ();
-  protected:
-    /**
-     * @brief remove plane and select largest cluster as input object
-     * @param input the input point cloud
-     * @param segmented the resulting segmented point cloud containing only points of the largest cluster
-     */
-    void segmentation (const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& input, const typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr& segmented) const;
-
-    /**
-     * @brief Detects key points in the input point cloud
-     * @param input the input point cloud
-     * @param keypoints the resulting key points. Note that they are not necessarily a subset of the input cloud
-     */
-    void detectKeypoints (const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& input, const pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints) const;
-
-    /**
-     * @brief extract descriptors for given key points
-     * @param input point cloud to be used for descriptor extraction
-     * @param keypoints locations where descriptors are to be extracted
-     * @param features resulting descriptors
-     */
-    void extractDescriptors (typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input, const typename pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints, typename pcl::PointCloud<FeatureType>::Ptr features);
-
-    /**
-     * @brief find corresponding features based on some metric
-     * @param source source feature descriptors
-     * @param target target feature descriptors
-     * @param correspondences indices out of the target descriptors that correspond (nearest neighbor) to the source descriptors
-     */
-    void findCorrespondences (typename pcl::PointCloud<FeatureType>::Ptr source, typename pcl::PointCloud<FeatureType>::Ptr target, std::vector<int>& correspondences) const;
-
-    /**
-     * @brief  remove non-consistent correspondences
-     */
-    void filterCorrespondences ();
-
-    /**
-     * @brief calculate the initial rigid transformation from filtered corresponding keypoints
-     */
-    void determineInitialTransformation ();
-
-    /**
-     * @brief calculate the final rigid transformation using ICP over all points
-     */
-    void determineFinalTransformation ();
-
-    /**
-     * @brief reconstructs the surface from merged point clouds
-     */
-    void reconstructSurface ();
-
-    /**
-     * @brief callback to handle keyboard events
-     * @param event object containing information about the event. e.g. type (press, release) etc.
-     * @param cookie user defined data passed during registration of the callback
-     */
-    void keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie);
-
-  private:
-    pcl::visualization::PCLVisualizer visualizer_;
-    pcl::PointCloud<pcl::PointXYZI>::Ptr source_keypoints_;
-    pcl::PointCloud<pcl::PointXYZI>::Ptr target_keypoints_;
-    pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector_;
-    typename pcl::Feature<pcl::PointXYZRGB, FeatureType>::Ptr feature_extractor_;
-    pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor_;
-    typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source_;
-    typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target_;
-    typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_segmented_;
-    typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr target_segmented_;
-    typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_transformed_;
-    typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_registered_;
-    typename pcl::PolygonMesh surface_;
-    typename pcl::PointCloud<FeatureType>::Ptr source_features_;
-    typename pcl::PointCloud<FeatureType>::Ptr target_features_;
-    std::vector<int> source2target_;
-    std::vector<int> target2source_;
-    pcl::CorrespondencesPtr correspondences_;
-    Eigen::Matrix4f initial_transformation_matrix_;
-    Eigen::Matrix4f transformation_matrix_;
-    bool show_source2target_;
-    bool show_target2source_;
-    bool show_correspondences;
+#include <sstream>
+#include <string>
+#include <vector>
+
+template <typename FeatureType>
+class ICCVTutorial {
+public:
+  ICCVTutorial(
+      pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector,
+      typename pcl::Feature<pcl::PointXYZRGB, FeatureType>::Ptr feature_extractor,
+      pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor,
+      pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source,
+      pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target);
+
+  /**
+   * \brief starts the event loop for the visualizer
+   */
+  void
+  run();
+
+protected:
+  /**
+   * \brief remove plane and select largest cluster as input object
+   * \param input the input point cloud
+   * \param segmented the resulting segmented point cloud containing only points of the
+   * largest cluster
+   */
+  void
+  segmentation(const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& input,
+               const typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr& segmented) const;
+
+  /**
+   * \brief Detects key points in the input point cloud
+   * \param input the input point cloud
+   * \param keypoints the resulting key points. Note that they are not necessarily a
+   * subset of the input cloud
+   */
+  void
+  detectKeypoints(const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& input,
+                  const pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints) const;
+
+  /**
+   * \brief extract descriptors for given key points
+   * \param input point cloud to be used for descriptor extraction
+   * \param keypoints locations where descriptors are to be extracted
+   * \param features resulting descriptors
+   */
+  void
+  extractDescriptors(typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input,
+                     const typename pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints,
+                     typename pcl::PointCloud<FeatureType>::Ptr features);
+
+  /**
+   * \brief find corresponding features based on some metric
+   * \param source source feature descriptors
+   * \param target target feature descriptors
+   * \param correspondences indices out of the target descriptors that correspond
+   * (nearest neighbor) to the source descriptors
+   */
+  void
+  findCorrespondences(typename pcl::PointCloud<FeatureType>::Ptr source,
+                      typename pcl::PointCloud<FeatureType>::Ptr target,
+                      std::vector<int>& correspondences) const;
+
+  /**
+   * \brief  remove non-consistent correspondences
+   */
+  void
+  filterCorrespondences();
+
+  /**
+   * \brief calculate the initial rigid transformation from filtered corresponding
+   * keypoints
+   */
+  void
+  determineInitialTransformation();
+
+  /**
+   * \brief calculate the final rigid transformation using ICP over all points
+   */
+  void
+  determineFinalTransformation();
+
+  /**
+   * \brief reconstructs the surface from merged point clouds
+   */
+  void
+  reconstructSurface();
+
+  /**
+   * \brief callback to handle keyboard events
+   * \param event object containing information about the event. e.g. type (press,
+   * release) etc.
+   * \param cookie user defined data passed during registration of the callback
+   */
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void* cookie);
+
+private:
+  pcl::visualization::PCLVisualizer visualizer_;
+  pcl::PointCloud<pcl::PointXYZI>::Ptr source_keypoints_;
+  pcl::PointCloud<pcl::PointXYZI>::Ptr target_keypoints_;
+  pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector_;
+  typename pcl::Feature<pcl::PointXYZRGB, FeatureType>::Ptr feature_extractor_;
+  pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor_;
+  typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source_;
+  typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target_;
+  typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_segmented_;
+  typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr target_segmented_;
+  typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_transformed_;
+  typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_registered_;
+  typename pcl::PolygonMesh surface_;
+  typename pcl::PointCloud<FeatureType>::Ptr source_features_;
+  typename pcl::PointCloud<FeatureType>::Ptr target_features_;
+  std::vector<int> source2target_;
+  std::vector<int> target2source_;
+  pcl::CorrespondencesPtr correspondences_;
+  Eigen::Matrix4f initial_transformation_matrix_;
+  Eigen::Matrix4f transformation_matrix_;
+  bool show_source2target_;
+  bool show_target2source_;
+  bool show_correspondences;
 };
 
-template<typename FeatureType>
-ICCVTutorial<FeatureType>::ICCVTutorial(pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector,
-                                        typename pcl::Feature<pcl::PointXYZRGB, FeatureType>::Ptr feature_extractor,
-                                        pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor,
-                                        pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source,
-                                        pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target)
-: source_keypoints_ (new pcl::PointCloud<pcl::PointXYZI> ())
-, target_keypoints_ (new pcl::PointCloud<pcl::PointXYZI> ())
-, keypoint_detector_ (std::move(keypoint_detector))
-, feature_extractor_ (feature_extractor)
-, surface_reconstructor_ (std::move(surface_reconstructor))
-, source_ (std::move(source))
-, target_ (std::move(target))
-, source_segmented_ (new pcl::PointCloud<pcl::PointXYZRGB>)
-, target_segmented_ (new pcl::PointCloud<pcl::PointXYZRGB>)
-, source_transformed_ (new pcl::PointCloud<pcl::PointXYZRGB>)
-, source_registered_ (new pcl::PointCloud<pcl::PointXYZRGB>)
-, source_features_ (new pcl::PointCloud<FeatureType>)
-, target_features_ (new pcl::PointCloud<FeatureType>)
-, correspondences_ (new pcl::Correspondences)
-, show_source2target_ (false)
-, show_target2source_ (false)
-, show_correspondences (false)
+template <typename FeatureType>
+ICCVTutorial<FeatureType>::ICCVTutorial(
+    pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector,
+    typename pcl::Feature<pcl::PointXYZRGB, FeatureType>::Ptr feature_extractor,
+    pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor,
+    pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source,
+    pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target)
+: source_keypoints_(new pcl::PointCloud<pcl::PointXYZI>())
+, target_keypoints_(new pcl::PointCloud<pcl::PointXYZI>())
+, keypoint_detector_(std::move(keypoint_detector))
+, feature_extractor_(feature_extractor)
+, surface_reconstructor_(std::move(surface_reconstructor))
+, source_(std::move(source))
+, target_(std::move(target))
+, source_segmented_(new pcl::PointCloud<pcl::PointXYZRGB>)
+, target_segmented_(new pcl::PointCloud<pcl::PointXYZRGB>)
+, source_transformed_(new pcl::PointCloud<pcl::PointXYZRGB>)
+, source_registered_(new pcl::PointCloud<pcl::PointXYZRGB>)
+, source_features_(new pcl::PointCloud<FeatureType>)
+, target_features_(new pcl::PointCloud<FeatureType>)
+, correspondences_(new pcl::Correspondences)
+, show_source2target_(false)
+, show_target2source_(false)
+, show_correspondences(false)
 {
-  visualizer_.registerKeyboardCallback(&ICCVTutorial::keyboard_callback, *this, nullptr);
+  visualizer_.registerKeyboardCallback(
+      &ICCVTutorial::keyboard_callback, *this, nullptr);
 
-  segmentation (source_, source_segmented_);
-  segmentation (target_, target_segmented_);
+  segmentation(source_, source_segmented_);
+  segmentation(target_, target_segmented_);
 
-  detectKeypoints (source_segmented_, source_keypoints_);
-  detectKeypoints (target_segmented_, target_keypoints_);
+  detectKeypoints(source_segmented_, source_keypoints_);
+  detectKeypoints(target_segmented_, target_keypoints_);
 
-  extractDescriptors (source_segmented_, source_keypoints_, source_features_);
-  extractDescriptors (target_segmented_, target_keypoints_, target_features_);
+  extractDescriptors(source_segmented_, source_keypoints_, source_features_);
+  extractDescriptors(target_segmented_, target_keypoints_, target_features_);
 
-  findCorrespondences (source_features_, target_features_, source2target_);
-  findCorrespondences (target_features_, source_features_, target2source_);
+  findCorrespondences(source_features_, target_features_, source2target_);
+  findCorrespondences(target_features_, source_features_, target2source_);
 
-  filterCorrespondences ();
+  filterCorrespondences();
 
-  determineInitialTransformation ();
-  determineFinalTransformation ();
+  determineInitialTransformation();
+  determineFinalTransformation();
 
-  reconstructSurface ();
+  reconstructSurface();
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::segmentation (const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& source, const typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr& segmented) const
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::segmentation(
+    const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& source,
+    const typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr& segmented) const
 {
   std::cout << "segmentation..." << std::flush;
   // fit plane and keep points above that plane
-  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
-  pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
+  pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
+  pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
   // Create the segmentation object
   pcl::SACSegmentation<pcl::PointXYZRGB> seg;
   // Optional
-  seg.setOptimizeCoefficients (true);
+  seg.setOptimizeCoefficients(true);
   // Mandatory
-  seg.setModelType (pcl::SACMODEL_PLANE);
-  seg.setMethodType (pcl::SAC_RANSAC);
-  seg.setDistanceThreshold (0.02);
+  seg.setModelType(pcl::SACMODEL_PLANE);
+  seg.setMethodType(pcl::SAC_RANSAC);
+  seg.setDistanceThreshold(0.02);
 
-  seg.setInputCloud (source);
-  seg.segment (*inliers, *coefficients);
+  seg.setInputCloud(source);
+  seg.segment(*inliers, *coefficients);
 
   pcl::ExtractIndices<pcl::PointXYZRGB> extract;
-  extract.setInputCloud (source);
-  extract.setIndices (inliers);
-  extract.setNegative (true);
+  extract.setInputCloud(source);
+  extract.setIndices(inliers);
+  extract.setNegative(true);
 
-  extract.filter (*segmented);
+  extract.filter(*segmented);
   std::vector<int> indices;
   pcl::removeNaNFromPointCloud(*segmented, *segmented, indices);
   std::cout << "OK" << std::endl;
 
   std::cout << "clustering..." << std::flush;
   // euclidean clustering
-  typename pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB>);
-  tree->setInputCloud (segmented);
+  typename pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree(
+      new pcl::search::KdTree<pcl::PointXYZRGB>);
+  tree->setInputCloud(segmented);
 
   std::vector<pcl::PointIndices> cluster_indices;
   pcl::EuclideanClusterExtraction<pcl::PointXYZRGB> clustering;
-  clustering.setClusterTolerance (0.02); // 2cm
-  clustering.setMinClusterSize (1000);
-  clustering.setMaxClusterSize (250000);
-  clustering.setSearchMethod (tree);
+  clustering.setClusterTolerance(0.02); // 2cm
+  clustering.setMinClusterSize(1000);
+  clustering.setMaxClusterSize(250000);
+  clustering.setSearchMethod(tree);
   clustering.setInputCloud(segmented);
-  clustering.extract (cluster_indices);
+  clustering.extract(cluster_indices);
 
-  if (!cluster_indices.empty ())//use largest cluster
+  if (!cluster_indices.empty()) // use largest cluster
   {
     std::cout << cluster_indices.size() << " clusters found";
     if (cluster_indices.size() > 1)
-      std::cout <<" Using largest one...";
+      std::cout << " Using largest one...";
     std::cout << std::endl;
-    typename pcl::IndicesPtr indices (new std::vector<int>);
+    typename pcl::IndicesPtr indices(new std::vector<int>);
     *indices = cluster_indices[0].indices;
-    extract.setInputCloud (segmented);
-    extract.setIndices (indices);
-    extract.setNegative (false);
+    extract.setInputCloud(segmented);
+    extract.setIndices(indices);
+    extract.setNegative(false);
 
-    extract.filter (*segmented);
+    extract.filter(*segmented);
   }
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::detectKeypoints (const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& input, const pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints) const
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::detectKeypoints(
+    const typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& input,
+    const pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints) const
 {
   std::cout << "keypoint detection..." << std::flush;
   keypoint_detector_->setInputCloud(input);
@@ -237,140 +270,168 @@ void ICCVTutorial<FeatureType>::detectKeypoints (const typename pcl::PointCloud<
   std::cout << "OK. keypoints found: " << keypoints->points.size() << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::extractDescriptors (typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input, const typename pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints, typename pcl::PointCloud<FeatureType>::Ptr features)
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::extractDescriptors(
+    typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input,
+    const typename pcl::PointCloud<pcl::PointXYZI>::Ptr& keypoints,
+    typename pcl::PointCloud<FeatureType>::Ptr features)
 {
-  typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr kpts(new pcl::PointCloud<pcl::PointXYZRGB>);
+  typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr kpts(
+      new pcl::PointCloud<pcl::PointXYZRGB>);
   kpts->points.resize(keypoints->points.size());
 
   pcl::copyPointCloud(*keypoints, *kpts);
 
-  typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType>::Ptr feature_from_normals = boost::dynamic_pointer_cast<pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType> > (feature_extractor_);
+  typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType>::Ptr
+      feature_from_normals = pcl::dynamic_pointer_cast<
+          pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType>>(
+          feature_extractor_);
 
   feature_extractor_->setSearchSurface(input);
   feature_extractor_->setInputCloud(kpts);
 
-  if (feature_from_normals)
-  //if (boost::dynamic_pointer_cast<typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType> > (feature_extractor_))
-  {
+  if (feature_from_normals) {
     std::cout << "normal estimation..." << std::flush;
-    typename pcl::PointCloud<pcl::Normal>::Ptr normals (new  pcl::PointCloud<pcl::Normal>);
+    typename pcl::PointCloud<pcl::Normal>::Ptr normals(
+        new pcl::PointCloud<pcl::Normal>);
     pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> normal_estimation;
-    normal_estimation.setSearchMethod (pcl::search::Search<pcl::PointXYZRGB>::Ptr (new pcl::search::KdTree<pcl::PointXYZRGB>));
-    normal_estimation.setRadiusSearch (0.01);
-    normal_estimation.setInputCloud (input);
-    normal_estimation.compute (*normals);
+    normal_estimation.setSearchMethod(pcl::search::Search<pcl::PointXYZRGB>::Ptr(
+        new pcl::search::KdTree<pcl::PointXYZRGB>));
+    normal_estimation.setRadiusSearch(0.01);
+    normal_estimation.setInputCloud(input);
+    normal_estimation.compute(*normals);
     feature_from_normals->setInputNormals(normals);
     std::cout << "OK" << std::endl;
   }
 
   std::cout << "descriptor extraction..." << std::flush;
-  feature_extractor_->compute (*features);
+  feature_extractor_->compute(*features);
   std::cout << "OK" << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::findCorrespondences (typename pcl::PointCloud<FeatureType>::Ptr source, typename pcl::PointCloud<FeatureType>::Ptr target, std::vector<int>& correspondences) const
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::findCorrespondences(
+    typename pcl::PointCloud<FeatureType>::Ptr source,
+    typename pcl::PointCloud<FeatureType>::Ptr target,
+    std::vector<int>& correspondences) const
 {
   std::cout << "correspondence assignment..." << std::flush;
-  correspondences.resize (source->size());
+  correspondences.resize(source->size());
 
   // Use a KdTree to search for the nearest matches in feature space
   pcl::KdTreeFLANN<FeatureType> descriptor_kdtree;
-  descriptor_kdtree.setInputCloud (target);
+  descriptor_kdtree.setInputCloud(target);
 
-  // Find the index of the best match for each keypoint, and store it in "correspondences_out"
+  // Find the index of the best match for each keypoint, and store it in
+  // "correspondences_out"
   const int k = 1;
-  std::vector<int> k_indices (k);
-  std::vector<float> k_squared_distances (k);
-  for (int i = 0; i < static_cast<int> (source->size ()); ++i)
-  {
-    descriptor_kdtree.nearestKSearch (*source, i, k, k_indices, k_squared_distances);
+  std::vector<int> k_indices(k);
+  std::vector<float> k_squared_distances(k);
+  for (int i = 0; i < static_cast<int>(source->size()); ++i) {
+    descriptor_kdtree.nearestKSearch(*source, i, k, k_indices, k_squared_distances);
     correspondences[i] = k_indices[0];
   }
   std::cout << "OK" << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::filterCorrespondences ()
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::filterCorrespondences()
 {
   std::cout << "correspondence rejection..." << std::flush;
-  std::vector<std::pair<unsigned, unsigned> > correspondences;
-  for (std::size_t cIdx = 0; cIdx < source2target_.size (); ++cIdx)
-    if (target2source_[source2target_[cIdx]] == static_cast<int> (cIdx))
+  std::vector<std::pair<unsigned, unsigned>> correspondences;
+  for (std::size_t cIdx = 0; cIdx < source2target_.size(); ++cIdx)
+    if (target2source_[source2target_[cIdx]] == static_cast<int>(cIdx))
       correspondences.push_back(std::make_pair(cIdx, source2target_[cIdx]));
 
-  correspondences_->resize (correspondences.size());
-  for (std::size_t cIdx = 0; cIdx < correspondences.size(); ++cIdx)
-  {
+  correspondences_->resize(correspondences.size());
+  for (std::size_t cIdx = 0; cIdx < correspondences.size(); ++cIdx) {
     (*correspondences_)[cIdx].index_query = correspondences[cIdx].first;
     (*correspondences_)[cIdx].index_match = correspondences[cIdx].second;
   }
 
   pcl::registration::CorrespondenceRejectorSampleConsensus<pcl::PointXYZI> rejector;
-  rejector.setInputSource (source_keypoints_);
-  rejector.setInputTarget (target_keypoints_);
+  rejector.setInputSource(source_keypoints_);
+  rejector.setInputTarget(target_keypoints_);
   rejector.setInputCorrespondences(correspondences_);
   rejector.getCorrespondences(*correspondences_);
   std::cout << "OK" << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::determineInitialTransformation ()
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::determineInitialTransformation()
 {
   std::cout << "initial alignment..." << std::flush;
-  pcl::registration::TransformationEstimation<pcl::PointXYZI, pcl::PointXYZI>::Ptr transformation_estimation (new pcl::registration::TransformationEstimationSVD<pcl::PointXYZI, pcl::PointXYZI>);
-
-  transformation_estimation->estimateRigidTransformation (*source_keypoints_, *target_keypoints_, *correspondences_, initial_transformation_matrix_);
-
-  pcl::transformPointCloud(*source_segmented_, *source_transformed_, initial_transformation_matrix_);
+  pcl::registration::TransformationEstimation<pcl::PointXYZI, pcl::PointXYZI>::Ptr
+      transformation_estimation(
+          new pcl::registration::TransformationEstimationSVD<pcl::PointXYZI,
+                                                             pcl::PointXYZI>);
+
+  transformation_estimation->estimateRigidTransformation(
+      *source_keypoints_,
+      *target_keypoints_,
+      *correspondences_,
+      initial_transformation_matrix_);
+
+  pcl::transformPointCloud(
+      *source_segmented_, *source_transformed_, initial_transformation_matrix_);
   std::cout << "OK" << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::determineFinalTransformation ()
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::determineFinalTransformation()
 {
   std::cout << "final registration..." << std::flush;
-  pcl::Registration<pcl::PointXYZRGB, pcl::PointXYZRGB>::Ptr registration (new pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB>);
-  registration->setInputSource (source_transformed_);
-  //registration->setInputSource (source_segmented_);
-  registration->setInputTarget (target_segmented_);
+  pcl::Registration<pcl::PointXYZRGB, pcl::PointXYZRGB>::Ptr registration(
+      new pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB>);
+  registration->setInputSource(source_transformed_);
+  // registration->setInputSource (source_segmented_);
+  registration->setInputTarget(target_segmented_);
   registration->setMaxCorrespondenceDistance(0.05);
-  registration->setRANSACOutlierRejectionThreshold (0.05);
-  registration->setTransformationEpsilon (0.000001);
-  registration->setMaximumIterations (1000);
+  registration->setRANSACOutlierRejectionThreshold(0.05);
+  registration->setTransformationEpsilon(0.000001);
+  registration->setMaximumIterations(1000);
   registration->align(*source_registered_);
   transformation_matrix_ = registration->getFinalTransformation();
   std::cout << "OK" << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::reconstructSurface ()
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::reconstructSurface()
 {
   std::cout << "surface reconstruction..." << std::flush;
   // merge the transformed and the target point cloud
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr merged (new pcl::PointCloud<pcl::PointXYZRGB>);
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr merged(new pcl::PointCloud<pcl::PointXYZRGB>);
   *merged = *source_registered_;
   *merged += *target_segmented_;
 
-  // apply grid filtering to reduce amount of points as well as to make them uniform distributed
+  // apply grid filtering to reduce amount of points as well as to make them uniform
+  // distributed
   pcl::VoxelGrid<pcl::PointXYZRGB> voxel_grid;
   voxel_grid.setInputCloud(merged);
-  voxel_grid.setLeafSize (0.002f, 0.002f, 0.002f);
+  voxel_grid.setLeafSize(0.002f, 0.002f, 0.002f);
   voxel_grid.setDownsampleAllData(true);
   voxel_grid.filter(*merged);
 
-  pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr vertices (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
+  pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr vertices(
+      new pcl::PointCloud<pcl::PointXYZRGBNormal>);
   pcl::copyPointCloud(*merged, *vertices);
 
   pcl::NormalEstimation<pcl::PointXYZRGB, pcl::PointXYZRGBNormal> normal_estimation;
-  normal_estimation.setSearchMethod (pcl::search::Search<pcl::PointXYZRGB>::Ptr (new pcl::search::KdTree<pcl::PointXYZRGB>));
-  normal_estimation.setRadiusSearch (0.01);
-  normal_estimation.setInputCloud (merged);
-  normal_estimation.compute (*vertices);
+  normal_estimation.setSearchMethod(pcl::search::Search<pcl::PointXYZRGB>::Ptr(
+      new pcl::search::KdTree<pcl::PointXYZRGB>));
+  normal_estimation.setRadiusSearch(0.01);
+  normal_estimation.setInputCloud(merged);
+  normal_estimation.compute(*vertices);
 
-  pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGBNormal>);
-  tree->setInputCloud (vertices);
+  pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr tree(
+      new pcl::search::KdTree<pcl::PointXYZRGBNormal>);
+  tree->setInputCloud(vertices);
 
   surface_reconstructor_->setSearchMethod(tree);
   surface_reconstructor_->setInputCloud(vertices);
@@ -378,279 +439,291 @@ void ICCVTutorial<FeatureType>::reconstructSurface ()
   std::cout << "OK" << std::endl;
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::run()
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::run()
 {
-  visualizer_.spin ();
+  visualizer_.spin();
 }
 
-template<typename FeatureType>
-void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
+template <typename FeatureType>
+void
+ICCVTutorial<FeatureType>::keyboard_callback(
+    const pcl::visualization::KeyboardEvent& event, void*)
 {
-  if (event.keyUp())
-  {
-    switch (event.getKeyCode())
-    {
-      case '1':
-        if (!visualizer_.removePointCloud("source_points"))
-        {
-          visualizer_.addPointCloud(source_, "source_points");
-        }
-        break;
-
-      case '2':
-        if (!visualizer_.removePointCloud("target_points"))
-        {
-          visualizer_.addPointCloud(target_, "target_points");
-        }
-        break;
-
-      case '3':
-        if (!visualizer_.removePointCloud("source_segmented"))
-        {
-          visualizer_.addPointCloud(source_segmented_, "source_segmented");
-        }
-        break;
-
-      case '4':
-        if (!visualizer_.removePointCloud("target_segmented"))
-        {
-          visualizer_.addPointCloud(target_segmented_, "target_segmented");
-        }
-        break;
-
-      case '5':
-        if (!visualizer_.removePointCloud("source_keypoints"))
-        {
-          pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> keypoint_color (source_keypoints_, 0, 0, 255);
-          //pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI> keypoint_color (source_keypoints_, "intensity");
-          visualizer_.addPointCloud(source_keypoints_, keypoint_color, "source_keypoints");
-        }
-        break;
-
-      case '6':
-        if (!visualizer_.removePointCloud("target_keypoints"))
-        {
-          //pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI> keypoint_color (target_keypoints_, "intensity");
-          pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> keypoint_color (target_keypoints_, 255, 0, 0);
-          visualizer_.addPointCloud(target_keypoints_, keypoint_color, "target_keypoints");
-        }
-        break;
-
-      case '7':
-        if (!show_source2target_)
-          visualizer_.addCorrespondences<pcl::PointXYZI>(source_keypoints_, target_keypoints_, source2target_, "source2target");
-        else
-          visualizer_.removeCorrespondences("source2target");
-
-        show_source2target_ = !show_source2target_;
-        break;
-
-      case '8':
-        if (!show_target2source_)
-          visualizer_.addCorrespondences<pcl::PointXYZI>(target_keypoints_, source_keypoints_, target2source_, "target2source");
-        else
-          visualizer_.removeCorrespondences("target2source");
-
-        show_target2source_ = !show_target2source_;
-        break;
-
-      case '9':
-        if (!show_correspondences)
-          visualizer_.addCorrespondences<pcl::PointXYZI>(source_keypoints_, target_keypoints_, *correspondences_, "correspondences");
-        else
-          visualizer_.removeCorrespondences("correspondences");
-        show_correspondences = !show_correspondences;
-        break;
-
-      case 'i':
-      case 'I':
-        if (!visualizer_.removePointCloud("transformed"))
-          visualizer_.addPointCloud(source_transformed_, "transformed");
-        break;
-
-      case 'r':
-      case 'R':
-        if (!visualizer_.removePointCloud("registered"))
-          visualizer_.addPointCloud(source_registered_, "registered");
-        break;
-
-      case 't':
-      case 'T':
-          visualizer_.addPolygonMesh(surface_, "surface");
-        break;
+  if (event.keyUp()) {
+    switch (event.getKeyCode()) {
+    case '1':
+      if (!visualizer_.removePointCloud("source_points")) {
+        visualizer_.addPointCloud(source_, "source_points");
+      }
+      break;
+
+    case '2':
+      if (!visualizer_.removePointCloud("target_points")) {
+        visualizer_.addPointCloud(target_, "target_points");
+      }
+      break;
+
+    case '3':
+      if (!visualizer_.removePointCloud("source_segmented")) {
+        visualizer_.addPointCloud(source_segmented_, "source_segmented");
+      }
+      break;
+
+    case '4':
+      if (!visualizer_.removePointCloud("target_segmented")) {
+        visualizer_.addPointCloud(target_segmented_, "target_segmented");
+      }
+      break;
+
+    case '5':
+      if (!visualizer_.removePointCloud("source_keypoints")) {
+        pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> keypoint_color(
+            source_keypoints_, 0, 0, 255);
+        visualizer_.addPointCloud(
+            source_keypoints_, keypoint_color, "source_keypoints");
+      }
+      break;
+
+    case '6':
+      if (!visualizer_.removePointCloud("target_keypoints")) {
+        pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> keypoint_color(
+            target_keypoints_, 255, 0, 0);
+        visualizer_.addPointCloud(
+            target_keypoints_, keypoint_color, "target_keypoints");
+      }
+      break;
+
+    case '7':
+      if (!show_source2target_)
+        visualizer_.addCorrespondences<pcl::PointXYZI>(
+            source_keypoints_, target_keypoints_, source2target_, "source2target");
+      else
+        visualizer_.removeCorrespondences("source2target");
+
+      show_source2target_ = !show_source2target_;
+      break;
+
+    case '8':
+      if (!show_target2source_)
+        visualizer_.addCorrespondences<pcl::PointXYZI>(
+            target_keypoints_, source_keypoints_, target2source_, "target2source");
+      else
+        visualizer_.removeCorrespondences("target2source");
+
+      show_target2source_ = !show_target2source_;
+      break;
+
+    case '9':
+      if (!show_correspondences)
+        visualizer_.addCorrespondences<pcl::PointXYZI>(
+            source_keypoints_, target_keypoints_, *correspondences_, "correspondences");
+      else
+        visualizer_.removeCorrespondences("correspondences");
+      show_correspondences = !show_correspondences;
+      break;
+
+    case 'i':
+    case 'I':
+      if (!visualizer_.removePointCloud("transformed"))
+        visualizer_.addPointCloud(source_transformed_, "transformed");
+      break;
+
+    case 'r':
+    case 'R':
+      if (!visualizer_.removePointCloud("registered"))
+        visualizer_.addPointCloud(source_registered_, "registered");
+      break;
+
+    case 't':
+    case 'T':
+      visualizer_.addPolygonMesh(surface_, "surface");
+      break;
     }
   }
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
-  if (argc < 6)
-  {
+  if (argc < 6) {
+    // clang-format off
     pcl::console::print_info ("Syntax is: %s <source-pcd-file> <target-pcd-file> <keypoint-method> <descriptor-type> <surface-reconstruction-method>\n", argv[0]);
-    pcl::console::print_info ("available <keypoint-methods>: 1 = Sift3D\n");
-    pcl::console::print_info ("                              2 = Harris3D\n");
-    pcl::console::print_info ("                              3 = Tomasi3D\n");
-    pcl::console::print_info ("                              4 = Noble3D\n");
-    pcl::console::print_info ("                              5 = Lowe3D\n");
-    pcl::console::print_info ("                              6 = Curvature3D\n\n");
-    pcl::console::print_info ("available <descriptor-types>: 1 = FPFH\n");
-    pcl::console::print_info ("                              2 = SHOTRGB\n");
-    pcl::console::print_info ("                              3 = PFH\n");
-    pcl::console::print_info ("                              4 = PFHRGB\n\n");
-    pcl::console::print_info ("available <surface-methods>:  1 = Greedy Projection\n");
-    pcl::console::print_info ("                              2 = Marching Cubes\n");
-
-    return (1);
+    pcl::console::print_info("available <keypoint-methods>: 1 = Sift3D\n");
+    pcl::console::print_info("                              2 = Harris3D\n");
+    pcl::console::print_info("                              3 = Tomasi3D\n");
+    pcl::console::print_info("                              4 = Noble3D\n");
+    pcl::console::print_info("                              5 = Lowe3D\n");
+    pcl::console::print_info("                              6 = Curvature3D\n\n");
+    pcl::console::print_info("available <descriptor-types>: 1 = FPFH\n");
+    pcl::console::print_info("                              2 = SHOTRGB\n");
+    pcl::console::print_info("                              3 = PFH\n");
+    pcl::console::print_info("                              4 = PFHRGB\n\n");
+    pcl::console::print_info("available <surface-methods>:  1 = Greedy Projection\n");
+    pcl::console::print_info("                              2 = Marching Cubes\n");
+    // clang-format on
+
+    return 1;
   }
-  pcl::console::print_info ("== MENU ==\n");
-  pcl::console::print_info ("1 - show/hide source point cloud\n");
-  pcl::console::print_info ("2 - show/hide target point cloud\n");
-  pcl::console::print_info ("3 - show/hide segmented source point cloud\n");
-  pcl::console::print_info ("4 - show/hide segmented target point cloud\n");
-  pcl::console::print_info ("5 - show/hide source key points\n");
-  pcl::console::print_info ("6 - show/hide target key points\n");
-  pcl::console::print_info ("7 - show/hide source2target correspondences\n");
-  pcl::console::print_info ("8 - show/hide target2source correspondences\n");
-  pcl::console::print_info ("9 - show/hide consistent correspondences\n");
-  pcl::console::print_info ("i - show/hide initial alignment\n");
-  pcl::console::print_info ("r - show/hide final registration\n");
-  pcl::console::print_info ("t - show/hide triangulation (surface reconstruction)\n");
-  pcl::console::print_info ("h - show visualizer options\n");
-  pcl::console::print_info ("q - quit\n");
-
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr source (new pcl::PointCloud<pcl::PointXYZRGB>);
-  pcl::io::loadPCDFile (argv[1], *source);
-
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr target (new pcl::PointCloud<pcl::PointXYZRGB>);
-  pcl::io::loadPCDFile (argv[2], *target);
-
-  int keypoint_type   = atoi (argv[3]);
-  int descriptor_type = atoi (argv[4]);
-  int surface_type    = atoi (argv[5]);
+  pcl::console::print_info("== MENU ==\n");
+  pcl::console::print_info("1 - show/hide source point cloud\n");
+  pcl::console::print_info("2 - show/hide target point cloud\n");
+  pcl::console::print_info("3 - show/hide segmented source point cloud\n");
+  pcl::console::print_info("4 - show/hide segmented target point cloud\n");
+  pcl::console::print_info("5 - show/hide source key points\n");
+  pcl::console::print_info("6 - show/hide target key points\n");
+  pcl::console::print_info("7 - show/hide source2target correspondences\n");
+  pcl::console::print_info("8 - show/hide target2source correspondences\n");
+  pcl::console::print_info("9 - show/hide consistent correspondences\n");
+  pcl::console::print_info("i - show/hide initial alignment\n");
+  pcl::console::print_info("r - show/hide final registration\n");
+  pcl::console::print_info("t - show/hide triangulation (surface reconstruction)\n");
+  pcl::console::print_info("h - show visualizer options\n");
+  pcl::console::print_info("q - quit\n");
+
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr source(new pcl::PointCloud<pcl::PointXYZRGB>);
+  pcl::io::loadPCDFile(argv[1], *source);
+
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr target(new pcl::PointCloud<pcl::PointXYZRGB>);
+  pcl::io::loadPCDFile(argv[2], *target);
+
+  int keypoint_type = atoi(argv[3]);
+  int descriptor_type = atoi(argv[4]);
+  int surface_type = atoi(argv[5]);
 
   pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector;
 
-  if (keypoint_type == 1)
-  {
-    pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI>* sift3D = new pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI>;
-    sift3D->setScales (0.01f, 3, 2);
-    sift3D->setMinimumContrast (0.0);
-    keypoint_detector.reset (sift3D);
+  if (keypoint_type == 1) {
+    pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI>* sift3D =
+        new pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI>;
+    sift3D->setScales(0.01f, 3, 2);
+    sift3D->setMinimumContrast(0.0);
+    keypoint_detector.reset(sift3D);
   }
-  else
-  {
-    pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>* harris3D = new pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI> (pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::HARRIS);
-    harris3D->setNonMaxSupression (true);
-    harris3D->setRadius (0.01f);
-    harris3D->setRadiusSearch (0.01f);
-    keypoint_detector.reset (harris3D);
-    switch (keypoint_type)
-    {
-      case 2:
-        harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::HARRIS);
+  else {
+    pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>* harris3D =
+        new pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>(
+            pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>::HARRIS);
+    harris3D->setNonMaxSupression(true);
+    harris3D->setRadius(0.01f);
+    harris3D->setRadiusSearch(0.01f);
+    keypoint_detector.reset(harris3D);
+    switch (keypoint_type) {
+    case 2:
+      harris3D->setMethod(
+          pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>::HARRIS);
       break;
 
-      case 3:
-        harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::TOMASI);
+    case 3:
+      harris3D->setMethod(
+          pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>::TOMASI);
       break;
 
-      case 4:
-        harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::NOBLE);
+    case 4:
+      harris3D->setMethod(
+          pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>::NOBLE);
       break;
 
-      case 5:
-        harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::LOWE);
+    case 5:
+      harris3D->setMethod(
+          pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>::LOWE);
       break;
 
-      case 6:
-        harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::CURVATURE);
+    case 6:
+      harris3D->setMethod(
+          pcl::HarrisKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZI>::CURVATURE);
+      break;
+    default:
+      pcl::console::print_error(
+          "unknown key point detection method %d\n expecting values between 1 and 6",
+          keypoint_type);
+      exit(1);
       break;
-      default:
-        pcl::console::print_error("unknown key point detection method %d\n expecting values between 1 and 6", keypoint_type);
-        exit (1);
-        break;
     }
-
   }
 
   pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstruction;
 
-  if (surface_type == 1)
-  {
-    pcl::GreedyProjectionTriangulation<pcl::PointXYZRGBNormal>* gp3 = new pcl::GreedyProjectionTriangulation<pcl::PointXYZRGBNormal>;
+  if (surface_type == 1) {
+    pcl::GreedyProjectionTriangulation<pcl::PointXYZRGBNormal>* gp3 =
+        new pcl::GreedyProjectionTriangulation<pcl::PointXYZRGBNormal>;
 
     // Set the maximum distance between connected points (maximum edge length)
-    gp3->setSearchRadius (0.025);
+    gp3->setSearchRadius(0.025);
 
     // Set typical values for the parameters
-    gp3->setMu (2.5);
-    gp3->setMaximumNearestNeighbors (100);
-    gp3->setMaximumSurfaceAngle(M_PI/4); // 45 degrees
-    gp3->setMinimumAngle(M_PI/18); // 10 degrees
-    gp3->setMaximumAngle(2*M_PI/3); // 120 degrees
+    gp3->setMu(2.5);
+    gp3->setMaximumNearestNeighbors(100);
+    gp3->setMaximumSurfaceAngle(M_PI / 4); // 45 degrees
+    gp3->setMinimumAngle(M_PI / 18);       // 10 degrees
+    gp3->setMaximumAngle(2 * M_PI / 3);    // 120 degrees
     gp3->setNormalConsistency(false);
     surface_reconstruction.reset(gp3);
   }
-  else if (surface_type == 2)
-  {
-    pcl::MarchingCubes<pcl::PointXYZRGBNormal>* mc = new pcl::MarchingCubesHoppe<pcl::PointXYZRGBNormal>;
-    mc->setIsoLevel (0.001f);
-    mc->setGridResolution (50, 50, 50);
+  else if (surface_type == 2) {
+    pcl::MarchingCubes<pcl::PointXYZRGBNormal>* mc =
+        new pcl::MarchingCubesHoppe<pcl::PointXYZRGBNormal>;
+    mc->setIsoLevel(0.001f);
+    mc->setGridResolution(50, 50, 50);
     surface_reconstruction.reset(mc);
   }
-  else
-  {
-    pcl::console::print_error("unknown surface reconstruction method %d\n expecting values between 1 and 2", surface_type);
-    exit (1);
+  else {
+    pcl::console::print_error(
+        "unknown surface reconstruction method %d\n expecting values between 1 and 2",
+        surface_type);
+    exit(1);
   }
 
-  switch (descriptor_type)
-  {
-    case 1:
-    {
-      pcl::Feature<pcl::PointXYZRGB, pcl::FPFHSignature33>::Ptr feature_extractor (new pcl::FPFHEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::FPFHSignature33>);
-      feature_extractor->setSearchMethod (pcl::search::Search<pcl::PointXYZRGB>::Ptr (new pcl::search::KdTree<pcl::PointXYZRGB>));
-      feature_extractor->setRadiusSearch (0.05);
-      ICCVTutorial<pcl::FPFHSignature33> tutorial (keypoint_detector, feature_extractor, surface_reconstruction, source, target);
-      tutorial.run ();
-    }
-    break;
-
-    case 2:
-    {
-      pcl::SHOTColorEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::SHOT1344>* shot = new pcl::SHOTColorEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::SHOT1344>;
-      shot->setRadiusSearch (0.04);
-      pcl::Feature<pcl::PointXYZRGB, pcl::SHOT1344>::Ptr feature_extractor (shot);
-      ICCVTutorial<pcl::SHOT1344> tutorial (keypoint_detector, feature_extractor, surface_reconstruction, source, target);
-      tutorial.run ();
-    }
-    break;
-
-    case 3:
-    {
-      pcl::Feature<pcl::PointXYZRGB, pcl::PFHSignature125>::Ptr feature_extractor (new pcl::PFHEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHSignature125>);
-      feature_extractor->setKSearch(50);
-      ICCVTutorial<pcl::PFHSignature125> tutorial (keypoint_detector, feature_extractor, surface_reconstruction, source, target);
-      tutorial.run ();
-    }
-    break;
-
-    case 4:
-    {
-      pcl::Feature<pcl::PointXYZRGB, pcl::PFHRGBSignature250>::Ptr feature_extractor (new pcl::PFHRGBEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHRGBSignature250>);
-      feature_extractor->setKSearch(50);
-      ICCVTutorial<pcl::PFHRGBSignature250> tutorial (keypoint_detector, feature_extractor, surface_reconstruction, source, target);
-      tutorial.run ();
-    }
+  switch (descriptor_type) {
+  case 1: {
+    pcl::Feature<pcl::PointXYZRGB, pcl::FPFHSignature33>::Ptr feature_extractor(
+        new pcl::
+            FPFHEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::FPFHSignature33>);
+    feature_extractor->setSearchMethod(pcl::search::Search<pcl::PointXYZRGB>::Ptr(
+        new pcl::search::KdTree<pcl::PointXYZRGB>));
+    feature_extractor->setRadiusSearch(0.05);
+    ICCVTutorial<pcl::FPFHSignature33> tutorial(
+        keypoint_detector, feature_extractor, surface_reconstruction, source, target);
+    tutorial.run();
+  } break;
+
+  case 2: {
+    pcl::SHOTColorEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::SHOT1344>* shot =
+        new pcl::SHOTColorEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::SHOT1344>;
+    shot->setRadiusSearch(0.04);
+    pcl::Feature<pcl::PointXYZRGB, pcl::SHOT1344>::Ptr feature_extractor(shot);
+    ICCVTutorial<pcl::SHOT1344> tutorial(
+        keypoint_detector, feature_extractor, surface_reconstruction, source, target);
+    tutorial.run();
+  } break;
+
+  case 3: {
+    pcl::Feature<pcl::PointXYZRGB, pcl::PFHSignature125>::Ptr feature_extractor(
+        new pcl::PFHEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHSignature125>);
+    feature_extractor->setKSearch(50);
+    ICCVTutorial<pcl::PFHSignature125> tutorial(
+        keypoint_detector, feature_extractor, surface_reconstruction, source, target);
+    tutorial.run();
+  } break;
+
+  case 4: {
+    pcl::Feature<pcl::PointXYZRGB, pcl::PFHRGBSignature250>::Ptr feature_extractor(
+        new pcl::
+            PFHRGBEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHRGBSignature250>);
+    feature_extractor->setKSearch(50);
+    ICCVTutorial<pcl::PFHRGBSignature250> tutorial(
+        keypoint_detector, feature_extractor, surface_reconstruction, source, target);
+    tutorial.run();
+  } break;
+
+  default:
+    pcl::console::print_error(
+        "unknown descriptor type %d\n expecting values between 1 and 4",
+        descriptor_type);
+    exit(1);
     break;
-
-    default:
-      pcl::console::print_error("unknown descriptor type %d\n expecting values between 1 and 4", descriptor_type);
-      exit (1);
-      break;
   }
 
-  return (0);
+  return 0;
 }
index 9db1fabe9647dee36fbde06aff46f89f2a97b033..67b9e3b59f9d2d7436b23199e51143fdaf452e99 100644 (file)
@@ -1,24 +1,23 @@
-#include <pcl/point_cloud.h>
-#include <pcl/segmentation/grabcut_segmentation.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/console/print.h>
 #include <pcl/console/parse.h>
-#include <pcl/point_types.h>
+#include <pcl/console/print.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/segmentation/grabcut_segmentation.h>
 #include <pcl/PCLPointCloud2.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #ifdef GLUT_IS_A_FRAMEWORK
 #include <GLUT/glut.h>
 #else
 #include <GL/glut.h>
-#if defined (FREEGLUT)
+#if defined(FREEGLUT)
 #include <GL/freeglut_ext.h>
-#elif defined (GLUI_OPENGLUT)
+#elif defined(GLUI_OPENGLUT)
 #include <GL/openglut.h>
 #endif
 #endif
 
-class GrabCutHelper : public pcl::GrabCut<pcl::PointXYZRGB>
-{
+class GrabCutHelper : public pcl::GrabCut<pcl::PointXYZRGB> {
   using pcl::GrabCut<pcl::PointXYZRGB>::n_links_;
   using pcl::GrabCut<pcl::PointXYZRGB>::graph_;
   using pcl::GrabCut<pcl::PointXYZRGB>::indices_;
@@ -31,39 +30,39 @@ class GrabCutHelper : public pcl::GrabCut<pcl::PointXYZRGB>
   using pcl::GrabCut<pcl::PointXYZRGB>::GMM_component_;
   using pcl::GrabCut<pcl::PointXYZRGB>::input_;
 
-  public:
+public:
   using Ptr = std::shared_ptr<GrabCutHelper>;
   using ConstPtr = std::shared_ptr<const GrabCutHelper>;
 
-  GrabCutHelper (std::uint32_t K = 5, float lambda = 50.f)
-    : pcl::GrabCut<pcl::PointXYZRGB> (K, lambda)
+  GrabCutHelper(std::uint32_t K = 5, float lambda = 50.f)
+  : pcl::GrabCut<pcl::PointXYZRGB>(K, lambda)
   {}
 
-  ~GrabCutHelper ()
-  {  }
+  ~GrabCutHelper() {}
 
   void
-  setInputCloud (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud) override;
+  setInputCloud(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud) override;
   void
-  setBackgroundPointsIndices (const pcl::PointIndices::ConstPtr& point_indices);
+  setBackgroundPointsIndices(const pcl::PointIndices::ConstPtr& point_indices);
   void
-  setBackgroundPointsIndices (int x1, int y1, int x2, int y2);
+  setBackgroundPointsIndices(int x1, int y1, int x2, int y2);
   void
-  setTrimap(int x1, int y1, int x2, int y2, const pcl::segmentation::grabcut::TrimapValue& t);
+  setTrimap(
+      int x1, int y1, int x2, int y2, const pcl::segmentation::grabcut::TrimapValue& t);
   void
-  refine () override;
+  refine() override;
   int
-  refineOnce () override;
+  refineOnce() override;
   void
-  fitGMMs () override;
+  fitGMMs() override;
   void
-  display (int display_type);
+  display(int display_type);
   void
-  overlayAlpha ();
+  overlayAlpha();
 
-  private:
+private:
   void
-  buildImages ();
+  buildImages();
 
   // Clouds of various variables that can be displayed for debugging.
   pcl::PointCloud<float>::Ptr n_links_image_;
@@ -77,50 +76,64 @@ class GrabCutHelper : public pcl::GrabCut<pcl::PointXYZRGB>
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::setInputCloud (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud)
+GrabCutHelper::setInputCloud(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud)
 {
-  pcl::GrabCut<pcl::PointXYZRGB>::setInputCloud (cloud);
+  pcl::GrabCut<pcl::PointXYZRGB>::setInputCloud(cloud);
   // Reset clouds
-  n_links_image_.reset (new pcl::PointCloud<float> (cloud->width, cloud->height, 0));
-  t_links_image_.reset (new pcl::segmentation::grabcut::Image (cloud->width, cloud->height));
-  gmm_image_.reset (new pcl::segmentation::grabcut::Image (cloud->width, cloud->height));
-  alpha_image_.reset (new pcl::PointCloud<float> (cloud->width, cloud->height, 0));
-  image_height_1_ = cloud->height-1;
-  image_width_1_ = cloud->width-1;
+  n_links_image_.reset(new pcl::PointCloud<float>(cloud->width, cloud->height, 0));
+  t_links_image_.reset(
+      new pcl::segmentation::grabcut::Image(cloud->width, cloud->height));
+  gmm_image_.reset(new pcl::segmentation::grabcut::Image(cloud->width, cloud->height));
+  alpha_image_.reset(new pcl::PointCloud<float>(cloud->width, cloud->height, 0));
+  image_height_1_ = cloud->height - 1;
+  image_width_1_ = cloud->width - 1;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::setBackgroundPointsIndices (const pcl::PointIndices::ConstPtr& point_indices)
+GrabCutHelper::setBackgroundPointsIndices(
+    const pcl::PointIndices::ConstPtr& point_indices)
 {
-  pcl::GrabCut<pcl::PointXYZRGB>::setBackgroundPointsIndices (point_indices);
-  buildImages ();
+  pcl::GrabCut<pcl::PointXYZRGB>::setBackgroundPointsIndices(point_indices);
+  buildImages();
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::setBackgroundPointsIndices (int x1, int y1, int x2, int y2)
+GrabCutHelper::setBackgroundPointsIndices(int x1, int y1, int x2, int y2)
 {
-  pcl::PointIndices::Ptr point_indices (new pcl::PointIndices);
-  point_indices->indices.reserve (input_->size ());
-  if (x1 > x2) std::swap (x1, x2);
-  if (y1 > y2) std::swap (y1, y2);
-  for (int y = std::max (y1, 0); y <= std::min (static_cast<int> (input_->height -1), y2); ++y)
-    for (int x = std::max (x1, 0); x <= std::min (static_cast<int> (input_->width -1), x2); ++x)
-      point_indices->indices.push_back (y * input_->width + x);
-  setBackgroundPointsIndices (point_indices);
+  pcl::PointIndices::Ptr point_indices(new pcl::PointIndices);
+  point_indices->indices.reserve(input_->size());
+  if (x1 > x2)
+    std::swap(x1, x2);
+  if (y1 > y2)
+    std::swap(y1, y2);
+  x1 = std::max(x1, 0);
+  y1 = std::max(y1, 0);
+  x2 = std::min(static_cast<int>(input_->width - 1), x2);
+  y2 = std::min(static_cast<int>(input_->height - 1), y2);
+  for (int y = y1; y <= y2; ++y)
+    for (int x = x1; x <= x2; ++x)
+      point_indices->indices.push_back(y * input_->width + x);
+  setBackgroundPointsIndices(point_indices);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::setTrimap(int x1, int y1, int x2, int y2, const pcl::segmentation::grabcut::TrimapValue& t)
+GrabCutHelper::setTrimap(
+    int x1, int y1, int x2, int y2, const pcl::segmentation::grabcut::TrimapValue& t)
 {
   using namespace pcl::segmentation::grabcut;
-  if (x1 > x2) std::swap (x1, x2);
-  if (y1 > y2) std::swap (y1, y2);
-  for (int y = std::max (y1, 0); y <= std::min (static_cast<int> (image_height_1_), y2); ++y)
-    for (int x = std::max (x1, 0); x <= std::min (static_cast<int> (image_width_1_), x2); ++x)
-    {
+  if (x1 > x2)
+    std::swap(x1, x2);
+  if (y1 > y2)
+    std::swap(y1, y2);
+  x1 = std::max(x1, 0);
+  y1 = std::max(y1, 0);
+  x2 = std::min(static_cast<int>(image_height_1_), x2);
+  y2 = std::min(static_cast<int>(image_width_1_), y2);
+  for (int y = y1; y <= y2; ++y)
+    for (int x = x1; x <= x2; ++x) {
       std::size_t idx = y * input_->width + x;
       trimap_[idx] = TrimapUnknown;
       // Immediately set the segmentation as well so that the display will update.
@@ -136,84 +149,77 @@ GrabCutHelper::setTrimap(int x1, int y1, int x2, int y2, const pcl::segmentation
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::refine ()
+GrabCutHelper::refine()
 {
-  pcl::GrabCut<pcl::PointXYZRGB>::refine ();
-  buildImages ();
+  pcl::GrabCut<pcl::PointXYZRGB>::refine();
+  buildImages();
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 int
-GrabCutHelper::refineOnce ()
+GrabCutHelper::refineOnce()
 {
-  int result = pcl::GrabCut<pcl::PointXYZRGB>::refineOnce ();
-  buildImages ();
-  return (result);
+  int result = pcl::GrabCut<pcl::PointXYZRGB>::refineOnce();
+  buildImages();
+  return result;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::fitGMMs ()
+GrabCutHelper::fitGMMs()
 {
-  pcl::GrabCut<pcl::PointXYZRGB>::fitGMMs ();
-  buildImages ();
+  pcl::GrabCut<pcl::PointXYZRGB>::fitGMMs();
+  buildImages();
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::buildImages ()
+GrabCutHelper::buildImages()
 {
   using namespace pcl::segmentation::grabcut;
-  memset (&n_links_image_->points[0], 0, sizeof (float) * n_links_image_->size ());
-  for (int y = 0; y < static_cast<int> (image_->height); ++y)
-       {
-    for (int x = 0; x < static_cast<int> (image_->width); ++x)
-               {
+  memset(&n_links_image_->points[0], 0, sizeof(float) * n_links_image_->size());
+  for (int y = 0; y < static_cast<int>(image_->height); ++y) {
+    for (int x = 0; x < static_cast<int>(image_->width); ++x) {
       std::size_t index = y * image_->width + x;
 
-      if (x > 0 && y < image_height_1_)
-      {
-                               (*n_links_image_)(x,y) += n_links_[index].weights[0];
-                               (*n_links_image_)(x-1,y+1) += n_links_[index].weights[0];
+      if (x > 0 && y < image_height_1_) {
+        (*n_links_image_)(x, y) += n_links_[index].weights[0];
+        (*n_links_image_)(x - 1, y + 1) += n_links_[index].weights[0];
       }
 
-                       if (y < image_height_1_)
-      {
-                               (*n_links_image_)(x,y) += n_links_[index].weights[1];
-                               (*n_links_image_)(x,y+1) += n_links_[index].weights[1];
+      if (y < image_height_1_) {
+        (*n_links_image_)(x, y) += n_links_[index].weights[1];
+        (*n_links_image_)(x, y + 1) += n_links_[index].weights[1];
       }
 
-                       if (x < image_width_1_ && y < image_height_1_)
-      {
-                               (*n_links_image_)(x,y) += n_links_[index].weights[2];
-                               (*n_links_image_)(x+1,y+1) += n_links_[index].weights[2];
+      if (x < image_width_1_ && y < image_height_1_) {
+        (*n_links_image_)(x, y) += n_links_[index].weights[2];
+        (*n_links_image_)(x + 1, y + 1) += n_links_[index].weights[2];
       }
 
-                       if (x < image_width_1_)
-      {
-                               (*n_links_image_)(x,y) += n_links_[index].weights[3];
-                               (*n_links_image_)(x+1,y) += n_links_[index].weights[3];
+      if (x < image_width_1_) {
+        (*n_links_image_)(x, y) += n_links_[index].weights[3];
+        (*n_links_image_)(x + 1, y) += n_links_[index].weights[3];
       }
 
       // TLinks cloud
-      pcl::segmentation::grabcut::Color &tlink_point  = t_links_image_->points[index];
-      pcl::segmentation::grabcut::Color &gmm_point    = gmm_image_->points[index];
-      float &alpha_point = alpha_image_->points[index];
-      double red = pow (graph_.getSourceEdgeCapacity (index)/L_, 0.25); // red
-      double green = pow (graph_.getTargetEdgeCapacity (index)/L_, 0.25); // green
-      tlink_point.r = static_cast<float> (red);
-      tlink_point.g = static_cast<float> (green);
+      pcl::segmentation::grabcut::Color& tlink_point = t_links_image_->points[index];
+      pcl::segmentation::grabcut::Color& gmm_point = gmm_image_->points[index];
+      floatalpha_point = alpha_image_->points[index];
+      double red = pow(graph_.getSourceEdgeCapacity(index) / L_, 0.25);   // red
+      double green = pow(graph_.getTargetEdgeCapacity(index) / L_, 0.25); // green
+      tlink_point.r = static_cast<float>(red);
+      tlink_point.g = static_cast<float>(green);
       gmm_point.b = tlink_point.b = 0;
       // GMM cloud and Alpha cloud
-      if (hard_segmentation_[index] == SegmentationForeground)
-      {
-        //assert (static_cast<float>(GMM_component_[index]+1)/static_cast<float> (K_) < 1.f);
-        gmm_point.r = static_cast<float>(GMM_component_[index]+1)/static_cast<float> (K_);
+      if (hard_segmentation_[index] == SegmentationForeground) {
+        gmm_point.r =
+            static_cast<float>(GMM_component_[index] + 1) / static_cast<float>(K_);
         alpha_point = 0;
       }
-      else
-      {
-        gmm_point.g = static_cast<float>(GMM_component_[index]+1)/static_cast<float> (K_);
+      else {
+        gmm_point.g =
+            static_cast<float>(GMM_component_[index] + 1) / static_cast<float>(K_);
         alpha_point = 0.75;
       }
     }
@@ -222,37 +228,52 @@ GrabCutHelper::buildImages ()
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::display (int display_type)
+GrabCutHelper::display(int display_type)
 {
-  switch (display_type)
-  {
-    case 0:
-      glDrawPixels (image_->width, image_->height, GL_RGB, GL_FLOAT, &(image_->points[0]));
-      break;
-
-    case 1:
-      glDrawPixels (gmm_image_->width, gmm_image_->height, GL_RGB, GL_FLOAT, &(gmm_image_->points[0]));
-      break;
-
-    case 2:
-      glDrawPixels (n_links_image_->width, n_links_image_->height, GL_LUMINANCE, GL_FLOAT, &(n_links_image_->points[0]));
-      break;
-
-    case 3:
-      glDrawPixels (t_links_image_->width, t_links_image_->height, GL_RGB, GL_FLOAT, &(t_links_image_->points[0]));
-      break;
-
-    default:
-      // Do nothing
-      break;
+  switch (display_type) {
+  case 0:
+    glDrawPixels(image_->width, image_->height, GL_RGB, GL_FLOAT, &(image_->points[0]));
+    break;
+
+  case 1:
+    glDrawPixels(gmm_image_->width,
+                 gmm_image_->height,
+                 GL_RGB,
+                 GL_FLOAT,
+                 &(gmm_image_->points[0]));
+    break;
+
+  case 2:
+    glDrawPixels(n_links_image_->width,
+                 n_links_image_->height,
+                 GL_LUMINANCE,
+                 GL_FLOAT,
+                 &(n_links_image_->points[0]));
+    break;
+
+  case 3:
+    glDrawPixels(t_links_image_->width,
+                 t_links_image_->height,
+                 GL_RGB,
+                 GL_FLOAT,
+                 &(t_links_image_->points[0]));
+    break;
+
+  default:
+    // Do nothing
+    break;
   }
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-GrabCutHelper::overlayAlpha ()
+GrabCutHelper::overlayAlpha()
 {
-  glDrawPixels (alpha_image_->width, alpha_image_->height, GL_ALPHA, GL_FLOAT, &(alpha_image_->points[0]));
+  glDrawPixels(alpha_image_->width,
+               alpha_image_->height,
+               GL_ALPHA,
+               GL_FLOAT,
+               &(alpha_image_->points[0]));
 }
 
 /* GUI interface */
@@ -270,28 +291,30 @@ pcl::segmentation::grabcut::Image::Ptr display_image;
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void
-display ()
+display()
 {
   glClear(GL_COLOR_BUFFER_BIT);
 
   if (display_type == -1)
-      glDrawPixels (display_image->width, display_image->height, GL_RGB, GL_FLOAT, &(display_image->points[0]));
+    glDrawPixels(display_image->width,
+                 display_image->height,
+                 GL_RGB,
+                 GL_FLOAT,
+                 &(display_image->points[0]));
   else
-    grabcut.display (display_type);
+    grabcut.display(display_type);
 
-  if (show_mask)
-  {
-    grabcut.overlayAlpha ();
+  if (show_mask) {
+    grabcut.overlayAlpha();
   }
 
-  if (box)
-  {
-    glColor4f( 1, 1, 1, 1 );
-    glBegin( GL_LINE_LOOP );
-    glVertex2d( xstart, ystart );
-    glVertex2d( xstart, yend );
-    glVertex2d( xend, yend );
-    glVertex2d( xend, ystart );
+  if (box) {
+    glColor4f(1, 1, 1, 1);
+    glBegin(GL_LINE_LOOP);
+    glVertex2d(xstart, ystart);
+    glVertex2d(xstart, yend);
+    glVertex2d(xend, yend);
+    glVertex2d(xend, ystart);
     glEnd();
   }
 
@@ -301,256 +324,250 @@ display ()
 
 /////////////////////////////////////////////////////////////////////////
 void
-idle_callback ()
+idle_callback()
 {
   int changed = 0;
 
-  if (refining_)
-  {
-    changed = grabcut.refineOnce ();
-    glutPostRedisplay ();
+  if (refining_) {
+    changed = grabcut.refineOnce();
+    glutPostRedisplay();
   }
 
-  if (!changed)
-  {
+  if (!changed) {
     refining_ = false;
-    glutIdleFunc (nullptr);
+    glutIdleFunc(nullptr);
   }
 }
 
 /////////////////////////////////////////////////////////////////////////
 void
-motion_callback (int x, int y)
+motion_callback(int x, int y)
 {
   y = height - y;
 
-  if (box)
-  {
-    xend = x; yend = y;
-    glutPostRedisplay ();
+  if (box) {
+    xend = x;
+    yend = y;
+    glutPostRedisplay();
   }
 
-  if (initialized)
-  {
+  if (initialized) {
     if (left)
-      grabcut.setTrimap (x-2,y-2,x+2,y+2,pcl::segmentation::grabcut::TrimapForeground);
+      grabcut.setTrimap(
+          x - 2, y - 2, x + 2, y + 2, pcl::segmentation::grabcut::TrimapForeground);
 
     if (right)
-      grabcut.setTrimap (x-2,y-2,x+2,y+2,pcl::segmentation::grabcut::TrimapForeground);
+      grabcut.setTrimap(
+          x - 2, y - 2, x + 2, y + 2, pcl::segmentation::grabcut::TrimapForeground);
 
-    glutPostRedisplay ();
+    glutPostRedisplay();
   }
 }
 
 void
-mouse_callback (int button, int state, int x, int y)
+mouse_callback(int button, int state, int x, int y)
 {
   y = height - y;
 
-  switch (button)
-  {
-    case GLUT_LEFT_BUTTON:
-      if (state==GLUT_DOWN)
-      {
-        left = true;
-
-        if (!initialized)
-        {
-          xstart = x; ystart = y;
-          box = true;
-        }
-      }
+  switch (button) {
+  case GLUT_LEFT_BUTTON:
+    if (state == GLUT_DOWN) {
+      left = true;
 
-      if (state==GLUT_UP)
-      {
-        left = false;
-
-        if (initialized)
-        {
-          grabcut.refineOnce ();
-          glutPostRedisplay ();
-        }
-        else
-        {
-          xend = x; yend = y;
-          grabcut.setBackgroundPointsIndices (xstart, ystart, xend, yend);
-          box = false;
-          initialized = true;
-          show_mask = true;
-          glutPostRedisplay ();
-        }
+      if (!initialized) {
+        xstart = x;
+        ystart = y;
+        box = true;
       }
-      break;
+    }
+
+    if (state == GLUT_UP) {
+      left = false;
 
-    case GLUT_RIGHT_BUTTON:
-      if (state==GLUT_DOWN)
-      {
-        right = true;
+      if (initialized) {
+        grabcut.refineOnce();
+        glutPostRedisplay();
       }
-      if (state==GLUT_UP)
-      {
-        right = false;
-
-        if (initialized)
-        {
-          grabcut.refineOnce ();
-          glutPostRedisplay ();
-        }
+      else {
+        xend = x;
+        yend = y;
+        grabcut.setBackgroundPointsIndices(xstart, ystart, xend, yend);
+        box = false;
+        initialized = true;
+        show_mask = true;
+        glutPostRedisplay();
+      }
+    }
+    break;
+
+  case GLUT_RIGHT_BUTTON:
+    if (state == GLUT_DOWN) {
+      right = true;
+    }
+    if (state == GLUT_UP) {
+      right = false;
+
+      if (initialized) {
+        grabcut.refineOnce();
+        glutPostRedisplay();
       }
-      break;
+    }
+    break;
 
-    default:
-      break;
+  default:
+    break;
   }
 }
 
 /////////////////////////////////////////////////////////////////////////
 void
-keyboard_callback (unsigned char key, int, int)
+keyboard_callback(unsigned char key, int, int)
 {
-  switch (key)
-  {
-    case ' ':           // space bar show/hide alpha mask
-      show_mask = !show_mask;
-      break;
-    case '0': case 'i': case 'I':// choose the RGB image
-      display_type = 0;
-      break;
-    case '1': case 'g': case 'G':// choose GMM index mask
-      display_type = 1;
-      break;
-    case '2': case 'n': case 'N': // choose N-Link mask
-      display_type = 2;
-      break;
-    case '3': case 't': case 'T': // choose T-Link mask
-      display_type = 3;
-      break;
-    case 'r': // run GrabCut refinement
-      refining_ = true;
-      glutIdleFunc (idle_callback);
-      break;
-    case 'o': // run one step of GrabCut refinement
-      grabcut.refineOnce ();
-      glutPostRedisplay ();
-      break;
-    case 'l': // rerun the Orchard-Bowman GMM clustering
-      grabcut.fitGMMs ();
-      glutPostRedisplay ();
-      break;
-    // case 's': case 'S':
-    //   save ();
-    //   break;
-    case 'q': case 'Q':
-#if defined (FREEGLUT) || defined (GLUI_OPENGLUT)
-      glutLeaveMainLoop ();
+  switch (key) {
+  case ' ': // space bar show/hide alpha mask
+    show_mask = !show_mask;
+    break;
+  case '0':
+  case 'i':
+  case 'I': // choose the RGB image
+    display_type = 0;
+    break;
+  case '1':
+  case 'g':
+  case 'G': // choose GMM index mask
+    display_type = 1;
+    break;
+  case '2':
+  case 'n':
+  case 'N': // choose N-Link mask
+    display_type = 2;
+    break;
+  case '3':
+  case 't':
+  case 'T': // choose T-Link mask
+    display_type = 3;
+    break;
+  case 'r': // run GrabCut refinement
+    refining_ = true;
+    glutIdleFunc(idle_callback);
+    break;
+  case 'o': // run one step of GrabCut refinement
+    grabcut.refineOnce();
+    glutPostRedisplay();
+    break;
+  case 'l': // rerun the Orchard-Bowman GMM clustering
+    grabcut.fitGMMs();
+    glutPostRedisplay();
+    break;
+  // case 's': case 'S':
+  //   save ();
+  //   break;
+  case 'q':
+  case 'Q':
+#if defined(FREEGLUT) || defined(GLUI_OPENGLUT)
+    glutLeaveMainLoop();
 #else
-      exit (0);
+    exit(0);
 #endif
-      break;
-    case 27:
-      refining_ = false;
-      glutIdleFunc(nullptr);
-    default:
-      break;
+    break;
+  case 27:
+    refining_ = false;
+    glutIdleFunc(nullptr);
+  default:
+    break;
   }
-  glutPostRedisplay ();
+  glutPostRedisplay();
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
-int main (int argc, char** argv)
+int
+main(int argc, char** argv)
 {
-    // Parse the command line arguments for .pcd files
-  std::vector<int> parsed_file_indices = pcl::console::parse_file_extension_argument (argc, argv, ".pcd");
-  if (parsed_file_indices.empty ())
-  {
-    pcl::console::print_error ("Need at least an input PCD file (e.g. scene.pcd) to continue!\n\n");
-    pcl::console::print_info ("Ideally, need an input file, and two output PCD files, e.g., object.pcd, background.pcd\n");
-    return (-1);
+  // Parse the command line arguments for .pcd files
+  std::vector<int> parsed_file_indices =
+      pcl::console::parse_file_extension_argument(argc, argv, ".pcd");
+  if (parsed_file_indices.empty()) {
+    // clang-format off
+    pcl::console::print_error("Need at least an input PCD file (e.g. scene.pcd) to continue!\n\n");
+    pcl::console::print_info("Ideally, need an input file, and two output PCD files, e.g., object.pcd, background.pcd\n");
+    // clang-format on
+    return -1;
   }
 
   pcl::PCDReader reader;
   // Test the header
   pcl::PCLPointCloud2 dummy;
-  reader.readHeader (argv[parsed_file_indices[0]], dummy);
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr scene (new pcl::PointCloud<pcl::PointXYZRGB>);
-  if (pcl::getFieldIndex (dummy, "rgba") != -1)
-  {
-    if (pcl::io::loadPCDFile (argv[parsed_file_indices[0]], *scene) < 0)
-    {
-      pcl::console::print_error (stderr, "[error]\n");
-      return (-2);
+  reader.readHeader(argv[parsed_file_indices[0]], dummy);
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr scene(new pcl::PointCloud<pcl::PointXYZRGB>);
+  if (pcl::getFieldIndex(dummy, "rgba") != -1) {
+    if (pcl::io::loadPCDFile(argv[parsed_file_indices[0]], *scene) < 0) {
+      pcl::console::print_error(stderr, "[error]\n");
+      return -2;
     }
   }
-  else
-    if (pcl::getFieldIndex (dummy, "rgb") != -1)
-    {
-      if (pcl::io::loadPCDFile (argv[parsed_file_indices[0]], *scene) < 0)
-      {
-        pcl::console::print_error (stderr, "[error]\n");
-        return (-2);
-      }
+  else if (pcl::getFieldIndex(dummy, "rgb") != -1) {
+    if (pcl::io::loadPCDFile(argv[parsed_file_indices[0]], *scene) < 0) {
+      pcl::console::print_error(stderr, "[error]\n");
+      return -2;
     }
-    else
-    {
-      pcl::console::print_error (stderr, "[No RGB data found!]\n");
-      return (-1);
-    }
-
-  if (scene->isOrganized ())
-  {
-    pcl::console::print_highlight ("Enabling 2D image viewer mode.\n");
+  }
+  else {
+    pcl::console::print_error(stderr, "[No RGB data found!]\n");
+    return -1;
   }
 
+  if (scene->isOrganized()) {
+    pcl::console::print_highlight("Enabling 2D image viewer mode.\n");
+  }
 
   width = scene->width;
   height = scene->height;
 
   display_type = -1;
 
-  display_image.reset (new pcl::segmentation::grabcut::Image (scene->width, scene->height));
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmp (new pcl::PointCloud<pcl::PointXYZRGB> (scene->width, scene->height));
-
-  if (scene->isOrganized ())
-  {
-    std::uint32_t height_1 = scene->height -1;
-    for (std::size_t i = 0; i < scene->height; ++i)
-    {
-      for (std::size_t j = 0; j < scene->width; ++j)
-      {
-        const pcl::PointXYZRGB &p = (*scene) (j,i);
-        std::size_t reverse_index = (height_1-i) * scene->width + j;
-        display_image->points[reverse_index].r = static_cast<float> (p.r) / 255.0;
-        display_image->points[reverse_index].g = static_cast<float> (p.g) / 255.0;
-        display_image->points[reverse_index].b = static_cast<float> (p.b) / 255.0;
+  display_image.reset(
+      new pcl::segmentation::grabcut::Image(scene->width, scene->height));
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmp(
+      new pcl::PointCloud<pcl::PointXYZRGB>(scene->width, scene->height));
+
+  if (scene->isOrganized()) {
+    std::uint32_t height_1 = scene->height - 1;
+    for (std::size_t i = 0; i < scene->height; ++i) {
+      for (std::size_t j = 0; j < scene->width; ++j) {
+        const pcl::PointXYZRGB& p = (*scene)(j, i);
+        std::size_t reverse_index = (height_1 - i) * scene->width + j;
+        display_image->points[reverse_index].r = static_cast<float>(p.r) / 255.0;
+        display_image->points[reverse_index].g = static_cast<float>(p.g) / 255.0;
+        display_image->points[reverse_index].b = static_cast<float>(p.b) / 255.0;
         tmp->points[reverse_index] = p;
       }
     }
   }
 
-  grabcut.setInputCloud (tmp);
+  grabcut.setInputCloud(tmp);
 
-  glutInit (&argc,argv);
-  glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
+  glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
 
-  glutInitWindowSize (width, height);
-  glutInitWindowPosition (100,100);
+  glutInitWindowSize(width, height);
+  glutInitWindowPosition(100, 100);
 
-  glutCreateWindow ("GrabCut");
+  glutCreateWindow("GrabCut");
 
-  glOrtho (0,width,0,height,-1,1);
+  glOrtho(0, width, 0, height, -1, 1);
 
-  //set the background color to black (RGBA)
-  glClearColor(0.0,0.0,0.0,0.0);
+  // set the background color to black (RGBA)
+  glClearColor(0.0, 0.0, 0.0, 0.0);
   glEnable(GL_TEXTURE_2D);
   glEnable(GL_BLEND);
-  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-  glutDisplayFunc (display);
-  glutMouseFunc (mouse_callback);
-  glutMotionFunc (motion_callback);
-  glutKeyboardFunc (keyboard_callback);
+  glutDisplayFunc(display);
+  glutMouseFunc(mouse_callback);
+  glutMotionFunc(motion_callback);
+  glutKeyboardFunc(keyboard_callback);
 
-  glutMainLoop ();
+  glutMainLoop();
 
-  return (0);
+  return 0;
 }
index 899e597c29bcc12952737be115614324154f95dd..26c3689536b75285cf781bd2fbcc76501afcf386 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2012, Willow Garage, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *
  * $Id: $
  *
- * @author: Koen Buys - KU Leuven
+ * \author: Koen Buys - KU Leuven
  */
 
 #include <pcl/apps/manual_registration.h>
 
-//QT4
 #include <QApplication>
-#include <QMutexLocker>
 #include <QEvent>
+#include <QMutexLocker>
 #include <QObject>
 
-// VTK
+#include <vtkCamera.h>
 #include <vtkRenderWindow.h>
 #include <vtkRendererCollection.h>
-#include <vtkCamera.h>
 
 using namespace pcl;
 using namespace std;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
-ManualRegistration::ManualRegistration ()
+ManualRegistration::ManualRegistration()
 {
-  //Create a timer
-  vis_timer_ = new QTimer (this);
-  vis_timer_->start (5);//5ms
+  // Create a timer
+  vis_timer_ = new QTimer(this);
+  vis_timer_->start(5); // 5ms
 
-  connect (vis_timer_, SIGNAL (timeout ()), this, SLOT (timeoutSlot()));
+  connect(vis_timer_, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
 
   ui_ = new Ui::MainWindow;
-  ui_->setupUi (this);
-  
-  this->setWindowTitle ("PCL Manual Registration");
+  ui_->setupUi(this);
+
+  this->setWindowTitle("PCL Manual Registration");
 
   // Set up the source window
-  vis_src_.reset (new pcl::visualization::PCLVisualizer ("", false));
-  ui_->qvtk_widget_src->SetRenderWindow (vis_src_->getRenderWindow ());
-  vis_src_->setupInteractor (ui_->qvtk_widget_src->GetInteractor (), ui_->qvtk_widget_src->GetRenderWindow ());
-  vis_src_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
-  ui_->qvtk_widget_src->update ();
+  vis_src_.reset(new pcl::visualization::PCLVisualizer("", false));
+  ui_->qvtk_widget_src->SetRenderWindow(vis_src_->getRenderWindow());
+  vis_src_->setupInteractor(ui_->qvtk_widget_src->GetInteractor(),
+                            ui_->qvtk_widget_src->GetRenderWindow());
+  vis_src_->getInteractorStyle()->setKeyboardModifier(
+      pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
+  ui_->qvtk_widget_src->update();
 
-  vis_src_->registerPointPickingCallback (&ManualRegistration::SourcePointPickCallback, *this);
+  vis_src_->registerPointPickingCallback(&ManualRegistration::SourcePointPickCallback,
+                                         *this);
 
   // Set up the destination window
-  vis_dst_.reset (new pcl::visualization::PCLVisualizer ("", false));
-  ui_->qvtk_widget_dst->SetRenderWindow (vis_dst_->getRenderWindow ());
-  vis_dst_->setupInteractor (ui_->qvtk_widget_dst->GetInteractor (), ui_->qvtk_widget_dst->GetRenderWindow ());
-  vis_dst_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
-  ui_->qvtk_widget_dst->update ();
-
-  vis_dst_->registerPointPickingCallback (&ManualRegistration::DstPointPickCallback, *this);
+  vis_dst_.reset(new pcl::visualization::PCLVisualizer("", false));
+  ui_->qvtk_widget_dst->SetRenderWindow(vis_dst_->getRenderWindow());
+  vis_dst_->setupInteractor(ui_->qvtk_widget_dst->GetInteractor(),
+                            ui_->qvtk_widget_dst->GetRenderWindow());
+  vis_dst_->getInteractorStyle()->setKeyboardModifier(
+      pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
+  ui_->qvtk_widget_dst->update();
 
+  vis_dst_->registerPointPickingCallback(&ManualRegistration::DstPointPickCallback,
+                                         *this);
 
   // Connect all buttons
-  connect (ui_->confirmSrcPointButton, SIGNAL(clicked()), this, SLOT(confirmSrcPointPressed()));
-  connect (ui_->confirmDstPointButton, SIGNAL(clicked()), this, SLOT(confirmDstPointPressed()));
-  connect (ui_->calculateButton, SIGNAL(clicked()), this, SLOT(calculatePressed()));
-  connect (ui_->clearButton, SIGNAL(clicked()), this, SLOT(clearPressed()));
-  connect (ui_->orthoButton, SIGNAL(stateChanged(int)), this, SLOT(orthoChanged(int)));
-  connect (ui_->applyTransformButton, SIGNAL(clicked()), this, SLOT(applyTransformPressed()));
-  connect (ui_->refineButton, SIGNAL(clicked()), this, SLOT(refinePressed()));
-  connect (ui_->undoButton, SIGNAL(clicked()), this, SLOT(undoPressed()));
-  connect (ui_->safeButton, SIGNAL(clicked()), this, SLOT(safePressed()));
+  connect(ui_->confirmSrcPointButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(confirmSrcPointPressed()));
+  connect(ui_->confirmDstPointButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(confirmDstPointPressed()));
+  connect(ui_->calculateButton, SIGNAL(clicked()), this, SLOT(calculatePressed()));
+  connect(ui_->clearButton, SIGNAL(clicked()), this, SLOT(clearPressed()));
+  connect(ui_->orthoButton, SIGNAL(stateChanged(int)), this, SLOT(orthoChanged(int)));
+  connect(ui_->applyTransformButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(applyTransformPressed()));
+  connect(ui_->refineButton, SIGNAL(clicked()), this, SLOT(refinePressed()));
+  connect(ui_->undoButton, SIGNAL(clicked()), this, SLOT(undoPressed()));
+  connect(ui_->safeButton, SIGNAL(clicked()), this, SLOT(safePressed()));
 
   cloud_src_modified_ = true; // first iteration is always a new pointcloud
   cloud_dst_modified_ = true;
 }
 
 void
-ManualRegistration::SourcePointPickCallback (const pcl::visualization::PointPickingEvent& event, void*)
+ManualRegistration::SourcePointPickCallback(
+    const pcl::visualization::PointPickingEvent& event, void*)
 {
   // Check to see if we got a valid point. Early exit.
-  int idx = event.getPointIndex ();
+  int idx = event.getPointIndex();
   if (idx == -1)
     return;
 
   // Get the point that was picked
-  event.getPoint (src_point_.x, src_point_.y, src_point_.z);
-  PCL_INFO ("Src Window: Clicked point %d with X:%f Y:%f Z:%f\n", idx, src_point_.x, src_point_.y, src_point_.z);
+  event.getPoint(src_point_.x, src_point_.y, src_point_.z);
+  PCL_INFO("Src Window: Clicked point %d with X:%f Y:%f Z:%f\n",
+           idx,
+           src_point_.x,
+           src_point_.y,
+           src_point_.z);
   src_point_selected_ = true;
 }
 
 void
-ManualRegistration::DstPointPickCallback (const pcl::visualization::PointPickingEvent& event, void*)
+ManualRegistration::DstPointPickCallback(
+    const pcl::visualization::PointPickingEvent& event, void*)
 {
   // Check to see if we got a valid point. Early exit.
-  int idx = event.getPointIndex ();
+  int idx = event.getPointIndex();
   if (idx == -1)
     return;
 
   // Get the point that was picked
-  event.getPoint (dst_point_.x, dst_point_.y, dst_point_.z);
-  PCL_INFO ("Dst Window: Clicked point %d with X:%f Y:%f Z:%f\n", idx, dst_point_.x, dst_point_.y, dst_point_.z);
+  event.getPoint(dst_point_.x, dst_point_.y, dst_point_.z);
+  PCL_INFO("Dst Window: Clicked point %d with X:%f Y:%f Z:%f\n",
+           idx,
+           dst_point_.x,
+           dst_point_.y,
+           dst_point_.z);
   dst_point_selected_ = true;
 }
 
-void 
+void
 ManualRegistration::confirmSrcPointPressed()
 {
-  if(src_point_selected_)
-  {
+  if (src_point_selected_) {
     src_pc_.points.push_back(src_point_);
-    PCL_INFO ("Selected %d source points\n", src_pc_.points.size());
+    PCL_INFO("Selected %d source points\n", src_pc_.points.size());
     src_point_selected_ = false;
     src_pc_.width = src_pc_.points.size();
   }
-  else
-  {
-    PCL_INFO ("Please select a point in the source window first\n");
+  else {
+    PCL_INFO("Please select a point in the source window first\n");
   }
 }
 
-void 
+void
 ManualRegistration::confirmDstPointPressed()
 {
-  if(dst_point_selected_)
-  {
+  if (dst_point_selected_) {
     dst_pc_.points.push_back(dst_point_);
-    PCL_INFO ("Selected %d destination points\n", dst_pc_.points.size());
+    PCL_INFO("Selected %d destination points\n", dst_pc_.points.size());
     dst_point_selected_ = false;
     dst_pc_.width = dst_pc_.points.size();
   }
-  else
-  {
-    PCL_INFO ("Please select a point in the destination window first\n");
+  else {
+    PCL_INFO("Please select a point in the destination window first\n");
   }
 }
 
-void 
+void
 ManualRegistration::calculatePressed()
 {
-  if(dst_pc_.points.size() != src_pc_.points.size())
-  {
-    PCL_INFO ("You haven't selected an equal amount of points, please do so\n");
+  if (dst_pc_.points.size() != src_pc_.points.size()) {
+    PCL_INFO("You haven't selected an equal amount of points, please do so\n");
     return;
   }
   pcl::registration::TransformationEstimationSVD<pcl::PointXYZ, pcl::PointXYZ> tfe;
@@ -182,66 +199,76 @@ ManualRegistration::clearPressed()
   src_point_selected_ = false;
   src_pc_.points.clear();
   dst_pc_.points.clear();
-  src_pc_.height = 1; src_pc_.width = 0;
-  dst_pc_.height = 1; dst_pc_.width = 0;
+  src_pc_.height = 1;
+  src_pc_.width = 0;
+  dst_pc_.height = 1;
+  dst_pc_.width = 0;
 }
 
-void 
-ManualRegistration::orthoChanged (int state)
+void
+ManualRegistration::orthoChanged(int state)
 {
-  PCL_INFO ("Ortho state %d\n", state);
-  if(state == 0) // Not selected
+  PCL_INFO("Ortho state %d\n", state);
+  if (state == 0) // Not selected
   {
-    vis_src_->getRenderWindow ()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetParallelProjection(0);
-    vis_dst_->getRenderWindow ()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetParallelProjection(0);
+    vis_src_->getRenderWindow()
+        ->GetRenderers()
+        ->GetFirstRenderer()
+        ->GetActiveCamera()
+        ->SetParallelProjection(0);
+    vis_dst_->getRenderWindow()
+        ->GetRenderers()
+        ->GetFirstRenderer()
+        ->GetActiveCamera()
+        ->SetParallelProjection(0);
   }
-  if(state == 2) // Selected
+  if (state == 2) // Selected
   {
-    vis_src_->getRenderWindow ()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetParallelProjection(1);
-    vis_dst_->getRenderWindow ()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetParallelProjection(1);
+    vis_src_->getRenderWindow()
+        ->GetRenderers()
+        ->GetFirstRenderer()
+        ->GetActiveCamera()
+        ->SetParallelProjection(1);
+    vis_dst_->getRenderWindow()
+        ->GetRenderers()
+        ->GetFirstRenderer()
+        ->GetActiveCamera()
+        ->SetParallelProjection(1);
   }
   ui_->qvtk_widget_src->update();
   ui_->qvtk_widget_dst->update();
 }
 
-//TODO
-void 
+// TODO
+void
 ManualRegistration::applyTransformPressed()
-{
-}
+{}
 
 void
 ManualRegistration::refinePressed()
-{
-}
+{}
 
 void
 ManualRegistration::undoPressed()
-{
-}
+{}
 
 void
 ManualRegistration::safePressed()
-{
-}
+{}
 
-void 
-ManualRegistration::timeoutSlot ()
+void
+ManualRegistration::timeoutSlot()
 {
-  if(cloud_src_present_ && cloud_src_modified_)
-  {
-    if(!vis_src_->updatePointCloud(cloud_src_, "cloud_src_"))
-    {
-      vis_src_->addPointCloud (cloud_src_, "cloud_src_");
+  if (cloud_src_present_ && cloud_src_modified_) {
+    if (!vis_src_->updatePointCloud(cloud_src_, "cloud_src_")) {
+      vis_src_->addPointCloud(cloud_src_, "cloud_src_");
       vis_src_->resetCameraViewpoint("cloud_src_");
     }
     cloud_src_modified_ = false;
   }
-  if(cloud_dst_present_ && cloud_dst_modified_)
-  {
-    if(!vis_dst_->updatePointCloud(cloud_dst_, "cloud_dst_"))
-    {
-      vis_dst_->addPointCloud (cloud_dst_, "cloud_dst_");
+  if (cloud_dst_present_ && cloud_dst_modified_) {
+    if (!vis_dst_->updatePointCloud(cloud_dst_, "cloud_dst_")) {
+      vis_dst_->addPointCloud(cloud_dst_, "cloud_dst_");
       vis_dst_->resetCameraViewpoint("cloud_dst_");
     }
     cloud_dst_modified_ = false;
@@ -251,37 +278,40 @@ ManualRegistration::timeoutSlot ()
 }
 
 void
-print_usage ()
+print_usage()
 {
-  PCL_INFO ("manual_registration cloud1.pcd cloud2.pcd\n");
-  PCL_INFO ("\t cloud1 \t source cloud\n");
-  PCL_INFO ("\t cloud2 \t destination cloud\n");
+  PCL_INFO("manual_registration cloud1.pcd cloud2.pcd\n");
+  PCL_INFO("\t cloud1 \t source cloud\n");
+  PCL_INFO("\t cloud2 \t destination cloud\n");
 }
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
   QApplication app(argc, argv);
 
-  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src (new pcl::PointCloud<pcl::PointXYZRGBA>);
-  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst (new pcl::PointCloud<pcl::PointXYZRGBA>);
+  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src(
+      new pcl::PointCloud<pcl::PointXYZRGBA>);
+  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst(
+      new pcl::PointCloud<pcl::PointXYZRGBA>);
 
-  if(argc < 3)
-  {
-    PCL_ERROR ("Incorrect usage\n");
+  if (argc < 3) {
+    PCL_ERROR("Incorrect usage\n");
     print_usage();
   }
 
   // TODO do this with PCL console
-  if (pcl::io::loadPCDFile<pcl::PointXYZRGBA> (argv[1], *cloud_src) == -1) //* load the file
+  if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>(argv[1], *cloud_src) ==
+      -1) //* load the file
   {
-    PCL_ERROR ("Couldn't read file %s \n", argv[1]);
-    return (-1);
+    PCL_ERROR("Couldn't read file %s \n", argv[1]);
+    return -1;
   }
-  if (pcl::io::loadPCDFile<pcl::PointXYZRGBA> (argv[2], *cloud_dst) == -1) //* load the file
+  if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>(argv[2], *cloud_dst) ==
+      -1) //* load the file
   {
-    PCL_ERROR ("Couldn't read file %s \n", argv[2]);
-    return (-1);
+    PCL_ERROR("Couldn't read file %s \n", argv[2]);
+    return -1;
   }
 
   ManualRegistration man_reg;
@@ -291,5 +321,5 @@ main (int argc, char** argv)
 
   man_reg.show();
 
-  return (QApplication::exec());
+  return QApplication::exec();
 }
index b5044583d05da0eb082b2ed69dc1d9304a0ae346..010e3e201f8624167de824236c040a2652954091 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
+#include <pcl/features/fpfh.h>
 #include <pcl/features/multiscale_feature_persistence.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/filters/extract_indices.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/features/fpfh.h>
-
+#include <pcl/filters/extract_indices.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 using namespace pcl;
 
-const Eigen::Vector4f subsampling_leaf_size (0.01f, 0.01f, 0.01f, 0.0f);
+const Eigen::Vector4f subsampling_leaf_size(0.01f, 0.01f, 0.01f, 0.0f);
 const float normal_estimation_search_radius = 0.05f;
 
-
 void
-subsampleAndCalculateNormals (PointCloud<PointXYZ>::Ptr &cloud,
-                              PointCloud<PointXYZ>::Ptr &cloud_subsampled,
-                              PointCloud<Normal>::Ptr &cloud_subsampled_normals)
+subsampleAndCalculateNormals(PointCloud<PointXYZ>::Ptr& cloud,
+                             PointCloud<PointXYZ>::Ptr& cloud_subsampled,
+                             PointCloud<Normal>::Ptr& cloud_subsampled_normals)
 {
-  cloud_subsampled = PointCloud<PointXYZ>::Ptr (new PointCloud<PointXYZ> ());
+  cloud_subsampled = PointCloud<PointXYZ>::Ptr(new PointCloud<PointXYZ>());
   VoxelGrid<PointXYZ> subsampling_filter;
-  subsampling_filter.setInputCloud (cloud);
-  subsampling_filter.setLeafSize (subsampling_leaf_size);
-  subsampling_filter.filter (*cloud_subsampled);
+  subsampling_filter.setInputCloud(cloud);
+  subsampling_filter.setLeafSize(subsampling_leaf_size);
+  subsampling_filter.filter(*cloud_subsampled);
 
-  cloud_subsampled_normals = PointCloud<Normal>::Ptr (new PointCloud<Normal> ());
+  cloud_subsampled_normals = PointCloud<Normal>::Ptr(new PointCloud<Normal>());
   NormalEstimation<PointXYZ, Normal> normal_estimation_filter;
-  normal_estimation_filter.setInputCloud (cloud_subsampled);
-  pcl::search::KdTree<PointXYZ>::Ptr search_tree (new pcl::search::KdTree<PointXYZ>);
-  normal_estimation_filter.setSearchMethod (search_tree);
-  normal_estimation_filter.setRadiusSearch (normal_estimation_search_radius);
-  normal_estimation_filter.compute (*cloud_subsampled_normals);
+  normal_estimation_filter.setInputCloud(cloud_subsampled);
+  pcl::search::KdTree<PointXYZ>::Ptr search_tree(new pcl::search::KdTree<PointXYZ>);
+  normal_estimation_filter.setSearchMethod(search_tree);
+  normal_estimation_filter.setRadiusSearch(normal_estimation_search_radius);
+  normal_estimation_filter.compute(*cloud_subsampled_normals);
 }
 
-
 int
-main (int argc, char **argv)
+main(int argc, char** argv)
 {
-  if (argc != 2)
-  {
-    PCL_ERROR ("Syntax: ./multiscale_feature_persistence_example [path_to_cloud.pcl]\n");
+  if (argc != 2) {
+    PCL_ERROR("Syntax: ./multiscale_feature_persistence_example [path_to_cloud.pcl]\n");
     return -1;
   }
 
-  PointCloud<PointXYZ>::Ptr cloud_scene (new PointCloud<PointXYZ> ());
+  PointCloud<PointXYZ>::Ptr cloud_scene(new PointCloud<PointXYZ>());
   PCDReader reader;
-  reader.read (argv[1], *cloud_scene);
+  reader.read(argv[1], *cloud_scene);
 
   PointCloud<PointXYZ>::Ptr cloud_subsampled;
   PointCloud<Normal>::Ptr cloud_subsampled_normals;
-  subsampleAndCalculateNormals (cloud_scene, cloud_subsampled, cloud_subsampled_normals);
-
-  PCL_INFO ("STATS:\ninitial point cloud size: %u\nsubsampled point cloud size: %u\n", cloud_scene->points.size (), cloud_subsampled->points.size ());
-  visualization::CloudViewer viewer ("Multiscale Feature Persistence Example Visualization");
-  viewer.showCloud (cloud_scene, "scene");
+  subsampleAndCalculateNormals(cloud_scene, cloud_subsampled, cloud_subsampled_normals);
 
+  PCL_INFO("STATS:\ninitial point cloud size: %u\nsubsampled point cloud size: %u\n",
+           cloud_scene->points.size(),
+           cloud_subsampled->points.size());
+  visualization::CloudViewer viewer(
+      "Multiscale Feature Persistence Example Visualization");
+  viewer.showCloud(cloud_scene, "scene");
 
   MultiscaleFeaturePersistence<PointXYZ, FPFHSignature33> feature_persistence;
   std::vector<float> scale_values;
   for (float x = 2.0f; x < 3.6f; x += 0.35f)
-    scale_values.push_back (x / 100.0f);
-  feature_persistence.setScalesVector (scale_values);
-  feature_persistence.setAlpha (1.3f);
-  FPFHEstimation<PointXYZ, Normal, FPFHSignature33>::Ptr fpfh_estimation (new FPFHEstimation<PointXYZ, Normal, FPFHSignature33> ());
-  fpfh_estimation->setInputCloud (cloud_subsampled);
-  fpfh_estimation->setInputNormals (cloud_subsampled_normals);
-  pcl::search::KdTree<PointXYZ>::Ptr tree (new pcl::search::KdTree<PointXYZ> ());
-  fpfh_estimation->setSearchMethod (tree);
-  feature_persistence.setFeatureEstimator (fpfh_estimation);
-  feature_persistence.setDistanceMetric (pcl::CS);
-
-  PointCloud<FPFHSignature33>::Ptr output_features (new PointCloud<FPFHSignature33> ());
-  auto output_indices = pcl::make_shared<std::vector<int>> ();
-  feature_persistence.determinePersistentFeatures (*output_features, output_indices);
-
-  PCL_INFO ("persistent features cloud size: %u\n", output_features->points.size ());
+    scale_values.push_back(x / 100.0f);
+  feature_persistence.setScalesVector(scale_values);
+  feature_persistence.setAlpha(1.3f);
+  FPFHEstimation<PointXYZ, Normal, FPFHSignature33>::Ptr fpfh_estimation(
+      new FPFHEstimation<PointXYZ, Normal, FPFHSignature33>());
+  fpfh_estimation->setInputCloud(cloud_subsampled);
+  fpfh_estimation->setInputNormals(cloud_subsampled_normals);
+  pcl::search::KdTree<PointXYZ>::Ptr tree(new pcl::search::KdTree<PointXYZ>());
+  fpfh_estimation->setSearchMethod(tree);
+  feature_persistence.setFeatureEstimator(fpfh_estimation);
+  feature_persistence.setDistanceMetric(pcl::CS);
+
+  PointCloud<FPFHSignature33>::Ptr output_features(new PointCloud<FPFHSignature33>());
+  auto output_indices = pcl::make_shared<std::vector<int>>();
+  feature_persistence.determinePersistentFeatures(*output_features, output_indices);
+
+  PCL_INFO("persistent features cloud size: %u\n", output_features->points.size());
 
   ExtractIndices<PointXYZ> extract_indices_filter;
-  extract_indices_filter.setInputCloud (cloud_subsampled);
-  extract_indices_filter.setIndices (output_indices);
-  PointCloud<PointXYZ>::Ptr persistent_features_locations (new PointCloud<PointXYZ> ());
-  extract_indices_filter.filter (*persistent_features_locations);
-
-  viewer.showCloud (persistent_features_locations, "persistent features");
-  PCL_INFO ("Persistent features have been computed. Waiting for the user to quit the visualization window.\n");
+  extract_indices_filter.setInputCloud(cloud_subsampled);
+  extract_indices_filter.setIndices(output_indices);
+  PointCloud<PointXYZ>::Ptr persistent_features_locations(new PointCloud<PointXYZ>());
+  extract_indices_filter.filter(*persistent_features_locations);
 
-//  io::savePCDFileASCII ("persistent_features.pcd", *persistent_features_locations);
-//  PCL_INFO ("\nPersistent feature locations written to persistent_features.pcd\n");
+  viewer.showCloud(persistent_features_locations, "persistent features");
+  PCL_INFO("Persistent features have been computed. Waiting for the user to quit the "
+           "visualization window.\n");
 
-  while (!viewer.wasStopped (50)) {}
+  while (!viewer.wasStopped(50)) {
+  }
 
-  return (0);
+  return 0;
 }
index b399ac4038b055af27abb336c9d62d0eb379a42b..a7f110e56e877085a42a4874760118ed09a858b6 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
 #define SHOW_FPS 1
 
 #include <pcl/apps/timer.h>
-#include <pcl/common/common.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/common.h>
 #include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/filters/extract_indices.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/keypoints/agast_2d.h>
-#include <pcl/filters/extract_indices.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/image_viewer.h>
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
+#include <pcl/visualization/pcl_visualizer.h>
 
 #include <mutex>
 #include <thread>
@@ -63,300 +63,309 @@ using KeyPointT = PointUV;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
-class AGASTDemo
-{
-  public:
-    using Cloud = PointCloud<PointT>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    AGASTDemo (Grabber& grabber)
-      : cloud_viewer_ ("AGAST 2D Keypoints -- PointCloud")
-      , grabber_ (grabber)
-      , image_viewer_ ("AGAST 2D Keypoints -- Image")
-      , bmax_ (255)
-      , threshold_ (30)
-      , detector_type_ (0)
-    {
+class AGASTDemo {
+public:
+  using Cloud = PointCloud<PointT>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  AGASTDemo(Grabber& grabber)
+  : cloud_viewer_("AGAST 2D Keypoints -- PointCloud")
+  , grabber_(grabber)
+  , image_viewer_("AGAST 2D Keypoints -- Image")
+  , bmax_(255)
+  , threshold_(30)
+  , detector_type_(0)
+  {}
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  cloud_callback(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+
+    // Compute AGAST keypoints
+    AgastKeypoint2D<PointT> agast;
+    agast.setNonMaxSuppression(true);
+    agast.setThreshold(threshold_);
+    agast.setMaxDataValue(bmax_);
+    agast.setInputCloud(cloud);
+
+    keypoints_.reset(new PointCloud<KeyPointT>);
+
+    // Select the detector type
+    switch (detector_type_) {
+    case 1:
+    default: {
+      timer_.reset();
+      pcl::keypoints::agast::AgastDetector7_12s::Ptr detector(
+          new pcl::keypoints::agast::AgastDetector7_12s(
+              cloud->width, cloud->height, threshold_, bmax_));
+      agast.setAgastDetector(detector);
+      agast.compute(*keypoints_);
+      PCL_DEBUG("AGAST 7_12s computation took %f ms.\n", timer_.getTime());
+      break;
     }
-
-    /////////////////////////////////////////////////////////////////////////
-    void
-    cloud_callback (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-
-      // Compute AGAST keypoints 
-      AgastKeypoint2D<PointT> agast;
-      agast.setNonMaxSuppression (true);
-      agast.setThreshold (threshold_);
-      agast.setMaxDataValue (bmax_);
-      agast.setInputCloud (cloud);
-
-      keypoints_.reset (new PointCloud<KeyPointT>);
-
-      // Select the detector type
-      switch (detector_type_)
-      {
-        case 1:
-        default:
-        {
-          timer_.reset ();
-          pcl::keypoints::agast::AgastDetector7_12s::Ptr detector (new pcl::keypoints::agast::AgastDetector7_12s (cloud->width, cloud->height, threshold_, bmax_));
-          agast.setAgastDetector (detector);
-          agast.compute (*keypoints_);
-          PCL_DEBUG ("AGAST 7_12s computation took %f ms.\n", timer_.getTime ());
-          break;
-        }
-        case 2:
-        {
-          timer_.reset ();
-          pcl::keypoints::agast::AgastDetector5_8::Ptr detector (new pcl::keypoints::agast::AgastDetector5_8 (cloud->width, cloud->height, threshold_, bmax_));
-          agast.setAgastDetector (detector);
-          agast.compute (*keypoints_);
-          PCL_DEBUG ("AGAST 5_8 computation took %f ms.\n", timer_.getTime ());
-          break;
-        }
-        case 3:
-        {
-          timer_.reset ();
-          pcl::keypoints::agast::OastDetector9_16::Ptr detector (new pcl::keypoints::agast::OastDetector9_16 (cloud->width, cloud->height, threshold_, bmax_));
-          agast.setAgastDetector (detector);
-          agast.compute (*keypoints_);
-          PCL_DEBUG ("OAST 9_6 computation took %f ms.\n", timer_.getTime ());
-          break;
-        }
-      }
-      cloud_ = cloud;
+    case 2: {
+      timer_.reset();
+      pcl::keypoints::agast::AgastDetector5_8::Ptr detector(
+          new pcl::keypoints::agast::AgastDetector5_8(
+              cloud->width, cloud->height, threshold_, bmax_));
+      agast.setAgastDetector(detector);
+      agast.compute(*keypoints_);
+      PCL_DEBUG("AGAST 5_8 computation took %f ms.\n", timer_.getTime());
+      break;
+    }
+    case 3: {
+      timer_.reset();
+      pcl::keypoints::agast::OastDetector9_16::Ptr detector(
+          new pcl::keypoints::agast::OastDetector9_16(
+              cloud->width, cloud->height, threshold_, bmax_));
+      agast.setAgastDetector(detector);
+      agast.compute(*keypoints_);
+      PCL_DEBUG("OAST 9_6 computation took %f ms.\n", timer_.getTime());
+      break;
+    }
+    }
+    cloud_ = cloud;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void* cookie)
+  {
+    AGASTDemo* obj = static_cast<AGASTDemo*>(cookie);
+
+    if (event.getKeyCode()) {
+      std::stringstream ss;
+      ss << event.getKeyCode();
+      obj->detector_type_ = atoi(ss.str().c_str());
+      return;
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    void 
-    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie)
-    {
-      AGASTDemo* obj = static_cast<AGASTDemo*> (cookie);
-      
-      if (event.getKeyCode ())
-      {
-        std::stringstream ss; ss << event.getKeyCode ();
-        obj->detector_type_ = atoi (ss.str ().c_str ());
+    if (event.getKeySym() == "Up") {
+      if (obj->threshold_ <= 0.9) {
+        PCL_INFO("[keyboard_callback] Increase AGAST threshold from %f to %f.\n",
+                 obj->threshold_,
+                 obj->threshold_ + 0.01);
+        obj->threshold_ += 0.01;
         return;
       }
+      PCL_INFO("[keyboard_callback] Increase AGAST threshold from %f to %f.\n",
+               obj->threshold_,
+               obj->threshold_ + 1);
+      obj->threshold_ += 1;
+      return;
+    }
 
-      if (event.getKeySym () == "Up")
-      {
-        if (obj->threshold_ <= 0.9)
-        {
-          PCL_INFO ("[keyboard_callback] Increase AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ + 0.01);
-          obj->threshold_ += 0.01;
-          return;
-        }
-        PCL_INFO ("[keyboard_callback] Increase AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ + 1);
-        obj->threshold_ += 1;
+    if (event.getKeySym() == "Down") {
+      if (obj->threshold_ <= 0)
         return;
-      }
-
-      if (event.getKeySym () == "Down")
-      {
-        if (obj->threshold_ <= 0)
-          return;
-        if (obj->threshold_ <= 1)
-        {
-          PCL_INFO ("[keyboard_callback] Decrease AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ - 0.01);
-          obj->threshold_ -= 0.01;
-          return;
-        }
-        PCL_INFO ("[keyboard_callback] Decrease AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ - 1);
-        obj->threshold_ -= 1;
+      if (obj->threshold_ <= 1) {
+        PCL_INFO("[keyboard_callback] Decrease AGAST threshold from %f to %f.\n",
+                 obj->threshold_,
+                 obj->threshold_ - 0.01);
+        obj->threshold_ -= 0.01;
         return;
       }
+      PCL_INFO("[keyboard_callback] Decrease AGAST threshold from %f to %f.\n",
+               obj->threshold_,
+               obj->threshold_ - 1);
+      obj->threshold_ -= 1;
+      return;
+    }
 
-      if (event.getKeySym () == "Right")
-      {
-        PCL_INFO ("[keyboard_callback] Increase AGAST BMAX from %f to %f.\n", obj->bmax_, obj->bmax_ + 1);
-        obj->bmax_ += 1;
-        return;
-      }
+    if (event.getKeySym() == "Right") {
+      PCL_INFO("[keyboard_callback] Increase AGAST BMAX from %f to %f.\n",
+               obj->bmax_,
+               obj->bmax_ + 1);
+      obj->bmax_ += 1;
+      return;
+    }
 
-      if (event.getKeySym () == "Left")
-      {
-        if (obj->bmax_ <= 0)
-          return;
-        PCL_INFO ("[keyboard_callback] Decrease AGAST BMAX from %f to %f.\n", obj->bmax_, obj->bmax_ - 1);
-        obj->bmax_ -= 1;
+    if (event.getKeySym() == "Left") {
+      if (obj->bmax_ <= 0)
         return;
-      }
+      PCL_INFO("[keyboard_callback] Decrease AGAST BMAX from %f to %f.\n",
+               obj->bmax_,
+               obj->bmax_ - 1);
+      obj->bmax_ -= 1;
+      return;
     }
-
-    /////////////////////////////////////////////////////////////////////////
-    void
-    init ()
-    {
-      std::function<void (const CloudConstPtr&) > cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback (cloud); };
-      cloud_connection = grabber_.registerCallback (cloud_cb);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  init()
+  {
+    std::function<void(const CloudConstPtr&)> cloud_cb =
+        [this](const CloudConstPtr& cloud) { cloud_callback(cloud); };
+    cloud_connection = grabber_.registerCallback(cloud_cb);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  string
+  getStrBool(bool state)
+  {
+    stringstream ss;
+    ss << state;
+    return ss.str();
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  get3DKeypoints(const CloudConstPtr& cloud,
+                 const PointCloud<KeyPointT>::Ptr& keypoints,
+                 PointCloud<PointT>& keypoints3d)
+  {
+    if (!cloud || !keypoints || cloud->points.empty() || keypoints->points.empty())
+      return;
+
+    keypoints3d.resize(keypoints->size());
+    keypoints3d.width = keypoints->width;
+    keypoints3d.height = keypoints->height;
+    keypoints3d.is_dense = true;
+
+    std::size_t j = 0;
+    for (std::size_t i = 0; i < keypoints->size(); ++i) {
+      const PointT& pt =
+          (*cloud)(static_cast<long unsigned int>(keypoints->points[i].u),
+                   static_cast<long unsigned int>(keypoints->points[i].v));
+      if (!std::isfinite(pt.x) || !std::isfinite(pt.y) || !std::isfinite(pt.z))
+        continue;
+
+      keypoints3d.points[j].x = pt.x;
+      keypoints3d.points[j].y = pt.y;
+      keypoints3d.points[j].z = pt.z;
+      ++j;
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    string
-    getStrBool (bool state)
-    {
-      stringstream ss;
-      ss << state;
-      return (ss.str ());
+    if (j != keypoints->size()) {
+      keypoints3d.resize(j);
+      keypoints3d.width = j;
+      keypoints3d.height = 1;
     }
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    get3DKeypoints (
-        const CloudConstPtr &cloud,
-        const PointCloud<KeyPointT>::Ptr &keypoints, PointCloud<PointT> &keypoints3d)
-    {
-      if (!cloud || !keypoints || cloud->points.empty () || keypoints->points.empty ())
-        return;
+  /////////////////////////////////////////////////////////////////////////
+  void
+  run()
+  {
+    cloud_viewer_.registerKeyboardCallback(
+        &AGASTDemo::keyboard_callback, *this, static_cast<AGASTDemo*>(this));
+    image_viewer_.registerKeyboardCallback(
+        &AGASTDemo::keyboard_callback, *this, static_cast<AGASTDemo*>(this));
 
-      keypoints3d.resize (keypoints->size ());
-      keypoints3d.width = keypoints->width;
-      keypoints3d.height = keypoints->height;
-      keypoints3d.is_dense = true;
-
-      std::size_t j = 0;
-      for (std::size_t i = 0; i < keypoints->size (); ++i)
-      {
-        const PointT &pt = (*cloud)(static_cast<long unsigned int> (keypoints->points[i].u), 
-                                    static_cast<long unsigned int> (keypoints->points[i].v));
-        if (!std::isfinite (pt.x) || !std::isfinite (pt.y) || !std::isfinite (pt.z))
-          continue;
-
-        keypoints3d.points[j].x = pt.x;
-        keypoints3d.points[j].y = pt.y;
-        keypoints3d.points[j].z = pt.z;
-        ++j;
-      }
+    grabber_.start();
+
+    bool image_init = false, cloud_init = false;
+    bool keypts = true;
 
-      if (j != keypoints->size ())
-      {
-        keypoints3d.resize (j);
-        keypoints3d.width = j;
-        keypoints3d.height = 1;
+    CloudPtr keypoints3d(new Cloud);
+
+    while (!cloud_viewer_.wasStopped() && !image_viewer_.wasStopped()) {
+      PointCloud<KeyPointT>::Ptr keypoints;
+      CloudConstPtr cloud;
+
+      if (cloud_mutex_.try_lock()) {
+        cloud_.swap(cloud);
+        keypoints_.swap(keypoints);
+
+        cloud_mutex_.unlock();
       }
-    }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    run ()
-    {
-      cloud_viewer_.registerKeyboardCallback (&AGASTDemo::keyboard_callback, *this, static_cast<AGASTDemo*> (this));
-      image_viewer_.registerKeyboardCallback (&AGASTDemo::keyboard_callback, *this, static_cast<AGASTDemo*> (this));
-
-      grabber_.start ();
-      
-      bool image_init = false, cloud_init = false;
-      bool keypts = true;
-
-      CloudPtr keypoints3d (new Cloud);
-
-      while (!cloud_viewer_.wasStopped () && !image_viewer_.wasStopped ())
-      {
-        PointCloud<KeyPointT>::Ptr keypoints;
-        CloudConstPtr cloud;
-
-        if (cloud_mutex_.try_lock ())
-        {
-          cloud_.swap (cloud);
-          keypoints_.swap (keypoints);
-        
-          cloud_mutex_.unlock ();
-        }
 
-        if (cloud)
-        {
-          if (!cloud_init)
-          {
-            cloud_viewer_.setPosition (0, 0);
-            cloud_viewer_.setSize (cloud->width, cloud->height);
-            cloud_init = true;
-          }
+      if (cloud) {
+        if (!cloud_init) {
+          cloud_viewer_.setPosition(0, 0);
+          cloud_viewer_.setSize(cloud->width, cloud->height);
+          cloud_init = true;
+        }
 
-          if (!cloud_viewer_.updatePointCloud (cloud, "OpenNICloud"))
-          {
-            cloud_viewer_.addPointCloud (cloud, "OpenNICloud");
-            cloud_viewer_.resetCameraViewpoint ("OpenNICloud");
-          }
+        if (!cloud_viewer_.updatePointCloud(cloud, "OpenNICloud")) {
+          cloud_viewer_.addPointCloud(cloud, "OpenNICloud");
+          cloud_viewer_.resetCameraViewpoint("OpenNICloud");
+        }
 
-          if (!image_init)
-          {
-            image_viewer_.setPosition (cloud->width, 0);
-            image_viewer_.setSize (cloud->width, cloud->height);
-            image_init = true;
-          }
+        if (!image_init) {
+          image_viewer_.setPosition(cloud->width, 0);
+          image_viewer_.setSize(cloud->width, cloud->height);
+          image_init = true;
+        }
 
-          image_viewer_.addRGBImage<PointT> (cloud);
-
-          if (keypoints && !keypoints->empty ())
-          {
-            image_viewer_.removeLayer (getStrBool (keypts));
-            for (std::size_t i = 0; i < keypoints->size (); ++i)
-            {
-              int u = int (keypoints->points[i].u);
-              int v = int (keypoints->points[i].v);
-              image_viewer_.markPoint (u, v, visualization::red_color, visualization::blue_color, 10, getStrBool (!keypts));
-            }
-            keypts = !keypts;
-
-            get3DKeypoints (cloud, keypoints, *keypoints3d);
-            visualization::PointCloudColorHandlerCustom<PointT> blue (keypoints3d, 0, 0, 255);
-            if (!cloud_viewer_.updatePointCloud (keypoints3d, blue, "keypoints"))
-              cloud_viewer_.addPointCloud (keypoints3d, blue, "keypoints");
-            cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_POINT_SIZE, 20, "keypoints");
-            cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
+        image_viewer_.addRGBImage<PointT>(cloud);
+
+        if (keypoints && !keypoints->empty()) {
+          image_viewer_.removeLayer(getStrBool(keypts));
+          for (std::size_t i = 0; i < keypoints->size(); ++i) {
+            int u = int(keypoints->points[i].u);
+            int v = int(keypoints->points[i].v);
+            image_viewer_.markPoint(u,
+                                    v,
+                                    visualization::red_color,
+                                    visualization::blue_color,
+                                    10,
+                                    getStrBool(!keypts));
           }
+          keypts = !keypts;
+
+          get3DKeypoints(cloud, keypoints, *keypoints3d);
+          visualization::PointCloudColorHandlerCustom<PointT> blue(
+              keypoints3d, 0, 0, 255);
+          if (!cloud_viewer_.updatePointCloud(keypoints3d, blue, "keypoints"))
+            cloud_viewer_.addPointCloud(keypoints3d, blue, "keypoints");
+          cloud_viewer_.setPointCloudRenderingProperties(
+              visualization::PCL_VISUALIZER_POINT_SIZE, 20, "keypoints");
+          cloud_viewer_.setPointCloudRenderingProperties(
+              visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
         }
-
-        cloud_viewer_.spinOnce ();
-        image_viewer_.spinOnce ();
-        std::this_thread::sleep_for(100us);
       }
 
-      grabber_.stop ();
-      cloud_connection.disconnect ();
+      cloud_viewer_.spinOnce();
+      image_viewer_.spinOnce();
+      std::this_thread::sleep_for(100us);
     }
-    
-    visualization::PCLVisualizer cloud_viewer_;
-    Grabber& grabber_;
-    std::mutex cloud_mutex_;
-    CloudConstPtr cloud_;
-    
-    visualization::ImageViewer image_viewer_;
-
-    PointCloud<KeyPointT>::Ptr keypoints_;
-
-    double bmax_;
-    double threshold_;
-    int detector_type_;
-  private:
-    boost::signals2::connection cloud_connection;
-    StopWatch timer_;
+
+    grabber_.stop();
+    cloud_connection.disconnect();
+  }
+
+  visualization::PCLVisualizer cloud_viewer_;
+  Grabber& grabber_;
+  std::mutex cloud_mutex_;
+  CloudConstPtr cloud_;
+
+  visualization::ImageViewer image_viewer_;
+
+  PointCloud<KeyPointT>::Ptr keypoints_;
+
+  double bmax_;
+  double threshold_;
+  int detector_type_;
+
+private:
+  boost::signals2::connection cloud_connection;
+  StopWatch timer_;
 };
 
 /* ---[ */
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
   bool debug = false;
-  pcl::console::parse_argument (argc, argv, "-debug", debug);
+  pcl::console::parse_argument(argc, argv, "-debug", debug);
   if (debug)
-    pcl::console::setVerbosityLevel (pcl::console::L_DEBUG);
+    pcl::console::setVerbosityLevel(pcl::console::L_DEBUG);
   else
-    pcl::console::setVerbosityLevel (pcl::console::L_INFO);
+    pcl::console::setVerbosityLevel(pcl::console::L_INFO);
+
+  string device_id("#1");
+  OpenNIGrabber grabber(device_id);
+  AGASTDemo<PointXYZRGBA> openni_viewer(grabber);
 
-  string device_id ("#1");
-  OpenNIGrabber grabber (device_id);
-  AGASTDemo<PointXYZRGBA> openni_viewer (grabber);
+  openni_viewer.init();
+  openni_viewer.run();
 
-  openni_viewer.init ();
-  openni_viewer.run ();
-  
-  return (0);
+  return 0;
 }
 /* ]--- */
index 4985435fb3d9db181454ab591270910f90327db0..8b5ad09fa9e419549dbb7604a9d04cc15436bfb0 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
 #define SHOW_FPS 1
 
 #include <pcl/apps/timer.h>
-#include <pcl/common/common.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/common.h>
 #include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/filters/extract_indices.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/keypoints/brisk_2d.h>
-#include <pcl/filters/extract_indices.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/image_viewer.h>
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
+#include <pcl/visualization/pcl_visualizer.h>
 
 #include <mutex>
 #include <thread>
@@ -63,248 +63,244 @@ using PointT = PointXYZRGBA;
 using KeyPointT = PointWithScale;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class BRISKDemo
-{
-  public:
-    using Cloud = PointCloud<PointT>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-    BRISKDemo (Grabber& grabber)
-      : cloud_viewer_ ("BRISK 2D Keypoints -- PointCloud")
-      , grabber_ (grabber)
-      , image_viewer_ ("BRISK 2D Keypoints -- Image")
-    {
+class BRISKDemo {
+public:
+  using Cloud = PointCloud<PointT>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  BRISKDemo(Grabber& grabber)
+  : cloud_viewer_("BRISK 2D Keypoints -- PointCloud")
+  , grabber_(grabber)
+  , image_viewer_("BRISK 2D Keypoints -- Image")
+  {}
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  cloud_callback(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+
+    // Compute BRISK keypoints
+    BriskKeypoint2D<PointT> brisk;
+    brisk.setThreshold(60);
+    brisk.setOctaves(4);
+    brisk.setInputCloud(cloud);
+
+    keypoints_.reset(new PointCloud<KeyPointT>);
+    brisk.compute(*keypoints_);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  init()
+  {
+    std::function<void(const CloudConstPtr&)> cloud_cb =
+        [this](const CloudConstPtr& cloud) { cloud_callback(cloud); };
+    cloud_connection = grabber_.registerCallback(cloud_cb);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  string
+  getStrBool(bool state)
+  {
+    stringstream ss;
+    ss << state;
+    return ss.str();
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  inline PointT
+  bilinearInterpolation(const CloudConstPtr& cloud, float x, float y)
+  {
+    int u = int(x);
+    int v = int(y);
+
+    PointT pt;
+    pt.x = pt.y = pt.z = 0;
+
+    const PointT& p1 = (*cloud)(u, v);
+    const PointT& p2 = (*cloud)(u + 1, v);
+    const PointT& p3 = (*cloud)(u, v + 1);
+    const PointT& p4 = (*cloud)(u + 1, v + 1);
+
+    float fx = x - float(u), fy = y - float(v);
+    float fx1 = 1.0f - fx, fy1 = 1.0f - fy;
+
+    float w1 = fx1 * fy1, w2 = fx * fy1, w3 = fx1 * fy, w4 = fx * fy;
+    float weight = 0;
+
+    if (isFinite(p1)) {
+      pt.x += p1.x * w1;
+      pt.y += p1.y * w1;
+      pt.z += p1.z * w1;
+      weight += w1;
+    }
+    if (isFinite(p2)) {
+      pt.x += p2.x * w2;
+      pt.y += p2.y * w2;
+      pt.z += p2.z * w2;
+      weight += w2;
+    }
+    if (isFinite(p3)) {
+      pt.x += p3.x * w3;
+      pt.y += p3.y * w3;
+      pt.z += p3.z * w3;
+      weight += w3;
+    }
+    if (isFinite(p4)) {
+      pt.x += p4.x * w4;
+      pt.y += p4.y * w4;
+      pt.z += p4.z * w4;
+      weight += w4;
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    cloud_callback (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      cloud_ = cloud;
-
-      // Compute BRISK keypoints 
-      BriskKeypoint2D<PointT> brisk;
-      brisk.setThreshold (60);
-      brisk.setOctaves (4);
-      brisk.setInputCloud (cloud);
-
-      keypoints_.reset (new PointCloud<KeyPointT>);
-      brisk.compute (*keypoints_);
+    if (weight == 0)
+      pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN();
+    else {
+      weight = 1.0f / weight;
+      pt.x *= weight;
+      pt.y *= weight;
+      pt.z *= weight;
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    init ()
-    {
-      std::function<void (const CloudConstPtr&) > cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback (cloud); };
-      cloud_connection = grabber_.registerCallback (cloud_cb);
+    return pt;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  get3DKeypoints(const CloudConstPtr& cloud,
+                 const PointCloud<KeyPointT>::Ptr& keypoints,
+                 PointCloud<PointT>& keypoints3d)
+  {
+    keypoints3d.resize(keypoints->size());
+    keypoints3d.width = keypoints->width;
+    keypoints3d.height = keypoints->height;
+    keypoints3d.is_dense = true;
+
+    std::size_t j = 0;
+    for (std::size_t i = 0; i < keypoints->size(); ++i) {
+      PointT pt =
+          bilinearInterpolation(cloud, keypoints->points[i].x, keypoints->points[i].y);
+
+      keypoints3d.points[j].x = pt.x;
+      keypoints3d.points[j].y = pt.y;
+      keypoints3d.points[j].z = pt.z;
+      ++j;
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    string
-    getStrBool (bool state)
-    {
-      stringstream ss;
-      ss << state;
-      return (ss.str ());
+    if (j != keypoints->size()) {
+      keypoints3d.resize(j);
+      keypoints3d.width = j;
+      keypoints3d.height = 1;
     }
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    inline PointT
-    bilinearInterpolation (const CloudConstPtr &cloud, float x, float y)
-    {
-      int u = int (x);
-      int v = int (y);
-      
-      PointT pt;
-      pt.x = pt.y = pt.z = 0;
-
-      const PointT &p1 = (*cloud)(u,   v);
-      const PointT &p2 = (*cloud)(u+1, v);
-      const PointT &p3 = (*cloud)(u,   v+1);
-      const PointT &p4 = (*cloud)(u+1, v+1);
-      
-      float fx = x - float (u), fy = y - float (v);
-      float fx1 = 1.0f - fx, fy1 = 1.0f - fy;
-
-      float w1 = fx1 * fy1, w2 = fx * fy1, w3 = fx1 * fy, w4 = fx * fy;
-      float weight = 0;
-      
-      if (isFinite (p1))
-      {
-        pt.x += p1.x * w1;
-        pt.y += p1.y * w1;
-        pt.z += p1.z * w1;
-        weight += w1;
-      }
-      if (isFinite (p2))
-      {
-        pt.x += p2.x * w2;
-        pt.y += p2.y * w2;
-        pt.z += p2.z * w2;
-        weight += w2;
-      }
-      if (isFinite (p3))
-      {
-        pt.x += p3.x * w3;
-        pt.y += p3.y * w3;
-        pt.z += p3.z * w3;
-        weight += w3;
-      }
-      if (isFinite (p4))
-      {
-        pt.x += p4.x * w4;
-        pt.y += p4.y * w4;
-        pt.z += p4.z * w4;
-        weight += w4;
-      }
+  /////////////////////////////////////////////////////////////////////////
+  void
+  run()
+  {
+    grabber_.start();
 
-      if (weight == 0)
-        pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN ();
-      else
-      {
-        weight = 1.0f / weight;
-        pt.x *= weight; pt.y *= weight; pt.z *= weight;
-      }
-      return (pt);
-    }
+    bool image_init = false, cloud_init = false;
+    bool keypts = true;
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    get3DKeypoints (
-        const CloudConstPtr &cloud,
-        const PointCloud<KeyPointT>::Ptr &keypoints, PointCloud<PointT> &keypoints3d)
-    {
-      keypoints3d.resize (keypoints->size ());
-      keypoints3d.width = keypoints->width;
-      keypoints3d.height = keypoints->height;
-      keypoints3d.is_dense = true;
-
-      std::size_t j = 0;
-      for (std::size_t i = 0; i < keypoints->size (); ++i)
-      {
-        PointT pt = bilinearInterpolation (cloud, keypoints->points[i].x, keypoints->points[i].y);
-
-        keypoints3d.points[j].x = pt.x;
-        keypoints3d.points[j].y = pt.y;
-        keypoints3d.points[j].z = pt.z;
-        ++j;
-      }
+    PointCloud<KeyPointT>::Ptr keypoints;
+    CloudConstPtr cloud;
+    CloudPtr keypoints3d(new Cloud);
 
-      if (j != keypoints->size ())
-      {
-        keypoints3d.resize (j);
-        keypoints3d.width = j;
-        keypoints3d.height = 1;
-      }
-    }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    run ()
-    {
-      grabber_.start ();
-      
-      bool image_init = false, cloud_init = false;
-      bool keypts = true;
-
-      PointCloud<KeyPointT>::Ptr keypoints;
-      CloudConstPtr cloud;
-      CloudPtr keypoints3d (new Cloud);
-
-      while (!cloud_viewer_.wasStopped () && !image_viewer_.wasStopped ())
-      {
-        if (cloud_mutex_.try_lock ())
-        {
-          if (cloud_)
-            cloud_.swap (cloud);
-
-          if (keypoints_)
-            keypoints_.swap (keypoints);
-
-          cloud_mutex_.unlock ();
-
-          if (!cloud)
-            continue;
-
-          if (!cloud_init)
-          {
-            cloud_viewer_.setPosition (0, 0);
-            cloud_viewer_.setSize (cloud->width, cloud->height);
-            cloud_init = true;
-          }
-
-          if (!cloud_viewer_.updatePointCloud (cloud, "OpenNICloud"))
-          {
-            cloud_viewer_.addPointCloud (cloud, "OpenNICloud");
-            cloud_viewer_.resetCameraViewpoint ("OpenNICloud");
-          }
-
-          if (!image_init)
-          {
-            image_viewer_.setPosition (cloud->width, 0);
-            image_viewer_.setSize (cloud->width, cloud->height);
-            image_init = true;
-          }
-
-          image_viewer_.showRGBImage<PointT> (cloud);
-
-          image_viewer_.removeLayer (getStrBool (keypts));
-          for (std::size_t i = 0; i < keypoints->size (); ++i)
-          {
-            int u = int (keypoints->points[i].x);
-            int v = int (keypoints->points[i].y);
-            image_viewer_.markPoint (u, v, visualization::red_color, visualization::blue_color, 10, getStrBool (!keypts));
-          }
-          keypts = !keypts;
-
-          
-          get3DKeypoints (cloud, keypoints, *keypoints3d);
-          visualization::PointCloudColorHandlerCustom<PointT> blue (keypoints3d, 0, 0, 255);
-          if (!cloud_viewer_.updatePointCloud (keypoints3d, blue, "keypoints"))
-            cloud_viewer_.addPointCloud (keypoints3d, blue, "keypoints");
-          cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_POINT_SIZE, 10, "keypoints");
-          cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
+    while (!cloud_viewer_.wasStopped() && !image_viewer_.wasStopped()) {
+      if (cloud_mutex_.try_lock()) {
+        if (cloud_)
+          cloud_.swap(cloud);
+
+        if (keypoints_)
+          keypoints_.swap(keypoints);
+
+        cloud_mutex_.unlock();
+
+        if (!cloud)
+          continue;
+
+        if (!cloud_init) {
+          cloud_viewer_.setPosition(0, 0);
+          cloud_viewer_.setSize(cloud->width, cloud->height);
+          cloud_init = true;
+        }
+
+        if (!cloud_viewer_.updatePointCloud(cloud, "OpenNICloud")) {
+          cloud_viewer_.addPointCloud(cloud, "OpenNICloud");
+          cloud_viewer_.resetCameraViewpoint("OpenNICloud");
+        }
+
+        if (!image_init) {
+          image_viewer_.setPosition(cloud->width, 0);
+          image_viewer_.setSize(cloud->width, cloud->height);
+          image_init = true;
         }
 
-        cloud_viewer_.spinOnce ();
-        image_viewer_.spinOnce ();
-        std::this_thread::sleep_for(100us);
+        image_viewer_.showRGBImage<PointT>(cloud);
+
+        image_viewer_.removeLayer(getStrBool(keypts));
+        for (std::size_t i = 0; i < keypoints->size(); ++i) {
+          int u = int(keypoints->points[i].x);
+          int v = int(keypoints->points[i].y);
+          image_viewer_.markPoint(u,
+                                  v,
+                                  visualization::red_color,
+                                  visualization::blue_color,
+                                  10,
+                                  getStrBool(!keypts));
+        }
+        keypts = !keypts;
+
+        get3DKeypoints(cloud, keypoints, *keypoints3d);
+        visualization::PointCloudColorHandlerCustom<PointT> blue(
+            keypoints3d, 0, 0, 255);
+        if (!cloud_viewer_.updatePointCloud(keypoints3d, blue, "keypoints"))
+          cloud_viewer_.addPointCloud(keypoints3d, blue, "keypoints");
+        cloud_viewer_.setPointCloudRenderingProperties(
+            visualization::PCL_VISUALIZER_POINT_SIZE, 10, "keypoints");
+        cloud_viewer_.setPointCloudRenderingProperties(
+            visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
       }
 
-      grabber_.stop ();
-      
-      cloud_connection.disconnect ();
+      cloud_viewer_.spinOnce();
+      image_viewer_.spinOnce();
+      std::this_thread::sleep_for(100us);
     }
-    
-    visualization::PCLVisualizer cloud_viewer_;
-    Grabber& grabber_;
-    std::mutex cloud_mutex_;
-    CloudConstPtr cloud_;
-    
-    visualization::ImageViewer image_viewer_;
-
-    PointCloud<KeyPointT>::Ptr keypoints_;
-        
-  private:
-    boost::signals2::connection cloud_connection;
+
+    grabber_.stop();
+
+    cloud_connection.disconnect();
+  }
+
+  visualization::PCLVisualizer cloud_viewer_;
+  Grabber& grabber_;
+  std::mutex cloud_mutex_;
+  CloudConstPtr cloud_;
+
+  visualization::ImageViewer image_viewer_;
+
+  PointCloud<KeyPointT>::Ptr keypoints_;
+
+private:
+  boost::signals2::connection cloud_connection;
 };
 
 /* ---[ */
 int
-main (int, char**)
+main(int, char**)
 {
-  string device_id ("#1");
-  OpenNIGrabber grabber (device_id);
-  BRISKDemo openni_viewer (grabber);
-
-  openni_viewer.init ();
-  openni_viewer.run ();
-  
-  return (0);
+  string device_id("#1");
+  OpenNIGrabber grabber(device_id);
+  BRISKDemo openni_viewer(grabber);
+
+  openni_viewer.init();
+  openni_viewer.run();
+
+  return 0;
 }
 /* ]--- */
index 3b000d2e50df591699361d645df0c82e474e3527..f0fb49d74e187fc0e68b9f2a54ce4ee375918f4c 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2012, Willow Garage, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  */
 
 #include <pcl/apps/timer.h>
-#include <pcl/common/common.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/common.h>
 #include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/features/integral_image_normal.h>
+#include <pcl/filters/extract_indices.h>
+#include <pcl/geometry/polygon_operations.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
+#include <pcl/sample_consensus/sac_model_plane.h>
 #include <pcl/search/organized.h>
-#include <pcl/features/integral_image_normal.h>
-#include <pcl/filters/extract_indices.h>
+#include <pcl/segmentation/edge_aware_plane_comparator.h>
+#include <pcl/segmentation/euclidean_cluster_comparator.h>
+#include <pcl/segmentation/extract_polygonal_prism_data.h>
+#include <pcl/segmentation/organized_connected_component_segmentation.h>
 #include <pcl/segmentation/organized_multi_plane_segmentation.h>
 #include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/segmentation/extract_polygonal_prism_data.h>
-#include <pcl/sample_consensus/sac_model_plane.h>
 #include <pcl/surface/convex_hull.h>
-#include <pcl/visualization/point_cloud_handlers.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/image_viewer.h>
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
-#include <pcl/segmentation/euclidean_cluster_comparator.h>
-#include <pcl/segmentation/organized_connected_component_segmentation.h>
-#include <pcl/segmentation/edge_aware_plane_comparator.h>
-#include <pcl/geometry/polygon_operations.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/visualization/point_cloud_handlers.h>
 
 #include <mutex>
 #include <thread>
@@ -73,491 +73,527 @@ using PointT = PointXYZRGBA;
 #define SHOW_FPS 1
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class NILinemod
-{
-  public:
-    using Cloud = PointCloud<PointT>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-    bool added;
-
-    NILinemod (Grabber& grabber)
-      : cloud_viewer_ ("PointCloud")
-      , grabber_ (grabber)
-      , image_viewer_ ("Image")
-      , first_frame_ (true)
-    {
-      added = false;
-
-      // Set the parameters for normal estimation
-      ne_.setNormalEstimationMethod (ne_.COVARIANCE_MATRIX);
-      ne_.setMaxDepthChangeFactor (0.02f);
-      ne_.setNormalSmoothingSize (20.0f);
-
-      // Set the parameters for planar segmentation
-      plane_comparator_.reset (new EdgeAwarePlaneComparator<PointT, Normal>);
-        plane_comparator_->setDistanceThreshold (0.01f, false);
-      mps_.setMinInliers (5000);
-      mps_.setAngularThreshold (pcl::deg2rad (3.0)); // 3 degrees
-      mps_.setDistanceThreshold (0.02); // 2 cm
-      mps_.setMaximumCurvature (0.001); // a small curvature
-      mps_.setProjectPoints (true);
-      mps_.setComparator (plane_comparator_);
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    void
-    cloud_callback (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      cloud_ = cloud;
-      search_.setInputCloud (cloud);
-
-      // Subsequent frames are segmented by "tracking" the parameters of the previous frame
-      // We do this by using the estimated inliers from previous frames in the current frame, 
-      // and refining the coefficients
-
-      if (!first_frame_)
-      {
-        if (!plane_indices_ || plane_indices_->indices.empty () || !search_.getInputCloud ())
-        {
-          PCL_ERROR ("Lost tracking. Select the object again to continue.\n");
-          first_frame_ = true;
-          return;
-        }
-        SACSegmentation<PointT> seg;
-        seg.setOptimizeCoefficients (true);
-        seg.setModelType (SACMODEL_PLANE);
-        seg.setMethodType (SAC_RANSAC);
-        seg.setMaxIterations (1000);
-        seg.setDistanceThreshold (0.01);
-        seg.setInputCloud (search_.getInputCloud ());
-        seg.setIndices (plane_indices_);
-        ModelCoefficients coefficients;
-        PointIndices inliers;
-        seg.segment (inliers, coefficients);
-
-        if (inliers.indices.empty ())
-        {
-          PCL_ERROR ("No planar model found. Select the object again to continue.\n");
-          first_frame_ = true;
-          return;
-        }
+class NILinemod {
+public:
+  using Cloud = PointCloud<PointT>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+  bool added;
+
+  NILinemod(Grabber& grabber)
+  : cloud_viewer_("PointCloud")
+  , grabber_(grabber)
+  , image_viewer_("Image")
+  , first_frame_(true)
+  {
+    added = false;
+
+    // Set the parameters for normal estimation
+    ne_.setNormalEstimationMethod(ne_.COVARIANCE_MATRIX);
+    ne_.setMaxDepthChangeFactor(0.02f);
+    ne_.setNormalSmoothingSize(20.0f);
+
+    // Set the parameters for planar segmentation
+    plane_comparator_.reset(new EdgeAwarePlaneComparator<PointT, Normal>);
+    plane_comparator_->setDistanceThreshold(0.01f, false);
+    mps_.setMinInliers(5000);
+    mps_.setAngularThreshold(pcl::deg2rad(3.0)); // 3 degrees
+    mps_.setDistanceThreshold(0.02);             // 2 cm
+    mps_.setMaximumCurvature(0.001);             // a small curvature
+    mps_.setProjectPoints(true);
+    mps_.setComparator(plane_comparator_);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  cloud_callback(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+    search_.setInputCloud(cloud);
+
+    // Subsequent frames are segmented by "tracking" the parameters of the previous
+    // frame We do this by using the estimated inliers from previous frames in the
+    // current frame, and refining the coefficients
+
+    if (!first_frame_) {
+      if (!plane_indices_ || plane_indices_->indices.empty() ||
+          !search_.getInputCloud()) {
+        PCL_ERROR("Lost tracking. Select the object again to continue.\n");
+        first_frame_ = true;
+        return;
+      }
+      SACSegmentation<PointT> seg;
+      seg.setOptimizeCoefficients(true);
+      seg.setModelType(SACMODEL_PLANE);
+      seg.setMethodType(SAC_RANSAC);
+      seg.setMaxIterations(1000);
+      seg.setDistanceThreshold(0.01);
+      seg.setInputCloud(search_.getInputCloud());
+      seg.setIndices(plane_indices_);
+      ModelCoefficients coefficients;
+      PointIndices inliers;
+      seg.segment(inliers, coefficients);
+
+      if (inliers.indices.empty()) {
+        PCL_ERROR("No planar model found. Select the object again to continue.\n");
+        first_frame_ = true;
+        return;
+      }
 
-        // Visualize the object in 3D...
-        CloudPtr plane_inliers (new Cloud);
-        pcl::copyPointCloud (*search_.getInputCloud (), inliers.indices, *plane_inliers);
-        if (plane_inliers->points.empty ())
-        {
-          PCL_ERROR ("No planar model found. Select the object again to continue.\n");
-          first_frame_ = true;
-          return;
-        }
-        plane_.reset (new Cloud);
+      // Visualize the object in 3D...
+      CloudPtr plane_inliers(new Cloud);
+      pcl::copyPointCloud(*search_.getInputCloud(), inliers.indices, *plane_inliers);
+      if (plane_inliers->points.empty()) {
+        PCL_ERROR("No planar model found. Select the object again to continue.\n");
+        first_frame_ = true;
+        return;
+      }
+      plane_.reset(new Cloud);
 
-        // Compute the convex hull of the plane
-        ConvexHull<PointT> chull;
-        chull.setDimension (2);
-        chull.setInputCloud (plane_inliers);
-        chull.reconstruct (*plane_);
+      // Compute the convex hull of the plane
+      ConvexHull<PointT> chull;
+      chull.setDimension(2);
+      chull.setInputCloud(plane_inliers);
+      chull.reconstruct(*plane_);
+    }
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  CloudConstPtr
+  getLatestCloud()
+  {
+    // Lock while we swap our cloud and reset it.
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    CloudConstPtr temp_cloud;
+    temp_cloud.swap(cloud_);
+    return temp_cloud;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  keyboard_callback(const visualization::KeyboardEvent&, void*)
+  {
+    // if (event.getKeyCode())
+    //  std::cout << "the key \'" << event.getKeyCode() << "\' (" << event.getKeyCode()
+    //  << ") was";
+    // else
+    //  std::cout << "the special key \'" << event.getKeySym() << "\' was";
+    // if (event.keyDown())
+    //  std::cout << " pressed" << std::endl;
+    // else
+    //  std::cout << " released" << std::endl;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  mouse_callback(const visualization::MouseEvent&, void*)
+  {
+    // if (mouse_event.getType() == visualization::MouseEvent::MouseButtonPress &&
+    // mouse_event.getButton() == visualization::MouseEvent::LeftButton)
+    //{
+    //  std::cout << "left button pressed @ " << mouse_event.getX () << " , " <<
+    //  mouse_event.getY () << std::endl;
+    //}
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  /**
+   * \brief Given a plane, and the set of inlier indices representing it,
+   * segment out the object of intererest supported by it.
+   *
+   * \param[in] picked_idx the index of a point on the object
+   * \param[in] cloud the full point cloud dataset
+   * \param[in] plane_indices a set of indices representing the plane supporting the
+   * object of interest
+   * \param[in] plane_boundary_indices a set of indices representing
+   * the boundary of the plane
+   * \param[out] object the segmented resultant object
+   */
+  void
+  segmentObject(int picked_idx,
+                const CloudConstPtr& cloud,
+                const PointIndices::Ptr& plane_indices,
+                const PointIndices::Ptr& plane_boundary_indices,
+                Cloud& object)
+  {
+    CloudPtr plane_hull(new Cloud);
+
+    // Compute the convex hull of the plane
+    ConvexHull<PointT> chull;
+    chull.setDimension(2);
+    chull.setInputCloud(cloud);
+    chull.setIndices(plane_boundary_indices);
+    chull.reconstruct(*plane_hull);
+
+    // Remove the plane indices from the data
+    PointIndices::Ptr everything_but_the_plane(new PointIndices);
+    if (indices_fullset_.size() != cloud->points.size()) {
+      indices_fullset_.resize(cloud->points.size());
+      for (int p_it = 0; p_it < static_cast<int>(indices_fullset_.size()); ++p_it)
+        indices_fullset_[p_it] = p_it;
+    }
+    std::vector<int> indices_subset = plane_indices->indices;
+    std::sort(indices_subset.begin(), indices_subset.end());
+    set_difference(indices_fullset_.begin(),
+                   indices_fullset_.end(),
+                   indices_subset.begin(),
+                   indices_subset.end(),
+                   inserter(everything_but_the_plane->indices,
+                            everything_but_the_plane->indices.begin()));
+
+    // Extract all clusters above the hull
+    PointIndices::Ptr points_above_plane(new PointIndices);
+    ExtractPolygonalPrismData<PointT> exppd;
+    exppd.setInputCloud(cloud);
+    exppd.setInputPlanarHull(plane_hull);
+    exppd.setIndices(everything_but_the_plane);
+    exppd.setHeightLimits(0.0, 0.5); // up to half a meter
+    exppd.segment(*points_above_plane);
+
+    // Use an organized clustering segmentation to extract the individual clusters
+    EuclideanClusterComparator<PointT, Label>::Ptr euclidean_cluster_comparator(
+        new EuclideanClusterComparator<PointT, Label>);
+    euclidean_cluster_comparator->setInputCloud(cloud);
+    euclidean_cluster_comparator->setDistanceThreshold(0.03f, false);
+    // Set the entire scene to false, and the inliers of the objects located on top of
+    // the plane to true
+    Label l;
+    l.label = 0;
+    PointCloud<Label>::Ptr scene(new PointCloud<Label>(cloud->width, cloud->height, l));
+    // Mask the objects that we want to split into clusters
+    for (const int& index : points_above_plane->indices)
+      scene->points[index].label = 1;
+    euclidean_cluster_comparator->setLabels(scene);
+
+    OrganizedConnectedComponentSegmentation<PointT, Label> euclidean_segmentation(
+        euclidean_cluster_comparator);
+    euclidean_segmentation.setInputCloud(cloud);
+
+    PointCloud<Label> euclidean_labels;
+    std::vector<PointIndices> euclidean_label_indices;
+    euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices);
+
+    // For each cluster found
+    bool cluster_found = false;
+    for (const auto& euclidean_label_index : euclidean_label_indices) {
+      if (cluster_found)
+        break;
+      // Check if the point that we picked belongs to it
+      for (std::size_t j = 0; j < euclidean_label_index.indices.size(); ++j) {
+        if (picked_idx != euclidean_label_index.indices[j])
+          continue;
+        // pcl::PointCloud<PointT> cluster;
+        pcl::copyPointCloud(*cloud, euclidean_label_index.indices, object);
+        cluster_found = true;
+        break;
+        // object_indices = euclidean_label_indices[i].indices;
+        // clusters.push_back (cluster);
+      }
+    }
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  segment(const PointT& picked_point,
+          int picked_idx,
+          PlanarRegion<PointT>& region,
+          PointIndices&,
+          CloudPtr& object)
+  {
+    // First frame is segmented using an organized multi plane segmentation approach
+    // from points and their normals
+    if (!first_frame_)
+      return;
+
+    // Estimate normals in the cloud
+    PointCloud<Normal>::Ptr normal_cloud(new PointCloud<Normal>);
+    ne_.setInputCloud(search_.getInputCloud());
+    ne_.compute(*normal_cloud);
+
+    plane_comparator_->setDistanceMap(ne_.getDistanceMap());
+
+    // Segment out all planes
+    mps_.setInputNormals(normal_cloud);
+    mps_.setInputCloud(search_.getInputCloud());
+
+    // Use one of the overloaded segmentAndRefine calls to get all the information that
+    // we want out
+    std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT>>>
+        regions;
+    std::vector<ModelCoefficients> model_coefficients;
+    std::vector<PointIndices> inlier_indices;
+    PointCloud<Label>::Ptr labels(new PointCloud<Label>);
+    std::vector<PointIndices> label_indices;
+    std::vector<PointIndices> boundary_indices;
+    mps_.segmentAndRefine(regions,
+                          model_coefficients,
+                          inlier_indices,
+                          labels,
+                          label_indices,
+                          boundary_indices);
+    PCL_DEBUG("Number of planar regions detected: %lu for a cloud of %lu points and "
+              "%lu normals.\n",
+              regions.size(),
+              search_.getInputCloud()->points.size(),
+              normal_cloud->points.size());
+
+    double max_dist = std::numeric_limits<double>::max();
+    // Compute the distances from all the planar regions to the picked point, and select
+    // the closest region
+    int idx = -1;
+    for (std::size_t i = 0; i < regions.size(); ++i) {
+      double dist = pointToPlaneDistance(picked_point, regions[i].getCoefficients());
+      if (dist < max_dist) {
+        max_dist = dist;
+        idx = static_cast<int>(i);
       }
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    CloudConstPtr
-    getLatestCloud ()
-    {
-      // Lock while we swap our cloud and reset it.
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      CloudConstPtr temp_cloud;
-      temp_cloud.swap (cloud_);
-      return (temp_cloud);
+    PointIndices::Ptr plane_boundary_indices;
+    // Get the plane that holds the object of interest
+    if (idx != -1) {
+      region = regions[idx];
+      plane_indices_.reset(new PointIndices(inlier_indices[idx]));
+      plane_boundary_indices.reset(new PointIndices(boundary_indices[idx]));
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    void 
-    keyboard_callback (const visualization::KeyboardEvent&, void*)
-    {
-      //if (event.getKeyCode())
-      //  std::cout << "the key \'" << event.getKeyCode() << "\' (" << event.getKeyCode() << ") was";
-      //else
-      //  std::cout << "the special key \'" << event.getKeySym() << "\' was";
-      //if (event.keyDown())
-      //  std::cout << " pressed" << std::endl;
-      //else
-      //  std::cout << " released" << std::endl;
+    // Segment the object of interest
+    if (plane_boundary_indices && !plane_boundary_indices->indices.empty()) {
+      object.reset(new Cloud);
+      segmentObject(picked_idx,
+                    search_.getInputCloud(),
+                    plane_indices_,
+                    plane_boundary_indices,
+                    *object);
+
+      // Save to disk
+      // pcl::io::saveTARPointCloud ("output.ltm", *object, "object.pcd");
     }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void 
-    mouse_callback (const visualization::MouseEvent&, void*)
-    {
-      //if (mouse_event.getType() == visualization::MouseEvent::MouseButtonPress && mouse_event.getButton() == visualization::MouseEvent::LeftButton)
-      //{
-      //  std::cout << "left button pressed @ " << mouse_event.getX () << " , " << mouse_event.getY () << std::endl;
-      //}
+    first_frame_ = false;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  /**
+   * \brief Point picking callback. This gets called when the user selects
+   * a 3D point on screen (in the PCLVisualizer window) using Shift+click.
+   *
+   * \param[in] event the event that triggered the call
+   */
+  void
+  pp_callback(const visualization::PointPickingEvent& event, void*)
+  {
+    // Check to see if we got a valid point. Early exit.
+    int idx = event.getPointIndex();
+    if (idx == -1)
+      return;
+
+    std::vector<int> indices(1);
+    std::vector<float> distances(1);
+
+    // Use mutices to make sure we get the right cloud
+    std::lock_guard<std::mutex> lock1(cloud_mutex_);
+
+    // Get the point that was picked
+    PointT picked_pt;
+    event.getPoint(picked_pt.x, picked_pt.y, picked_pt.z);
+
+    // Add a sphere to it in the PCLVisualizer window
+    stringstream ss;
+    ss << "sphere_" << idx;
+    cloud_viewer_.addSphere(picked_pt, 0.01, 1.0, 0.0, 0.0, ss.str());
+
+    // Check to see if we have access to the actual cloud data. Use the previously built
+    // search object.
+    if (!search_.isValid())
+      return;
+
+    // Because VTK/OpenGL stores data without NaN, we lose the 1-1 correspondence, so we
+    // must search for the real point
+    search_.nearestKSearch(picked_pt, 1, indices, distances);
+
+    // Get the [u, v] in pixel coordinates for the ImageViewer. Remember that 0,0 is
+    // bottom left.
+    std::uint32_t width = search_.getInputCloud()->width;
+    //               height = search_.getInputCloud ()->height;
+    int v = indices[0] / width, u = indices[0] % width;
+
+    // Add some marker to the image
+    image_viewer_.addCircle(u, v, 5, 1.0, 0.0, 0.0, "circles", 1.0);
+    image_viewer_.addFilledRectangle(
+        u - 5, u + 5, v - 5, v + 5, 0.0, 1.0, 0.0, "boxes", 0.5);
+    image_viewer_.markPoint(
+        u, v, visualization::red_color, visualization::blue_color, 10);
+
+    // Segment the region that we're interested in, by employing a two step process:
+    //  * first, segment all the planes in the scene, and find the one closest to our
+    //  picked point
+    //  * then, use euclidean clustering to find the object that we clicked on and
+    //  return it
+    PlanarRegion<PointT> region;
+    CloudPtr object;
+    PointIndices region_indices;
+    segment(picked_pt, indices[0], region, region_indices, object);
+
+    // If no region could be determined, exit
+    if (region.getContour().empty()) {
+      PCL_ERROR("No planar region detected. Please select another point or relax the "
+                "thresholds and continue.\n");
+      return;
     }
-
-    /////////////////////////////////////////////////////////////////////////
-    /** \brief Given a plane, and the set of inlier indices representing it,
-      * segment out the object of intererest supported by it. 
-      *
-      * \param[in] picked_idx the index of a point on the object
-      * \param[in] cloud the full point cloud dataset
-      * \param[in] plane_indices a set of indices representing the plane supporting the object of interest
-      * \param[in] plane_boundary_indices a set of indices representing the boundary of the plane
-      * \param[out] object the segmented resultant object 
-      */
-    void
-    segmentObject (int picked_idx, 
-                   const CloudConstPtr &cloud, 
-                   const PointIndices::Ptr &plane_indices, 
-                   const PointIndices::Ptr &plane_boundary_indices, 
-                   Cloud &object)
-    {
-      CloudPtr plane_hull (new Cloud);
-
-      // Compute the convex hull of the plane
-      ConvexHull<PointT> chull;
-      chull.setDimension (2);
-      chull.setInputCloud (cloud);
-      chull.setIndices (plane_boundary_indices);
-      chull.reconstruct (*plane_hull);
-
-      // Remove the plane indices from the data
-      PointIndices::Ptr everything_but_the_plane (new PointIndices);
-      if (indices_fullset_.size () != cloud->points.size ())
-      {
-        indices_fullset_.resize (cloud->points.size ());
-        for (int p_it = 0; p_it < static_cast<int> (indices_fullset_.size ()); ++p_it)
-          indices_fullset_[p_it] = p_it;
-      }
-      std::vector<int> indices_subset = plane_indices->indices;
-      std::sort (indices_subset.begin (), indices_subset.end ());
-      set_difference (indices_fullset_.begin (), indices_fullset_.end (), 
-                      indices_subset.begin (), indices_subset.end (), 
-                      inserter (everything_but_the_plane->indices, everything_but_the_plane->indices.begin ()));
-
-      // Extract all clusters above the hull
-      PointIndices::Ptr points_above_plane (new PointIndices);
-      ExtractPolygonalPrismData<PointT> exppd;
-      exppd.setInputCloud (cloud);
-      exppd.setInputPlanarHull (plane_hull);
-      exppd.setIndices (everything_but_the_plane);
-      exppd.setHeightLimits (0.0, 0.5);           // up to half a meter
-      exppd.segment (*points_above_plane);
-
-      // Use an organized clustering segmentation to extract the individual clusters
-      EuclideanClusterComparator<PointT, Label>::Ptr euclidean_cluster_comparator (new EuclideanClusterComparator<PointT, Label>);
-      euclidean_cluster_comparator->setInputCloud (cloud);
-      euclidean_cluster_comparator->setDistanceThreshold (0.03f, false);
-      // Set the entire scene to false, and the inliers of the objects located on top of the plane to true
-      Label l; l.label = 0;
-      PointCloud<Label>::Ptr scene (new PointCloud<Label> (cloud->width, cloud->height, l));
-      // Mask the objects that we want to split into clusters
-      for (const int &index : points_above_plane->indices)
-        scene->points[index].label = 1;
-      euclidean_cluster_comparator->setLabels (scene);
-
-      OrganizedConnectedComponentSegmentation<PointT, Label> euclidean_segmentation (euclidean_cluster_comparator);
-      euclidean_segmentation.setInputCloud (cloud);
-
-      PointCloud<Label> euclidean_labels;
-      std::vector<PointIndices> euclidean_label_indices;
-      euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices);
-
-      // For each cluster found
-      bool cluster_found = false;
-      for (const auto &euclidean_label_index : euclidean_label_indices)
-      {
-        if (cluster_found)
-          break;
-        // Check if the point that we picked belongs to it
-        for (std::size_t j = 0; j < euclidean_label_index.indices.size (); ++j)
-        {
-          if (picked_idx != euclidean_label_index.indices[j])
-            continue;
-          //pcl::PointCloud<PointT> cluster;
-          pcl::copyPointCloud (*cloud, euclidean_label_index.indices, object);
-          cluster_found = true;
-          break;
-          //object_indices = euclidean_label_indices[i].indices;
-          //clusters.push_back (cluster);
-        }
-      }
+    // Else, draw it on screen
+    // cloud_viewer_.addPolygon (region, 1.0, 0.0, 0.0, "region");
+    // cloud_viewer_.setShapeRenderingProperties
+    // (visualization::PCL_VISUALIZER_LINE_WIDTH, 10, "region");
+
+    PlanarRegion<PointT> refined_region;
+    pcl::approximatePolygon(region, refined_region, 0.01, false, true);
+    PCL_INFO("Planar region: %lu points initial, %lu points after refinement.\n",
+             region.getContour().size(),
+             refined_region.getContour().size());
+    cloud_viewer_.addPolygon(refined_region, 0.0, 0.0, 1.0, "refined_region");
+    cloud_viewer_.setShapeRenderingProperties(
+        visualization::PCL_VISUALIZER_LINE_WIDTH, 10, "refined_region");
+
+    // Draw in image space
+    image_viewer_.addPlanarPolygon(
+        search_.getInputCloud(), refined_region, 0.0, 0.0, 1.0, "refined_region", 1.0);
+
+    // If no object could be determined, exit
+    if (!object) {
+      PCL_ERROR("No object detected. Please select another point or relax the "
+                "thresholds and continue.\n");
+      return;
     }
+    // Visualize the object in 3D...
+    visualization::PointCloudColorHandlerCustom<PointT> red(object, 255, 0, 0);
+    if (!cloud_viewer_.updatePointCloud(object, red, "object"))
+      cloud_viewer_.addPointCloud(object, red, "object");
+    // ...and 2D
+    image_viewer_.removeLayer("object");
+    image_viewer_.addMask(search_.getInputCloud(), *object, "object");
+
+    // Compute the min/max of the object
+    PointT min_pt, max_pt;
+    getMinMax3D(*object, min_pt, max_pt);
+    stringstream ss2;
+    ss2 << "cube_" << idx;
+    // Visualize the bounding box in 3D...
+    cloud_viewer_.addCube(min_pt.x,
+                          max_pt.x,
+                          min_pt.y,
+                          max_pt.y,
+                          min_pt.z,
+                          max_pt.z,
+                          0.0,
+                          1.0,
+                          0.0,
+                          ss2.str());
+    cloud_viewer_.setShapeRenderingProperties(
+        visualization::PCL_VISUALIZER_LINE_WIDTH, 10, ss2.str());
+
+    // ...and 2D
+    image_viewer_.addRectangle(search_.getInputCloud(), *object);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  init()
+  {
+    cloud_viewer_.registerMouseCallback(&NILinemod::mouse_callback, *this);
+    cloud_viewer_.registerKeyboardCallback(&NILinemod::keyboard_callback, *this);
+    cloud_viewer_.registerPointPickingCallback(&NILinemod::pp_callback, *this);
+    std::function<void(const CloudConstPtr&)> cloud_cb =
+        [this](const CloudConstPtr& cloud) { cloud_callback(cloud); };
+    cloud_connection = grabber_.registerCallback(cloud_cb);
+
+    image_viewer_.registerMouseCallback(&NILinemod::mouse_callback, *this);
+    image_viewer_.registerKeyboardCallback(&NILinemod::keyboard_callback, *this);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  run()
+  {
+    grabber_.start();
+
+    bool image_init = false, cloud_init = false;
+
+    while (!cloud_viewer_.wasStopped() && !image_viewer_.wasStopped()) {
+      if (cloud_) {
+        CloudConstPtr cloud = getLatestCloud();
+        if (!cloud_init) {
+          cloud_viewer_.setPosition(0, 0);
+          cloud_viewer_.setSize(cloud->width, cloud->height);
+          cloud_init = true;
+        }
 
+        if (!cloud_viewer_.updatePointCloud(cloud, "OpenNICloud")) {
+          cloud_viewer_.addPointCloud(cloud, "OpenNICloud");
+          cloud_viewer_.resetCameraViewpoint("OpenNICloud");
+        }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    segment (const PointT &picked_point, 
-             int picked_idx,
-             PlanarRegion<PointT> &region,
-             PointIndices &,
-             CloudPtr &object)
-    {
-      // First frame is segmented using an organized multi plane segmentation approach from points and their normals
-      if (!first_frame_)
-        return;
-
-      // Estimate normals in the cloud
-      PointCloud<Normal>::Ptr normal_cloud (new PointCloud<Normal>);
-      ne_.setInputCloud (search_.getInputCloud ());
-      ne_.compute (*normal_cloud);
-
-      plane_comparator_->setDistanceMap (ne_.getDistanceMap ());
-
-      // Segment out all planes
-      mps_.setInputNormals (normal_cloud);
-      mps_.setInputCloud (search_.getInputCloud ());
-
-      // Use one of the overloaded segmentAndRefine calls to get all the information that we want out
-      std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT> > > regions;
-      std::vector<ModelCoefficients> model_coefficients;
-      std::vector<PointIndices> inlier_indices;  
-      PointCloud<Label>::Ptr labels (new PointCloud<Label>);
-      std::vector<PointIndices> label_indices;
-      std::vector<PointIndices> boundary_indices;
-      mps_.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);
-      PCL_DEBUG ("Number of planar regions detected: %lu for a cloud of %lu points and %lu normals.\n", regions.size (), search_.getInputCloud ()->points.size (), normal_cloud->points.size ());
-
-      double max_dist = std::numeric_limits<double>::max ();
-      // Compute the distances from all the planar regions to the picked point, and select the closest region
-      int idx = -1;
-      for (std::size_t i = 0; i < regions.size (); ++i)
-      {
-        double dist = pointToPlaneDistance (picked_point, regions[i].getCoefficients ()); 
-        if (dist < max_dist)
-        {
-          max_dist = dist;
-          idx = static_cast<int> (i);
+        if (!image_init) {
+          image_viewer_.setPosition(cloud->width, 0);
+          image_viewer_.setSize(cloud->width, cloud->height);
+          image_init = true;
         }
-      }
 
-      PointIndices::Ptr plane_boundary_indices;
-      // Get the plane that holds the object of interest
-      if (idx != -1)
-      {
-        region = regions[idx]; 
-        plane_indices_.reset (new PointIndices (inlier_indices[idx]));
-        plane_boundary_indices.reset (new PointIndices (boundary_indices[idx]));
+        image_viewer_.showRGBImage<PointT>(cloud);
       }
 
-      // Segment the object of interest
-      if (plane_boundary_indices && !plane_boundary_indices->indices.empty ())
-      {
-        object.reset (new Cloud);
-        segmentObject (picked_idx, search_.getInputCloud (), plane_indices_, plane_boundary_indices, *object);
-
-        // Save to disk
-        //pcl::io::saveTARPointCloud ("output.ltm", *object, "object.pcd");
-      }
-      first_frame_ = false;
+      // Add the plane that we're tracking to the cloud visualizer
+      CloudPtr plane(new Cloud);
+      if (plane_)
+        *plane = *plane_;
+      visualization::PointCloudColorHandlerCustom<PointT> blue(plane, 0, 255, 0);
+      if (!cloud_viewer_.updatePointCloud(plane, blue, "plane"))
+        cloud_viewer_.addPointCloud(plane, "plane");
+      cloud_viewer_.spinOnce();
+
+      image_viewer_.spinOnce();
+      std::this_thread::sleep_for(100us);
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    /** \brief Point picking callback. This gets called when the user selects
-      * a 3D point on screen (in the PCLVisualizer window) using Shift+click.
-      *
-      * \param[in] event the event that triggered the call
-      */
-    void 
-    pp_callback (const visualization::PointPickingEvent& event, void*)
-    {
-      // Check to see if we got a valid point. Early exit.
-      int idx = event.getPointIndex ();
-      if (idx == -1)
-        return;
-
-      std::vector<int> indices (1);
-      std::vector<float> distances (1);
+    grabber_.stop();
 
-      // Use mutices to make sure we get the right cloud
-      std::lock_guard<std::mutex> lock1 (cloud_mutex_);
+    cloud_connection.disconnect();
+  }
 
-      // Get the point that was picked
-      PointT picked_pt;
-      event.getPoint (picked_pt.x, picked_pt.y, picked_pt.z);
+  visualization::PCLVisualizer cloud_viewer_;
+  Grabber& grabber_;
+  std::mutex cloud_mutex_;
+  CloudConstPtr cloud_;
 
-      // Add a sphere to it in the PCLVisualizer window
-      stringstream ss;
-      ss << "sphere_" << idx;
-      cloud_viewer_.addSphere (picked_pt, 0.01, 1.0, 0.0, 0.0, ss.str ());
+  visualization::ImageViewer image_viewer_;
 
-      // Check to see if we have access to the actual cloud data. Use the previously built search object.
-      if (!search_.isValid ())
-        return;
+  search::OrganizedNeighbor<PointT> search_;
 
-      // Because VTK/OpenGL stores data without NaN, we lose the 1-1 correspondence, so we must search for the real point
-      search_.nearestKSearch (picked_pt, 1, indices, distances);
-
-      // Get the [u, v] in pixel coordinates for the ImageViewer. Remember that 0,0 is bottom left.
-      std::uint32_t width  = search_.getInputCloud ()->width;
-//               height = search_.getInputCloud ()->height;
-      int v = indices[0] / width,
-          u = indices[0] % width;
-
-      // Add some marker to the image
-      image_viewer_.addCircle (u, v, 5, 1.0, 0.0, 0.0, "circles", 1.0);
-      image_viewer_.addFilledRectangle (u-5, u+5, v-5, v+5, 0.0, 1.0, 0.0, "boxes", 0.5);
-      image_viewer_.markPoint (u, v, visualization::red_color, visualization::blue_color, 10);
-
-      // Segment the region that we're interested in, by employing a two step process:
-      //  * first, segment all the planes in the scene, and find the one closest to our picked point
-      //  * then, use euclidean clustering to find the object that we clicked on and return it
-      PlanarRegion<PointT> region;
-      CloudPtr object;
-      PointIndices region_indices;
-      segment (picked_pt, indices[0], region, region_indices, object);
-
-      // If no region could be determined, exit
-      if (region.getContour ().empty ())
-      {
-        PCL_ERROR ("No planar region detected. Please select another point or relax the thresholds and continue.\n");
-        return;
-      }
-      // Else, draw it on screen
-      //cloud_viewer_.addPolygon (region, 1.0, 0.0, 0.0, "region");
-      //cloud_viewer_.setShapeRenderingProperties (visualization::PCL_VISUALIZER_LINE_WIDTH, 10, "region");
-
-      PlanarRegion<PointT> refined_region;
-      pcl::approximatePolygon (region, refined_region, 0.01, false, true);
-      PCL_INFO ("Planar region: %lu points initial, %lu points after refinement.\n", region.getContour ().size (), refined_region.getContour ().size ());
-      cloud_viewer_.addPolygon (refined_region, 0.0, 0.0, 1.0, "refined_region");
-      cloud_viewer_.setShapeRenderingProperties (visualization::PCL_VISUALIZER_LINE_WIDTH, 10, "refined_region");
-
-      // Draw in image space
-      image_viewer_.addPlanarPolygon (search_.getInputCloud (), refined_region, 0.0, 0.0, 1.0, "refined_region", 1.0);
-
-      // If no object could be determined, exit
-      if (!object)
-      {
-        PCL_ERROR ("No object detected. Please select another point or relax the thresholds and continue.\n");
-        return;
-      }
-      // Visualize the object in 3D...
-      visualization::PointCloudColorHandlerCustom<PointT> red (object, 255, 0, 0);
-      if (!cloud_viewer_.updatePointCloud (object, red, "object"))
-        cloud_viewer_.addPointCloud (object, red, "object");
-      // ...and 2D
-      image_viewer_.removeLayer ("object");
-      image_viewer_.addMask (search_.getInputCloud (), *object, "object");
-
-      // Compute the min/max of the object
-      PointT min_pt, max_pt;
-      getMinMax3D (*object, min_pt, max_pt);
-      stringstream ss2;
-      ss2 << "cube_" << idx;
-      // Visualize the bounding box in 3D...
-      cloud_viewer_.addCube (min_pt.x, max_pt.x, min_pt.y, max_pt.y, min_pt.z, max_pt.z, 0.0, 1.0, 0.0, ss2.str ());
-      cloud_viewer_.setShapeRenderingProperties (visualization::PCL_VISUALIZER_LINE_WIDTH, 10, ss2.str ());
-
-      // ...and 2D
-      image_viewer_.addRectangle (search_.getInputCloud (), *object);
-    }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    init ()
-    {
-      cloud_viewer_.registerMouseCallback (&NILinemod::mouse_callback, *this);
-      cloud_viewer_.registerKeyboardCallback(&NILinemod::keyboard_callback, *this);
-      cloud_viewer_.registerPointPickingCallback (&NILinemod::pp_callback, *this);
-      std::function<void (const CloudConstPtr&) > cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback (cloud); };
-      cloud_connection = grabber_.registerCallback (cloud_cb);
-      
-      image_viewer_.registerMouseCallback (&NILinemod::mouse_callback, *this);
-      image_viewer_.registerKeyboardCallback(&NILinemod::keyboard_callback, *this);
-    }
+private:
+  boost::signals2::connection cloud_connection, image_connection;
+  bool first_frame_;
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    run ()
-    {
-      grabber_.start ();
-      
-      bool image_init = false, cloud_init = false;
-
-      while (!cloud_viewer_.wasStopped () && !image_viewer_.wasStopped ())
-      {
-        if (cloud_)
-        {
-          CloudConstPtr cloud = getLatestCloud ();
-          if (!cloud_init)
-          {
-            cloud_viewer_.setPosition (0, 0);
-            cloud_viewer_.setSize (cloud->width, cloud->height);
-            cloud_init = true;
-          }
-
-          if (!cloud_viewer_.updatePointCloud (cloud, "OpenNICloud"))
-          {
-            cloud_viewer_.addPointCloud (cloud, "OpenNICloud");
-            cloud_viewer_.resetCameraViewpoint ("OpenNICloud");
-          }
-
-          if (!image_init)
-          {
-            image_viewer_.setPosition (cloud->width, 0);
-            image_viewer_.setSize (cloud->width, cloud->height);
-            image_init = true;
-          }
-
-          image_viewer_.showRGBImage<PointT> (cloud);
-        }
-
-
-        // Add the plane that we're tracking to the cloud visualizer
-        CloudPtr plane (new Cloud);
-        if (plane_)
-          *plane = *plane_;
-        visualization::PointCloudColorHandlerCustom<PointT> blue (plane, 0, 255, 0);
-        if (!cloud_viewer_.updatePointCloud (plane, blue, "plane"))
-          cloud_viewer_.addPointCloud (plane, "plane");
-        cloud_viewer_.spinOnce ();
-
-        image_viewer_.spinOnce ();
-        std::this_thread::sleep_for(100us);
-      }
-
-      grabber_.stop ();
-      
-      cloud_connection.disconnect ();
-    }
-    
-    visualization::PCLVisualizer cloud_viewer_;
-    Grabber& grabber_;
-    std::mutex cloud_mutex_;
-    CloudConstPtr cloud_;
-    
-    visualization::ImageViewer image_viewer_;
-
-    search::OrganizedNeighbor<PointT> search_;
-  private:
-    boost::signals2::connection cloud_connection, image_connection;
-    bool first_frame_;
-    
-    // Segmentation
-    std::vector<int> indices_fullset_;
-    PointIndices::Ptr plane_indices_;
-    CloudPtr plane_;
-    IntegralImageNormalEstimation<PointT, Normal> ne_;
-    OrganizedMultiPlaneSegmentation<PointT, Normal, Label> mps_;
-    EdgeAwarePlaneComparator<PointT, Normal>::Ptr plane_comparator_;
+  // Segmentation
+  std::vector<int> indices_fullset_;
+  PointIndices::Ptr plane_indices_;
+  CloudPtr plane_;
+  IntegralImageNormalEstimation<PointT, Normal> ne_;
+  OrganizedMultiPlaneSegmentation<PointT, Normal, Label> mps_;
+  EdgeAwarePlaneComparator<PointT, Normal>::Ptr plane_comparator_;
 };
 
 /* ---[ */
 int
-main (int, char**)
+main(int, char**)
 {
-  string device_id ("#1");
-  OpenNIGrabber grabber (device_id);
-  NILinemod openni_viewer (grabber);
-
-  openni_viewer.init ();
-  openni_viewer.run ();
-  
-  return (0);
+  string device_id("#1");
+  OpenNIGrabber grabber(device_id);
+  NILinemod openni_viewer(grabber);
+
+  openni_viewer.init();
+  openni_viewer.run();
+
+  return 0;
 }
 /* ]--- */
index fd62704309f4e4576ebb79f5ac5285d059161266..f5b411102765298d3d739b40b86c11442a7efe56 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
 #define SHOW_FPS 1
 
 #include <pcl/apps/timer.h>
-#include <pcl/common/common.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/common.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/filters/extract_indices.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/keypoints/susan.h>
-#include <pcl/filters/extract_indices.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/image_viewer.h>
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
+#include <pcl/visualization/pcl_visualizer.h>
 
 #include <mutex>
 #include <thread>
@@ -62,152 +62,151 @@ using PointT = PointXYZRGBA;
 using KeyPointT = PointXYZRGBL;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class SUSANDemo
-{
-  public:
-    using Cloud = PointCloud<PointT>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-    SUSANDemo (Grabber& grabber)
-      : cloud_viewer_ ("SUSAN 2D Keypoints -- PointCloud")
-      , grabber_ (grabber)
-      , image_viewer_ ("SUSAN 2D Keypoints -- Image")
-    {
-    }
+class SUSANDemo {
+public:
+  using Cloud = PointCloud<PointT>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  SUSANDemo(Grabber& grabber)
+  : cloud_viewer_("SUSAN 2D Keypoints -- PointCloud")
+  , grabber_(grabber)
+  , image_viewer_("SUSAN 2D Keypoints -- Image")
+  {}
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  cloud_callback(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+
+    // Compute SUSAN keypoints
+    SUSANKeypoint<PointT, KeyPointT> susan;
+    susan.setInputCloud(cloud);
+    susan.setNumberOfThreads(6);
+    susan.setNonMaxSupression(true);
+    keypoints_.reset(new PointCloud<KeyPointT>);
+    susan.compute(*keypoints_);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  init()
+  {
+    std::function<void(const CloudConstPtr&)> cloud_cb =
+        [this](const CloudConstPtr& cloud) { cloud_callback(cloud); };
+    cloud_connection = grabber_.registerCallback(cloud_cb);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  string
+  getStrBool(bool state)
+  {
+    stringstream ss;
+    ss << state;
+    return ss.str();
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  run()
+  {
+    grabber_.start();
+
+    bool image_init = false, cloud_init = false;
+    bool keypts = true;
+
+    while (!cloud_viewer_.wasStopped() && !image_viewer_.wasStopped()) {
+      PointCloud<KeyPointT>::Ptr keypoints;
+      CloudConstPtr cloud;
+
+      if (cloud_mutex_.try_lock()) {
+        cloud_.swap(cloud);
+        keypoints_.swap(keypoints);
+
+        cloud_mutex_.unlock();
+      }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    cloud_callback (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      cloud_ = cloud;
-
-      // Compute SUSAN keypoints 
-      SUSANKeypoint<PointT, KeyPointT> susan;
-      susan.setInputCloud (cloud);
-      susan.setNumberOfThreads (6);
-      susan.setNonMaxSupression (true);
-      keypoints_.reset (new PointCloud<KeyPointT>);
-      susan.compute (*keypoints_);
-    }
+      if (cloud) {
+        if (!cloud_init) {
+          cloud_viewer_.setPosition(0, 0);
+          cloud_viewer_.setSize(cloud->width, cloud->height);
+          cloud_init = true;
+        }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    init ()
-    {
-      std::function<void (const CloudConstPtr&) > cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback (cloud); };
-      cloud_connection = grabber_.registerCallback (cloud_cb);
-    }
+        if (!cloud_viewer_.updatePointCloud(cloud, "OpenNICloud")) {
+          cloud_viewer_.addPointCloud(cloud, "OpenNICloud");
+          cloud_viewer_.resetCameraViewpoint("OpenNICloud");
+        }
 
-    /////////////////////////////////////////////////////////////////////////
-    string
-    getStrBool (bool state)
-    {
-      stringstream ss;
-      ss << state;
-      return (ss.str ());
-    }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    run ()
-    {
-      grabber_.start ();
-      
-      bool image_init = false, cloud_init = false;
-      bool keypts = true;
-
-      while (!cloud_viewer_.wasStopped () && !image_viewer_.wasStopped ())
-      {
-        PointCloud<KeyPointT>::Ptr keypoints;
-        CloudConstPtr cloud;
-
-        if (cloud_mutex_.try_lock ())
-        {
-          cloud_.swap (cloud);
-          keypoints_.swap (keypoints);
-        
-          cloud_mutex_.unlock ();
+        if (!image_init) {
+          image_viewer_.setPosition(cloud->width, 0);
+          image_viewer_.setSize(cloud->width, cloud->height);
+          image_init = true;
         }
 
-        if (cloud)
-        {
-          if (!cloud_init)
-          {
-            cloud_viewer_.setPosition (0, 0);
-            cloud_viewer_.setSize (cloud->width, cloud->height);
-            cloud_init = true;
+        image_viewer_.addRGBImage<PointT>(cloud);
+
+        if (keypoints && !keypoints->empty()) {
+          image_viewer_.removeLayer(getStrBool(keypts));
+          for (std::size_t i = 0; i < keypoints->size(); ++i) {
+            int u = int(keypoints->points[i].label % cloud->width);
+            int v = cloud->height - int(keypoints->points[i].label / cloud->width);
+            image_viewer_.markPoint(u,
+                                    v,
+                                    visualization::red_color,
+                                    visualization::blue_color,
+                                    10,
+                                    getStrBool(!keypts));
           }
+          keypts = !keypts;
+
+          visualization::PointCloudColorHandlerCustom<KeyPointT> blue(
+              keypoints, 0, 0, 255);
+          if (!cloud_viewer_.updatePointCloud(keypoints, blue, "keypoints"))
+            cloud_viewer_.addPointCloud(keypoints, blue, "keypoints");
+          cloud_viewer_.setPointCloudRenderingProperties(
+              visualization::PCL_VISUALIZER_POINT_SIZE, 20, "keypoints");
+          cloud_viewer_.setPointCloudRenderingProperties(
+              visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
+        }
+      }
 
-          if (!cloud_viewer_.updatePointCloud (cloud, "OpenNICloud"))
-          {
-            cloud_viewer_.addPointCloud (cloud, "OpenNICloud");
-            cloud_viewer_.resetCameraViewpoint ("OpenNICloud");
-          }
+      cloud_viewer_.spinOnce();
+      image_viewer_.spinOnce();
+      std::this_thread::sleep_for(100us);
+    }
 
-          if (!image_init)
-          {
-            image_viewer_.setPosition (cloud->width, 0);
-            image_viewer_.setSize (cloud->width, cloud->height);
-            image_init = true;
-          }
+    grabber_.stop();
+    cloud_connection.disconnect();
+  }
 
-          image_viewer_.addRGBImage<PointT> (cloud);
-
-          if (keypoints && !keypoints->empty ())
-          {
-            image_viewer_.removeLayer (getStrBool (keypts));
-            for (std::size_t i = 0; i < keypoints->size (); ++i)
-            {
-              int u = int (keypoints->points[i].label % cloud->width);
-              int v = cloud->height - int (keypoints->points[i].label / cloud->width);
-              image_viewer_.markPoint (u, v, visualization::red_color, visualization::blue_color, 10, getStrBool (!keypts));
-            }
-            keypts = !keypts;
-
-            visualization::PointCloudColorHandlerCustom<KeyPointT> blue (keypoints, 0, 0, 255);
-            if (!cloud_viewer_.updatePointCloud (keypoints, blue, "keypoints"))
-              cloud_viewer_.addPointCloud (keypoints, blue, "keypoints");
-            cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_POINT_SIZE, 20, "keypoints");
-            cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
-          }
-        }
+  visualization::PCLVisualizer cloud_viewer_;
+  Grabber& grabber_;
+  std::mutex cloud_mutex_;
+  CloudConstPtr cloud_;
 
-        cloud_viewer_.spinOnce ();
-        image_viewer_.spinOnce ();
-        std::this_thread::sleep_for(100us);
-      }
+  visualization::ImageViewer image_viewer_;
 
-      grabber_.stop ();
-      cloud_connection.disconnect ();
-    }
-    
-    visualization::PCLVisualizer cloud_viewer_;
-    Grabber& grabber_;
-    std::mutex cloud_mutex_;
-    CloudConstPtr cloud_;
-    
-    visualization::ImageViewer image_viewer_;
-
-    PointCloud<KeyPointT>::Ptr keypoints_;
-        
-  private:
-    boost::signals2::connection cloud_connection;
+  PointCloud<KeyPointT>::Ptr keypoints_;
+
+private:
+  boost::signals2::connection cloud_connection;
 };
 
 /* ---[ */
 int
-main (int, char**)
+main(int, char**)
 {
-  string device_id ("#1");
-  OpenNIGrabber grabber (device_id);
-  SUSANDemo openni_viewer (grabber);
-
-  openni_viewer.init ();
-  openni_viewer.run ();
-  
-  return (0);
+  string device_id("#1");
+  OpenNIGrabber grabber(device_id);
+  SUSANDemo openni_viewer(grabber);
+
+  openni_viewer.init();
+  openni_viewer.run();
+
+  return 0;
 }
 /* ]--- */
index fb1f18999210ae4508688a83ae2732d3f8725f1e..88f57e1069052b03dc6ef780dd36b668780ffc46 100644 (file)
 
 #include <pcl/apps/timer.h>
 #include <pcl/common/common.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/keypoints/trajkovic_2d.h>
 #include <pcl/keypoints/trajkovic_3d.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/image_viewer.h>
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
+#include <pcl/visualization/pcl_visualizer.h>
 
 #include <mutex>
 #include <thread>
@@ -58,194 +58,195 @@ using PointT = PointXYZRGBA;
 using KeyPointT = PointXYZI;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class TrajkovicDemo
-{
-  public:
-    using Cloud = PointCloud<PointT>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-  TrajkovicDemo (Grabber& grabber, bool enable_3d)
-      : cloud_viewer_ ("TRAJKOVIC 3D Keypoints -- PointCloud")
-      , grabber_ (grabber)
-      , image_viewer_ ("TRAJKOVIC 3D Keypoints -- Image")
-      , enable_3d_ (enable_3d)
-    {
-    }
+class TrajkovicDemo {
+public:
+  using Cloud = PointCloud<PointT>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  TrajkovicDemo(Grabber& grabber, bool enable_3d)
+  : cloud_viewer_("TRAJKOVIC 3D Keypoints -- PointCloud")
+  , grabber_(grabber)
+  , image_viewer_("TRAJKOVIC 3D Keypoints -- Image")
+  , enable_3d_(enable_3d)
+  {}
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  cloud_callback_3d(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+
+    // Compute TRAJKOVIC keypoints 3D
+    TrajkovicKeypoint3D<PointT, KeyPointT> trajkovic;
+    trajkovic.setInputCloud(cloud);
+    trajkovic.setNumberOfThreads(6);
+    keypoints_.reset(new PointCloud<KeyPointT>);
+    trajkovic.compute(*keypoints_);
+    keypoints_indices_ = trajkovic.getKeypointsIndices();
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    cloud_callback_3d (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      cloud_ = cloud;
-
-      // Compute TRAJKOVIC keypoints 3D
-      TrajkovicKeypoint3D<PointT, KeyPointT> trajkovic;
-      trajkovic.setInputCloud (cloud);
-      trajkovic.setNumberOfThreads (6);
-      keypoints_.reset (new PointCloud<KeyPointT>);
-      trajkovic.compute (*keypoints_);
-      keypoints_indices_ = trajkovic.getKeypointsIndices ();
-    }
+  /////////////////////////////////////////////////////////////////////////
+  void
+  cloud_callback_2d(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+
+    // Compute TRAJKOVIC keypoints 2D
+    TrajkovicKeypoint2D<PointT, KeyPointT> trajkovic;
+    trajkovic.setInputCloud(cloud);
+    trajkovic.setNumberOfThreads(6);
+    keypoints_.reset(new PointCloud<KeyPointT>);
+    trajkovic.compute(*keypoints_);
+    keypoints_indices_ = trajkovic.getKeypointsIndices();
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    cloud_callback_2d (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      cloud_ = cloud;
-
-      // Compute TRAJKOVIC keypoints 2D
-      TrajkovicKeypoint2D<PointT, KeyPointT> trajkovic;
-      trajkovic.setInputCloud (cloud);
-      trajkovic.setNumberOfThreads (6);
-      keypoints_.reset (new PointCloud<KeyPointT>);
-      trajkovic.compute (*keypoints_);
-      keypoints_indices_ = trajkovic.getKeypointsIndices ();
-    }
+  /////////////////////////////////////////////////////////////////////////
+  void
+  init()
+  {
+    std::function<void(const CloudConstPtr&)> cloud_cb;
+    if (enable_3d_)
+      cloud_cb = [this](const CloudConstPtr& cloud) { cloud_callback_3d(cloud); };
+    else
+      cloud_cb = [this](const CloudConstPtr& cloud) { cloud_callback_2d(cloud); };
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    init ()
-    {
-      std::function<void (const CloudConstPtr&) > cloud_cb;
-      if (enable_3d_)
-        cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback_3d (cloud); };
-      else
-        cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback_2d (cloud); };
-
-      cloud_connection = grabber_.registerCallback (cloud_cb);
-    }
+    cloud_connection = grabber_.registerCallback(cloud_cb);
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    std::string
-    getStrBool (bool state)
-    {
-      std::ostringstream ss;
-      ss << state;
-      return (ss.str ());
-    }
+  /////////////////////////////////////////////////////////////////////////
+  std::string
+  getStrBool(bool state)
+  {
+    std::ostringstream ss;
+    ss << state;
+    return ss.str();
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    run ()
-    {
-      grabber_.start ();
-
-      bool image_init = false, cloud_init = false;
-      bool keypts = true;
-
-      while (!cloud_viewer_.wasStopped () && !image_viewer_.wasStopped ())
-      {
-        PointCloud<KeyPointT>::Ptr keypoints;
-        CloudConstPtr cloud;
-        if (cloud_mutex_.try_lock ())
-        {
-          cloud_.swap (cloud);
-          keypoints_.swap (keypoints);
-
-          cloud_mutex_.unlock ();
-        }
+  /////////////////////////////////////////////////////////////////////////
+  void
+  run()
+  {
+    grabber_.start();
 
-        if (cloud)
-        {
-          if (!cloud_init)
-          {
-            cloud_viewer_.setPosition (0, 0);
-            cloud_viewer_.setSize (cloud->width, cloud->height);
-            cloud_init = true;
-          }
+    bool image_init = false, cloud_init = false;
+    bool keypts = true;
 
-          if (!cloud_viewer_.updatePointCloud (cloud, "OpenNICloud"))
-          {
-            cloud_viewer_.addPointCloud (cloud, "OpenNICloud");
-            cloud_viewer_.resetCameraViewpoint ("OpenNICloud");
-          }
+    while (!cloud_viewer_.wasStopped() && !image_viewer_.wasStopped()) {
+      PointCloud<KeyPointT>::Ptr keypoints;
+      CloudConstPtr cloud;
+      if (cloud_mutex_.try_lock()) {
+        cloud_.swap(cloud);
+        keypoints_.swap(keypoints);
 
-          if (!image_init)
-          {
-            image_viewer_.setPosition (cloud->width, 0);
-            image_viewer_.setSize (cloud->width, cloud->height);
-            image_init = true;
-          }
+        cloud_mutex_.unlock();
+      }
 
-          image_viewer_.addRGBImage<PointT> (cloud);
-
-          if (keypoints && !keypoints->empty ())
-          {
-            image_viewer_.removeLayer (getStrBool (keypts));
-            std::vector<int> uv;
-            uv.reserve (keypoints_indices_->indices.size () * 2);
-            for (const int &index : keypoints_indices_->indices)
-            {
-              int u (index % cloud->width);
-              int v (index / cloud->width);
-              image_viewer_.markPoint (u, v, visualization::red_color, visualization::blue_color, 5, getStrBool (!keypts), 0.5);
-            }
-            keypts = !keypts;
-
-            visualization::PointCloudColorHandlerCustom<KeyPointT> blue (keypoints, 0, 0, 255);
-            if (!cloud_viewer_.updatePointCloud (keypoints, blue, "keypoints"))
-              cloud_viewer_.addPointCloud (keypoints, blue, "keypoints");
-            cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_POINT_SIZE, 10, "keypoints");
-            cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
-          }
+      if (cloud) {
+        if (!cloud_init) {
+          cloud_viewer_.setPosition(0, 0);
+          cloud_viewer_.setSize(cloud->width, cloud->height);
+          cloud_init = true;
+        }
+
+        if (!cloud_viewer_.updatePointCloud(cloud, "OpenNICloud")) {
+          cloud_viewer_.addPointCloud(cloud, "OpenNICloud");
+          cloud_viewer_.resetCameraViewpoint("OpenNICloud");
+        }
+
+        if (!image_init) {
+          image_viewer_.setPosition(cloud->width, 0);
+          image_viewer_.setSize(cloud->width, cloud->height);
+          image_init = true;
         }
 
-        cloud_viewer_.spinOnce ();
-        image_viewer_.spinOnce ();
-        std::this_thread::sleep_for(100us);
+        image_viewer_.addRGBImage<PointT>(cloud);
+
+        if (keypoints && !keypoints->empty()) {
+          image_viewer_.removeLayer(getStrBool(keypts));
+          std::vector<int> uv;
+          uv.reserve(keypoints_indices_->indices.size() * 2);
+          for (const int& index : keypoints_indices_->indices) {
+            int u(index % cloud->width);
+            int v(index / cloud->width);
+            image_viewer_.markPoint(u,
+                                    v,
+                                    visualization::red_color,
+                                    visualization::blue_color,
+                                    5,
+                                    getStrBool(!keypts),
+                                    0.5);
+          }
+          keypts = !keypts;
+
+          visualization::PointCloudColorHandlerCustom<KeyPointT> blue(
+              keypoints, 0, 0, 255);
+          if (!cloud_viewer_.updatePointCloud(keypoints, blue, "keypoints"))
+            cloud_viewer_.addPointCloud(keypoints, blue, "keypoints");
+          cloud_viewer_.setPointCloudRenderingProperties(
+              visualization::PCL_VISUALIZER_POINT_SIZE, 10, "keypoints");
+          cloud_viewer_.setPointCloudRenderingProperties(
+              visualization::PCL_VISUALIZER_OPACITY, 0.5, "keypoints");
+        }
       }
 
-      grabber_.stop ();
-      cloud_connection.disconnect ();
+      cloud_viewer_.spinOnce();
+      image_viewer_.spinOnce();
+      std::this_thread::sleep_for(100us);
     }
 
-    visualization::PCLVisualizer cloud_viewer_;
-    Grabber& grabber_;
-    std::mutex cloud_mutex_;
-    CloudConstPtr cloud_;
+    grabber_.stop();
+    cloud_connection.disconnect();
+  }
+
+  visualization::PCLVisualizer cloud_viewer_;
+  Grabber& grabber_;
+  std::mutex cloud_mutex_;
+  CloudConstPtr cloud_;
 
-    visualization::ImageViewer image_viewer_;
+  visualization::ImageViewer image_viewer_;
 
-    PointCloud<KeyPointT>::Ptr keypoints_;
-    pcl::PointIndicesConstPtr keypoints_indices_;
-    bool enable_3d_;
-  private:
-    boost::signals2::connection cloud_connection;
+  PointCloud<KeyPointT>::Ptr keypoints_;
+  pcl::PointIndicesConstPtr keypoints_indices_;
+  bool enable_3d_;
+
+private:
+  boost::signals2::connection cloud_connection;
 };
 
 /* ---[ */
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
-  if (pcl::console::find_switch (argc, argv, "-h"))
-  {
-    pcl::console::print_info ("Syntax is: %s [-device device_id_string] [-2d]\n", argv[0]);
-    return (0);
+  if (pcl::console::find_switch(argc, argv, "-h")) {
+    pcl::console::print_info("Syntax is: %s [-device device_id_string] [-2d]\n",
+                             argv[0]);
+    return 0;
   }
 
-  std::string device_id ("#1");
+  std::string device_id("#1");
   bool enable_3d = true;
-  if (pcl::console::find_switch (argc, argv, "-2d"))
+  if (pcl::console::find_switch(argc, argv, "-2d"))
     enable_3d = false;
 
-  if (pcl::console::find_argument (argc, argv, "-device"))
-    pcl::console::parse<std::string> (argc, argv, "-device", device_id);
+  if (pcl::console::find_argument(argc, argv, "-device"))
+    pcl::console::parse<std::string>(argc, argv, "-device", device_id);
 
-  pcl::console::print_info ("Extracting Trajkovic %s keypoints from device %s.\n",
-                            enable_3d ? "3D" : "2D", device_id.c_str ());
+  pcl::console::print_info("Extracting Trajkovic %s keypoints from device %s.\n",
+                           enable_3d ? "3D" : "2D",
+                           device_id.c_str());
 
-  OpenNIGrabber grabber (device_id);
+  OpenNIGrabber grabber(device_id);
 
-  TrajkovicDemo openni_viewer (grabber, enable_3d);
+  TrajkovicDemo openni_viewer(grabber, enable_3d);
 
-  openni_viewer.init ();
-  openni_viewer.run ();
+  openni_viewer.init();
+  openni_viewer.run();
 
-  return (0);
+  return 0;
 }
 /* ]--- */
index fd5e43f4b78e104b4fd0c6c8e7cde928d637f7de..7580c1e618ff7a575453fa58fb9c0f1ec74e8267 100644 (file)
  *
  */
 
-#include <pcl/point_types.h>
-#include <pcl/io/pcd_io.h>
 #include <pcl/apps/vfh_nn_classifier.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/point_types.h>
 
-int 
-main (int, char* argv[])
+int
+main(int, char* argv[])
 {
   // Load input file
   char* file_name = argv[1];
   pcl::PCLPointCloud2 cloud_blob;
-  pcl::io::loadPCDFile (file_name, cloud_blob);
-
-  // Declare variable to hold result
-  pcl::NNClassification<pcl::VFHSignature308>::ResultPtr result;
-  // same as: pcl::VFHClassifierNN::ResultPtr result;
-
-  // Do general classification using NNClassification or use the VHClassiierNN helper class
-  if (false)
-  {
-    // Estimate your favorite feature
-    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
-    pcl::fromPCLPointCloud2 (cloud_blob, *cloud);
-    /// NOTE: make sure to use same radius as for training data
-    pcl::PointCloud<pcl::VFHSignature308>::Ptr feature = pcl::computeVFH<pcl::PointXYZ> (cloud, 0.03);
+  pcl::io::loadPCDFile(file_name, cloud_blob);
 
-    // Nearest neighbors classification
-    pcl::NNClassification<pcl::VFHSignature308> nn;
-    //nn.setTrainingFeatures(cloud);
-    //nn.setTrainingLabels(std::vector<std::string>(cloud->points.size(), "bla"));
-    nn.loadTrainingFeatures (argv[2], argv[3]);
-    result = nn.classify(feature->points[0], 300, 50);
-  }
-  else
-  {
-    pcl::VFHClassifierNN vfh_classifier;
-    //vfh_classifier.loadTrainingData ("/home/marton/ros/pcl/trunk/apps/data/can.pcd", "can");
-    //vfh_classifier.loadTrainingData ("/home/marton/ros/pcl/trunk/apps/data/salt.pcd", "salt");
-    //vfh_classifier.loadTrainingData ("/home/marton/ros/pcl/trunk/apps/data/sugar.pcd", "sugar");
-    //vfh_classifier.saveTrainingFeatures ("/tmp/vfhs.pcd", "/tmp/vfhs.labels");
-    vfh_classifier.loadTrainingFeatures (argv[2], argv[3]);
-    vfh_classifier.finalizeTraining ();
-    result = vfh_classifier.classify(cloud_blob);
-  }
+  // Do general classification using VFHClassifierNN
+  pcl::VFHClassifierNN vfh_classifier;
+  vfh_classifier.loadTrainingFeatures(argv[2], argv[3]);
+  vfh_classifier.finalizeTraining();
+  const auto result = vfh_classifier.classify(cloud_blob);
 
   // Print results
   for (std::size_t i = 0; i < result->first.size(); ++i)
-    std::cerr << result->first.at (i) << ": " << result->second.at (i) << std::endl;
+    std::cerr << result->first.at(i) << ": " << result->second.at(i) << std::endl;
 
   return 0;
 }
index 80e7432675bdc5e512507de593286da230ed7742..7717c482c51569aaeffc58bfa8ca975b5a375b24 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/filters/voxel_grid.h>
 #include <pcl/surface/concave_hull.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
 #include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
@@ -52,136 +52,134 @@ using namespace pcl::visualization;
 using namespace std;
 using namespace std::chrono_literals;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    if (++count == 100) \
-    { \
-      double now = pcl::getTime (); \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    if (++count == 100) {                                                              \
+      double now = pcl::getTime();                                                     \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 template <typename PointType>
-class OpenNI3DConcaveHull
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNI3DConcaveHull (const std::string& device_id = "")
-      : viewer ("PCL OpenNI 3D Concave Hull Viewer") 
-    , device_id_(device_id)
-    {
-      grid.setFilterFieldName ("z");
-      grid.setFilterLimits (0.0, 1.0);
-      grid.setLeafSize (0.01f, 0.01f, 0.01f);
-    }
-    
-    void 
-    cloud_cb (const CloudConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      FPS_CALC ("computation");
-
-      cloud_pass_.reset (new Cloud);
-      // Computation goes here
-      grid.setInputCloud (cloud);
-      grid.filter (*cloud_pass_);
-
-      // Estimate 3D convex hull
-      pcl::ConcaveHull<PointType> hr;
-      hr.setAlpha (0.1);
-      hr.setInputCloud (cloud_pass_);
-      cloud_hull_.reset (new Cloud);
-      hr.reconstruct (*cloud_hull_, vertices_);
-
-      cloud_ = cloud;
-      new_cloud_ = true;
+class OpenNI3DConcaveHull {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNI3DConcaveHull(const std::string& device_id = "")
+  : viewer("PCL OpenNI 3D Concave Hull Viewer"), device_id_(device_id)
+  {
+    grid.setFilterFieldName("z");
+    grid.setFilterLimits(0.0, 1.0);
+    grid.setLeafSize(0.01f, 0.01f, 0.01f);
+  }
+
+  void
+  cloud_cb(const CloudConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    FPS_CALC("computation");
+
+    cloud_pass_.reset(new Cloud);
+    // Computation goes here
+    grid.setInputCloud(cloud);
+    grid.filter(*cloud_pass_);
+
+    // Estimate 3D convex hull
+    pcl::ConcaveHull<PointType> hr;
+    hr.setAlpha(0.1);
+    hr.setInputCloud(cloud_pass_);
+    cloud_hull_.reset(new Cloud);
+    hr.reconstruct(*cloud_hull_, vertices_);
+
+    cloud_ = cloud;
+    new_cloud_ = true;
+  }
+
+  void
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
+  {
+    if (!cloud_ || !new_cloud_) {
+      std::this_thread::sleep_for(1ms);
+      return;
     }
 
-    void
-    viz_cb (pcl::visualization::PCLVisualizer& viz)
     {
-      if (!cloud_ || !new_cloud_)
-      {
-        std::this_thread::sleep_for(1ms);
-        return;
+      std::lock_guard<std::mutex> lock(mtx_);
+      FPS_CALC("visualization");
+      CloudPtr temp_cloud;
+      temp_cloud.swap(cloud_pass_);
+
+      if (!viz.updatePointCloud(temp_cloud, "OpenNICloud")) {
+        viz.addPointCloud(temp_cloud, "OpenNICloud");
+        viz.resetCameraViewpoint("OpenNICloud");
       }
-
-      {
-        std::lock_guard<std::mutex> lock (mtx_);
-        FPS_CALC ("visualization");
-        CloudPtr temp_cloud;
-        temp_cloud.swap (cloud_pass_);
-
-        if (!viz.updatePointCloud (temp_cloud, "OpenNICloud"))
-        {
-          viz.addPointCloud (temp_cloud, "OpenNICloud");
-          viz.resetCameraViewpoint ("OpenNICloud");
-        }
-        // Render the data 
-        if (new_cloud_ && cloud_hull_)
-        {
-          viz.removePointCloud ("hull");
-          viz.addPolygonMesh<PointType> (cloud_hull_, vertices_, "hull");
-        }
-        new_cloud_ = false;
+      // Render the data
+      if (new_cloud_ && cloud_hull_) {
+        viz.removePointCloud("hull");
+        viz.addPolygonMesh<PointType>(cloud_hull_, vertices_, "hull");
       }
+      new_cloud_ = false;
     }
+  }
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      viewer.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
+    viewer.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
 
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        std::this_thread::sleep_for(1ms);
-      }
+    interface.start();
 
-      interface.stop ();
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1ms);
     }
 
-    pcl::VoxelGrid<PointType> grid;
-    pcl::visualization::CloudViewer viewer;
+    interface.stop();
+  }
+
+  pcl::VoxelGrid<PointType> grid;
+  pcl::visualization::CloudViewer viewer;
 
-    std::string device_id_;
-    std::mutex mtx_;
-    // Data
-    CloudConstPtr cloud_;
-    CloudPtr cloud_pass_, cloud_hull_;
-    std::vector<pcl::Vertices> vertices_;
-    bool new_cloud_;
+  std::string device_id_;
+  std::mutex mtx_;
+  // Data
+  CloudConstPtr cloud_;
+  CloudPtr cloud_pass_, cloud_hull_;
+  std::vector<pcl::Vertices> vertices_;
+  bool new_cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -189,30 +187,27 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+    arg = std::string(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    PCL_INFO ("PointXYZRGBA mode enabled.\n");
-    OpenNI3DConcaveHull<pcl::PointXYZRGBA> v ("");
-    v.run ();
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    PCL_INFO("PointXYZRGBA mode enabled.\n");
+    OpenNI3DConcaveHull<pcl::PointXYZRGBA> v("");
+    v.run();
   }
-  else
-  {
-    PCL_INFO ("PointXYZ mode enabled.\n");
-    OpenNI3DConcaveHull<pcl::PointXYZ> v ("");
-    v.run ();
+  else {
+    PCL_INFO("PointXYZ mode enabled.\n");
+    OpenNI3DConcaveHull<pcl::PointXYZ> v("");
+    v.run();
   }
-  return (0);
+  return 0;
 }
index c3fae85158ce4bf9916b5f0d91f1329340e7645e..54f12e202ac00ef7b9e11fe83e9cd164a3e53ad8 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/filters/passthrough.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/filters/passthrough.h>
 #include <pcl/surface/convex_hull.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
 #include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
@@ -52,134 +52,132 @@ using namespace std::chrono_literals;
 using namespace pcl;
 using namespace pcl::visualization;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    if (++count == 100) \
-    { \
-      double now = pcl::getTime (); \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    if (++count == 100) {                                                              \
+      double now = pcl::getTime();                                                     \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 template <typename PointType>
-class OpenNI3DConvexHull
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNI3DConvexHull (const std::string& device_id = "")
-      : viewer ("PCL OpenNI 3D Convex Hull Viewer") 
-    , device_id_(device_id)
-    {
-      pass.setFilterFieldName ("z");
-      pass.setFilterLimits (0.0, 1.0);
-    }
-    
-    void 
-    cloud_cb (const CloudConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      FPS_CALC ("computation");
-
-      cloud_pass_.reset (new Cloud);
-      // Computation goes here
-      pass.setInputCloud (cloud);
-      pass.filter (*cloud_pass_);
-
-      // Estimate 3D convex hull
-      pcl::ConvexHull<PointType> hr;
-      hr.setInputCloud (cloud_pass_);
-      cloud_hull_.reset (new Cloud);
-      hr.reconstruct (*cloud_hull_, vertices_);
-
-      cloud_ = cloud;
-      new_cloud_ = true;
+class OpenNI3DConvexHull {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNI3DConvexHull(const std::string& device_id = "")
+  : viewer("PCL OpenNI 3D Convex Hull Viewer"), device_id_(device_id)
+  {
+    pass.setFilterFieldName("z");
+    pass.setFilterLimits(0.0, 1.0);
+  }
+
+  void
+  cloud_cb(const CloudConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    FPS_CALC("computation");
+
+    cloud_pass_.reset(new Cloud);
+    // Computation goes here
+    pass.setInputCloud(cloud);
+    pass.filter(*cloud_pass_);
+
+    // Estimate 3D convex hull
+    pcl::ConvexHull<PointType> hr;
+    hr.setInputCloud(cloud_pass_);
+    cloud_hull_.reset(new Cloud);
+    hr.reconstruct(*cloud_hull_, vertices_);
+
+    cloud_ = cloud;
+    new_cloud_ = true;
+  }
+
+  void
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
+  {
+    if (!cloud_ || !new_cloud_) {
+      std::this_thread::sleep_for(1ms);
+      return;
     }
 
-    void
-    viz_cb (pcl::visualization::PCLVisualizer& viz)
     {
-      if (!cloud_ || !new_cloud_)
-      {
-        std::this_thread::sleep_for(1ms);
-        return;
+      std::lock_guard<std::mutex> lock(mtx_);
+      FPS_CALC("visualization");
+      CloudPtr temp_cloud;
+      temp_cloud.swap(cloud_pass_);
+
+      if (!viz.updatePointCloud(temp_cloud, "OpenNICloud")) {
+        viz.addPointCloud(temp_cloud, "OpenNICloud");
+        viz.resetCameraViewpoint("OpenNICloud");
       }
-
-      {
-        std::lock_guard<std::mutex> lock (mtx_);
-        FPS_CALC ("visualization");
-        CloudPtr temp_cloud;
-        temp_cloud.swap (cloud_pass_);
-
-        if (!viz.updatePointCloud (temp_cloud, "OpenNICloud"))
-        {
-          viz.addPointCloud (temp_cloud, "OpenNICloud");
-          viz.resetCameraViewpoint ("OpenNICloud");
-        }
-        // Render the data 
-        if (new_cloud_ && cloud_hull_)
-        {
-          viz.removePointCloud ("hull");
-          viz.addPolygonMesh<PointType> (cloud_hull_, vertices_, "hull");
-        }
-        new_cloud_ = false;
+      // Render the data
+      if (new_cloud_ && cloud_hull_) {
+        viz.removePointCloud("hull");
+        viz.addPolygonMesh<PointType>(cloud_hull_, vertices_, "hull");
       }
+      new_cloud_ = false;
     }
+  }
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      viewer.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
+    viewer.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
 
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        std::this_thread::sleep_for(1ms);
-      }
+    interface.start();
 
-      interface.stop ();
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1ms);
     }
 
-    pcl::PassThrough<PointType> pass;
-    pcl::visualization::CloudViewer viewer;
+    interface.stop();
+  }
+
+  pcl::PassThrough<PointType> pass;
+  pcl::visualization::CloudViewer viewer;
 
-    std::string device_id_;
-    std::mutex mtx_;
-    // Data
-    CloudConstPtr cloud_;
-    CloudPtr cloud_pass_, cloud_hull_;
-    std::vector<pcl::Vertices> vertices_;
-    bool new_cloud_;
+  std::string device_id_;
+  std::mutex mtx_;
+  // Data
+  CloudConstPtr cloud_;
+  CloudPtr cloud_pass_, cloud_hull_;
+  std::vector<pcl::Vertices> vertices_;
+  bool new_cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -187,30 +185,27 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+    arg = std::string(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    PCL_INFO ("PointXYZRGBA mode enabled.\n");
-    OpenNI3DConvexHull<pcl::PointXYZRGBA> v ("");
-    v.run ();
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    PCL_INFO("PointXYZRGBA mode enabled.\n");
+    OpenNI3DConvexHull<pcl::PointXYZRGBA> v("");
+    v.run();
   }
-  else
-  {
-    PCL_INFO ("PointXYZ mode enabled.\n");
-    OpenNI3DConvexHull<pcl::PointXYZ> v ("");
-    v.run ();
+  else {
+    PCL_INFO("PointXYZ mode enabled.\n");
+    OpenNI3DConvexHull<pcl::PointXYZ> v("");
+    v.run();
   }
-  return (0);
+  return 0;
 }
index eb6309243bf7cd686af2abd3b305fbddcfe571e3..52e5c2317667e4c4241b1f9ce68bfe40be43b347 100644 (file)
  *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/filters/approximate_voxel_grid.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
 #include <pcl/features/boundary.h>
 #include <pcl/features/integral_image_normal.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/filters/approximate_voxel_grid.h>
+#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
@@ -56,178 +56,169 @@ using ColorHandler = pcl::visualization::PointCloudColorHandler<pcl::PCLPointClo
 using ColorHandlerPtr = ColorHandler::Ptr;
 using ColorHandlerConstPtr = ColorHandler::ConstPtr;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
-
-class OpenNIIntegralImageNormalEstimation
-{
-  public:
-    using Cloud = pcl::PointCloud<pcl::PointXYZRGBNormal>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-    OpenNIIntegralImageNormalEstimation (const std::string& device_id = "")
-      : viewer ("PCL OpenNI NormalEstimation Viewer") 
-    , device_id_(device_id)
-    {
-      ne_.setNormalEstimationMethod (ne_.AVERAGE_3D_GRADIENT);
-      //ne_.setNormalEstimationMethod (ne_.COVARIANCE_MATRIX);
-      ne_.setRectSize (10, 10);
-      new_cloud_ = false;
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
+
+class OpenNIIntegralImageNormalEstimation {
+public:
+  using Cloud = pcl::PointCloud<pcl::PointXYZRGBNormal>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  OpenNIIntegralImageNormalEstimation(const std::string& device_id = "")
+  : viewer("PCL OpenNI NormalEstimation Viewer"), device_id_(device_id)
+  {
+    ne_.setNormalEstimationMethod(ne_.AVERAGE_3D_GRADIENT);
+    ne_.setRectSize(10, 10);
+    new_cloud_ = false;
 
-      pass_.setDownsampleAllData (true);
-      pass_.setLeafSize (0.005f, 0.005f, 0.005f);
+    pass_.setDownsampleAllData(true);
+    pass_.setLeafSize(0.005f, 0.005f, 0.005f);
 
-      pcl::search::OrganizedNeighbor<pcl::PointXYZRGBNormal>::Ptr tree (new pcl::search::OrganizedNeighbor<pcl::PointXYZRGBNormal>);
-      be_.setRadiusSearch (0.02);
-      be_.setSearchMethod (tree);
-    }
-    
-    void 
-    cloud_cb (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      //lock while we set our cloud;
-      FPS_CALC ("computation");
-
-      cloud_.reset (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
-
-      // Estimate surface normals
-      ne_.setInputCloud (cloud);
-      ne_.compute (*cloud_);
-      copyPointCloud (*cloud, *cloud_);
-
-//      cloud_pass_.reset (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
-      // Passthrough
-//      pass_.setInputCloud (cloud_);
-//      pass_.filter (*cloud_pass_);
-
-      be_.setInputCloud (cloud_);
-      be_.setInputNormals (cloud_);
-      boundaries_.reset (new pcl::PointCloud<pcl::Boundary>);
-      be_.compute (*boundaries_);
-
-      new_cloud_ = true;
+    pcl::search::OrganizedNeighbor<pcl::PointXYZRGBNormal>::Ptr tree(
+        new pcl::search::OrganizedNeighbor<pcl::PointXYZRGBNormal>);
+    be_.setRadiusSearch(0.02);
+    be_.setSearchMethod(tree);
+  }
+
+  void
+  cloud_cb(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    // lock while we set our cloud;
+    FPS_CALC("computation");
+
+    cloud_.reset(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
+
+    // Estimate surface normals
+    ne_.setInputCloud(cloud);
+    ne_.compute(*cloud_);
+    copyPointCloud(*cloud, *cloud_);
+
+    be_.setInputCloud(cloud_);
+    be_.setInputNormals(cloud_);
+    boundaries_.reset(new pcl::PointCloud<pcl::Boundary>);
+    be_.compute(*boundaries_);
+
+    new_cloud_ = true;
+  }
+
+  void
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    if (!cloud_) {
+      std::this_thread::sleep_for(1s);
+      return;
     }
 
-    void
-    viz_cb (pcl::visualization::PCLVisualizer& viz)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      if (!cloud_)
-      {
-        std::this_thread::sleep_for(1s);
-        return;
-      }
-
-      // Render the data 
-      if (new_cloud_ && cloud_ && boundaries_)
-      {
-        CloudPtr temp_cloud;
-        temp_cloud.swap (cloud_); //here we set cloud_ to null, so that
-
-//        if (!viz.updatePointCloud<pcl::PointXYZRGBNormal> (temp_cloud, "OpenNICloud"))
-//        {
-//          viz.addPointCloud<pcl::PointXYZRGBNormal> (temp_cloud, "OpenNICloud");
-//          viz.resetCameraViewpoint ("OpenNICloud");
-//        }
-
-        viz.removePointCloud ("normalcloud");
-        pcl::PCLPointCloud2::Ptr cloud2 (new pcl::PCLPointCloud2);
-        pcl::toPCLPointCloud2 (*boundaries_, *cloud2);
-        ColorHandlerConstPtr color_handler (new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (cloud2, "boundary_point"));
-        viz.addPointCloud<pcl::PointXYZRGBNormal> (temp_cloud, color_handler, "normalcloud");
-        viz.resetCameraViewpoint ("normalcloud");
-        new_cloud_ = false;
-      }
+    // Render the data
+    if (new_cloud_ && cloud_ && boundaries_) {
+      CloudPtr temp_cloud;
+      temp_cloud.swap(cloud_); // here we set cloud_ to null, so that
+
+      viz.removePointCloud("normalcloud");
+      pcl::PCLPointCloud2::Ptr cloud2(new pcl::PCLPointCloud2);
+      pcl::toPCLPointCloud2(*boundaries_, *cloud2);
+      ColorHandlerConstPtr color_handler(
+          new pcl::visualization::PointCloudColorHandlerGenericField<
+              pcl::PCLPointCloud2>(cloud2, "boundary_point"));
+      viz.addPointCloud<pcl::PointXYZRGBNormal>(
+          temp_cloud, color_handler, "normalcloud");
+      viz.resetCameraViewpoint("normalcloud");
+      new_cloud_ = false;
     }
+  }
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
-      std::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &)> f = [this] (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud) { cloud_cb (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
+    std::function<void(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&)> f =
+        [this](const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr& cloud) {
+          cloud_cb(cloud);
+        };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      viewer.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
+    viewer.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
 
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        std::this_thread::sleep_for(1s);
-      }
+    interface.start();
 
-      interface.stop ();
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1s);
     }
 
-    pcl::ApproximateVoxelGrid<pcl::PointXYZRGBNormal> pass_;
-    pcl::IntegralImageNormalEstimation<pcl::PointXYZRGB, pcl::PointXYZRGBNormal> ne_;
-    pcl::BoundaryEstimation<pcl::PointXYZRGBNormal, pcl::PointXYZRGBNormal, pcl::Boundary> be_;
-    pcl::visualization::CloudViewer viewer;
-    std::string device_id_;
-    std::mutex mtx_;
-    // Data
-    pcl::PointCloud<pcl::Boundary>::Ptr boundaries_;
-    CloudPtr cloud_, cloud_pass_;
-    bool new_cloud_;
+    interface.stop();
+  }
+
+  pcl::ApproximateVoxelGrid<pcl::PointXYZRGBNormal> pass_;
+  pcl::IntegralImageNormalEstimation<pcl::PointXYZRGB, pcl::PointXYZRGBNormal> ne_;
+  pcl::BoundaryEstimation<pcl::PointXYZRGBNormal, pcl::PointXYZRGBNormal, pcl::Boundary>
+      be_;
+  pcl::visualization::CloudViewer viewer;
+  std::string device_id_;
+  std::mutex mtx_;
+  // Data
+  pcl::PointCloud<pcl::Boundary>::Ptr boundaries_;
+  CloudPtr cloud_, cloud_pass_;
+  bool new_cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
     std::cout << "No devices connected." << std::endl;
 }
 
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+    arg = std::string(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb> ())
-  {
-    OpenNIIntegralImageNormalEstimation v ("");
-    v.run ();
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb>()) {
+    OpenNIIntegralImageNormalEstimation v("");
+    v.run();
   }
   else
-    PCL_ERROR ("The input device does not provide a PointXYZRGB mode.\n");
+    PCL_ERROR("The input device does not provide a PointXYZRGB mode.\n");
 
-  return (0);
+  return 0;
 }
index 797f23e3d4d3796f2cb03935c59a57b0e4b26ead..b237e5196bcb35082d85ac140fc4201144237aaf 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  * Author: Nico Blodow (blodow@cs.tum.edu), Julius Kammerl (julius@kammerl.de)
  */
 
-#include <thread>
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
+#include <pcl/console/parse.h>
+#include <pcl/filters/extract_indices.h>
 #include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
 #include <pcl/octree/octree_pointcloud_changedetector.h>
-#include <pcl/filters/extract_indices.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
-#include <pcl/console/parse.h>
+#include <thread>
 
 using namespace std::chrono_literals;
 
-enum 
-{
-  REDDIFF_MODE,
-  ONLYDIFF_MODE,
-  MODE_COUNT
-};
+enum { REDDIFF_MODE, ONLYDIFF_MODE, MODE_COUNT };
+
+class OpenNIChangeViewer {
+public:
+  OpenNIChangeViewer(double resolution, int mode, int noise_filter)
+  : viewer("PCL OpenNI Viewer")
+  {
+    octree =
+        new pcl::octree::OctreePointCloudChangeDetector<pcl::PointXYZRGBA>(resolution);
+    mode_ = mode;
+    noise_filter_ = noise_filter;
+  }
 
-class OpenNIChangeViewer
-{
-  public:
-    OpenNIChangeViewer (double resolution, int mode, int noise_filter)
-      : viewer ("PCL OpenNI Viewer")
-    {
-      octree = new pcl::octree::OctreePointCloudChangeDetector<pcl::PointXYZRGBA>(resolution);
-      mode_ = mode;
-      noise_filter_ = noise_filter;
-    }
+  void
+  cloud_cb_(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
+  {
+    std::cerr << cloud->points.size() << " -- ";
 
-    void 
-    cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
-    {
-      std::cerr << cloud->points.size() << " -- ";
+    // assign point cloud to octree
+    octree->setInputCloud(cloud);
 
-      // assign point cloud to octree
-      octree->setInputCloud (cloud);
+    // add points from cloud to octree
+    octree->addPointsFromInputCloud();
 
-      // add points from cloud to octree
-      octree->addPointsFromInputCloud ();
+    std::cerr << octree->getLeafCount() << " -- ";
+    std::vector<int> newPointIdxVector;
 
-      std::cerr << octree->getLeafCount() << " -- ";
-      std::vector<int> newPointIdxVector;
+    // get a vector of new points, which did not exist in previous buffer
+    octree->getPointIndicesFromNewVoxels(newPointIdxVector, noise_filter_);
 
-      // get a vector of new points, which did not exist in previous buffer
-      octree->getPointIndicesFromNewVoxels (newPointIdxVector, noise_filter_);
+    std::cerr << newPointIdxVector.size() << std::endl;
 
-      std::cerr << newPointIdxVector.size() << std::endl;
+    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr filtered_cloud;
 
-      pcl::PointCloud<pcl::PointXYZRGBA>::Ptr filtered_cloud;
+    switch (mode_) {
+    case REDDIFF_MODE:
+      filtered_cloud.reset(new pcl::PointCloud<pcl::PointXYZRGBA>(*cloud));
+      filtered_cloud->points.reserve(newPointIdxVector.size());
 
-      switch (mode_) 
-      {
-        case REDDIFF_MODE:
-          filtered_cloud.reset (new pcl::PointCloud<pcl::PointXYZRGBA> (*cloud));
-          filtered_cloud->points.reserve(newPointIdxVector.size());
+      for (const int& idx : newPointIdxVector)
+        filtered_cloud->points[idx].rgba = 255 << 16;
 
-          for (const int &idx : newPointIdxVector)
-            filtered_cloud->points[idx].rgba = 255<<16;
+      if (!viewer.wasStopped())
+        viewer.showCloud(filtered_cloud);
 
-          if (!viewer.wasStopped())
-            viewer.showCloud (filtered_cloud);
+      break;
+    case ONLYDIFF_MODE:
+      filtered_cloud.reset(new pcl::PointCloud<pcl::PointXYZRGBA>);
 
-          break;
-        case ONLYDIFF_MODE:
-          filtered_cloud.reset (new pcl::PointCloud<pcl::PointXYZRGBA>);
+      filtered_cloud->points.reserve(newPointIdxVector.size());
 
-          filtered_cloud->points.reserve(newPointIdxVector.size());
+      for (const int& idx : newPointIdxVector)
+        filtered_cloud->points.push_back(cloud->points[idx]);
 
-          for (const int &idx : newPointIdxVector)
-            filtered_cloud->points.push_back(cloud->points[idx]);
+      if (!viewer.wasStopped())
+        viewer.showCloud(filtered_cloud);
+      break;
+    }
 
+    // switch buffers - reset tree
+    octree->switchBuffers();
+  }
 
-          if (!viewer.wasStopped())
-            viewer.showCloud (filtered_cloud);
-          break;
-      }
-      
-      // switch buffers - reset tree
-      octree->switchBuffers ();
-    }
-    
-    void 
-    run ()
-    {
-      pcl::OpenNIGrabber interface {};
-
-      std::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
-        [this] (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud) { cloud_cb_ (cloud); };
-
-      boost::signals2::connection c = interface.registerCallback (f);
-      
-      interface.start ();
-      
-      while (!viewer.wasStopped())
-      {
-        std::this_thread::sleep_for(1s);
-      }
-
-      interface.stop ();
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{};
+
+    std::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
+        [this](const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) {
+          cloud_cb_(cloud);
+        };
+
+    boost::signals2::connection c = interface.registerCallback(f);
+
+    interface.start();
+
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1s);
     }
 
-    pcl::octree::OctreePointCloudChangeDetector<pcl::PointXYZRGBA> *octree;
-    pcl::visualization::CloudViewer viewer;
+    interface.stop();
+  }
+
+  pcl::octree::OctreePointCloudChangeDetector<pcl::PointXYZRGBA>* octree;
+  pcl::visualization::CloudViewer viewer;
 
-    int mode_;
-    int noise_filter_;
+  int mode_;
+  int noise_filter_;
 };
 
-int 
-main (int argc, char* argv[])
+int
+main(int argc, char* argv[])
 {
 
-  std::cout << "Syntax is " << argv[0] << " [-r octree resolution] [-d] [-n noise_filter intensity] \n";
+  std::cout << "Syntax is " << argv[0]
+            << " [-r octree resolution] [-d] [-n noise_filter intensity] \n";
 
   int mode = REDDIFF_MODE;
   int noise_filter = 7;
   double resolution = 0.01;
 
-  pcl::console::parse_argument (argc, argv, "-r", resolution);
+  pcl::console::parse_argument(argc, argv, "-r", resolution);
 
-  pcl::console::parse_argument (argc, argv, "-n", noise_filter);
+  pcl::console::parse_argument(argc, argv, "-n", noise_filter);
 
-  if (pcl::console::find_argument (argc, argv, "-d")>0) {
+  if (pcl::console::find_argument(argc, argv, "-d") > 0) {
     mode = ONLYDIFF_MODE;
   }
 
-
-  OpenNIChangeViewer v (resolution, mode, noise_filter);
-  v.run ();
+  OpenNIChangeViewer v(resolution, mode, noise_filter);
+  v.run();
   return 0;
 }
index 7b79194aeacc88cf437d7c3d0119c935b565a153..e06e45f512190dc071de0717ad0c701231917e3c 100644 (file)
  *  Author: Suat Gedikli (gedikli@willowgarage.com)
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/filters/color.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/filters/color.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
-
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 template <typename PointType>
-class OpenNIPassthrough
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIPassthrough (pcl::OpenNIGrabber& grabber, unsigned char red, unsigned char green, unsigned char blue, unsigned char radius)
-    : viewer ("PCL OpenNI ColorFilter Viewer")
-    , grabber_(grabber)
-    {
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-      boost::signals2::connection c = grabber_.registerCallback (f);
-
-      std::vector<bool> lookup(1<<24, false);
-      fillLookup (lookup, red, green, blue, radius);
-      unsigned set = 0;
-      for (unsigned i = 0; i < (1<<24); ++i)
-       if (lookup[i])
+class OpenNIPassthrough {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIPassthrough(pcl::OpenNIGrabber& grabber,
+                    unsigned char red,
+                    unsigned char green,
+                    unsigned char blue,
+                    unsigned char radius)
+  : viewer("PCL OpenNI ColorFilter Viewer"), grabber_(grabber)
+  {
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+    boost::signals2::connection c = grabber_.registerCallback(f);
+
+    std::vector<bool> lookup(1 << 24, false);
+    fillLookup(lookup, red, green, blue, radius);
+    unsigned set = 0;
+    for (unsigned i = 0; i < (1 << 24); ++i)
+      if (lookup[i])
         ++set;
-        
-      std::cout << "used colors: " << set << std::endl;
-      
-      color_filter_.setLookUpTable (lookup);
-    }
 
-    void fillLookup (std::vector<bool>& lookup, unsigned char red, unsigned char green, unsigned char blue, unsigned radius)
-    {      
-      unsigned radius_sqr = radius * radius;
-      pcl::RGB color;
-      for (color.rgba = 0; color.rgba < (1<<24); ++color.rgba)
-      {
-        unsigned dist = (unsigned(color.r) - unsigned(red)) * (unsigned(color.r) - unsigned(red)) +
-                        (unsigned(color.g) - unsigned(green)) * (unsigned(color.g) - unsigned(green)) +
-                        (unsigned(color.b) - unsigned(blue)) * (unsigned(color.b) - unsigned(blue));
-        if (dist < radius_sqr)
-          lookup [color.rgba] = true;
-        else
-          lookup [color.rgba] = false;
-      }
-    }
+    std::cout << "used colors: " << set << std::endl;
+
+    color_filter_.setLookUpTable(lookup);
+  }
 
-    void
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      FPS_CALC ("computation");
-
-      cloud_color_.reset (new Cloud);
-      // Computation goes here
-      color_filter_.setInputCloud (cloud);
-      color_filter_.filter (*cloud_color_);
-      cloud_  = cloud;
+  void
+  fillLookup(std::vector<bool>& lookup,
+             unsigned char red,
+             unsigned char green,
+             unsigned char blue,
+             unsigned radius)
+  {
+    unsigned radius_sqr = radius * radius;
+    pcl::RGB color;
+    for (color.rgba = 0; color.rgba < (1 << 24); ++color.rgba) {
+      unsigned dist =
+          (unsigned(color.r) - unsigned(red)) * (unsigned(color.r) - unsigned(red)) +
+          (unsigned(color.g) - unsigned(green)) *
+              (unsigned(color.g) - unsigned(green)) +
+          (unsigned(color.b) - unsigned(blue)) * (unsigned(color.b) - unsigned(blue));
+      if (dist < radius_sqr)
+        lookup[color.rgba] = true;
+      else
+        lookup[color.rgba] = false;
     }
+  }
+
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    FPS_CALC("computation");
+
+    cloud_color_.reset(new Cloud);
+    // Computation goes here
+    color_filter_.setInputCloud(cloud);
+    color_filter_.filter(*cloud_color_);
+    cloud_ = cloud;
+  }
 
-    void
-    run ()
-    {
+  void
+  run()
+  {
 
-      grabber_.start ();
+    grabber_.start();
 
-      while (!viewer.wasStopped ())
-      {
-        if (cloud_color_)
-        {
-          std::lock_guard<std::mutex> lock (mtx_);
+    while (!viewer.wasStopped()) {
+      if (cloud_color_) {
+        std::lock_guard<std::mutex> lock(mtx_);
 
-          FPS_CALC ("visualization");
-          CloudPtr temp_cloud;
-          temp_cloud.swap (cloud_color_); //here we set cloud_ to null, so that
-          viewer.showCloud (temp_cloud);
-        }
+        FPS_CALC("visualization");
+        CloudPtr temp_cloud;
+        temp_cloud.swap(cloud_color_); // here we set cloud_ to null, so that
+        viewer.showCloud(temp_cloud);
       }
-
-      grabber_.stop ();
     }
 
-    pcl::ColorFilter<PointType> color_filter_;
-    pcl::visualization::CloudViewer viewer;
-    pcl::OpenNIGrabber& grabber_;
-    std::string device_id_;
-    std::mutex mtx_;
-    CloudConstPtr cloud_;
-    CloudPtr cloud_color_;
+    grabber_.stop();
+  }
+
+  pcl::ColorFilter<PointType> color_filter_;
+  pcl::visualization::CloudViewer viewer;
+  pcl::OpenNIGrabber& grabber_;
+  std::string device_id_;
+  std::mutex mtx_;
+  CloudConstPtr cloud_;
+  CloudPtr cloud_color_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
-  std::cout << "usage: " << argv[0] << " <device_id> [-rgb <red> <green> <blue> [-radius <radius>] ]\n\n" << std::endl;
-
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  std::cout << "usage: " << argv[0]
+            << " <device_id> [-rgb <red> <green> <blue> [-radius <radius>] ]\n\n"
+            << std::endl;
+
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << (int)driver.getBus (deviceIdx) << " @ " << (int)driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -170,19 +180,17 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
-  if (argc < 2)
-  {
-    usage (argv);
+  if (argc < 2) {
+    usage(argv);
     return 1;
   }
 
-  std::string arg (argv[1]);
+  std::string arg(argv[1]);
 
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
@@ -190,35 +198,31 @@ main (int argc, char ** argv)
   int rr, gg, bb;
   unsigned char radius = 442; // all colors!
 
-  if (pcl::console::parse_3x_arguments (argc, argv, "-rgb", rr, gg, bb, true) != -1 )
-  {
+  if (pcl::console::parse_3x_arguments(argc, argv, "-rgb", rr, gg, bb, true) != -1) {
     std::cout << "-rgb present" << std::endl;
     int rad;
-    int idx = pcl::console::parse_argument (argc, argv, "-radius", rad);
-    if (idx != -1)
-    {
+    int idx = pcl::console::parse_argument(argc, argv, "-radius", rad);
+    if (idx != -1) {
       if (rad > 0)
         radius = rad;
     }
     if (rr >= 0 && rr < 256)
-      red = (unsigned char) rr;
+      red = (unsigned char)rr;
     if (gg >= 0 && gg < 256)
-      green = (unsigned char) gg;
+      green = (unsigned char)gg;
     if (bb >= 0 && bb < 256)
-      blue = (unsigned char) bb;
+      blue = (unsigned char)bb;
   }
-  
-  pcl::OpenNIGrabber grabber (arg);
-  
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    OpenNIPassthrough<pcl::PointXYZRGBA> v (grabber, red, green, blue, radius);
-    v.run ();
+
+  pcl::OpenNIGrabber grabber(arg);
+
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    OpenNIPassthrough<pcl::PointXYZRGBA> v(grabber, red, green, blue, radius);
+    v.run();
   }
-  else
-  {
+  else {
     std::cout << "device does not provide rgb stream" << std::endl;
   }
 
-  return (0);
+  return 0;
 }
index 039312f2de78b81bb179d91c8c3abacc90961e1e..d1aa036a53982d5ececa63f0cb0cbd6f80831bb7 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/surface/organized_fast_mesh.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
 #include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
@@ -51,122 +51,129 @@ using namespace pcl::visualization;
 using namespace std;
 using namespace std::chrono_literals;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    if (++count == 100) \
-    { \
-      double now = pcl::getTime (); \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    if (++count == 100) {                                                              \
+      double now = pcl::getTime();                                                     \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 template <typename PointType>
-class OpenNIFastMesh
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
+class OpenNIFastMesh {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIFastMesh(const std::string& device_id = "") : device_id_(device_id)
+  {
+    ofm.setTrianglePixelSize(3);
+    ofm.setTriangulationType(pcl::OrganizedFastMesh<PointType>::QUAD_MESH);
+  }
 
-    OpenNIFastMesh (const std::string& device_id = "")
-      : device_id_(device_id)
+  void
+  cloud_cb(const CloudConstPtr& cloud)
+  {
+    // Computation goes here
+    FPS_CALC("computation");
+
+    // Prepare input
+    ofm.setInputCloud(cloud);
+
+    // Store the results in a temporary object
+    std::vector<pcl::Vertices> temp_verts;
+    ofm.reconstruct(temp_verts);
+
+    // Lock and copy
     {
-      ofm.setTrianglePixelSize (3);
-      ofm.setTriangulationType (pcl::OrganizedFastMesh<PointType>::QUAD_MESH);
+      std::lock_guard<std::mutex> lock(mtx_);
+      vertices_ = std::move(temp_verts);
+      cloud_ = cloud; // reset (new Cloud (*cloud));
     }
-    
-    void 
-    cloud_cb (const CloudConstPtr& cloud)
-    {
-      // Computation goes here
-      FPS_CALC ("computation");
-     
-      // Prepare input
-      ofm.setInputCloud (cloud);
-
-      // Store the results in a temporary object
-      std::vector<pcl::Vertices> temp_verts;
-      ofm.reconstruct (temp_verts);
-
-      // Lock and copy
-      {
-        std::lock_guard<std::mutex> lock (mtx_);
-        vertices_ = std::move (temp_verts);
-        cloud_ = cloud;//reset (new Cloud (*cloud));
+  }
+
+  void
+  run(int argc, char** argv)
+  {
+    pcl::OpenNIGrabber interface{device_id_};
+
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
+
+    view.reset(
+        new pcl::visualization::PCLVisualizer(argc, argv, "PCL OpenNI Mesh Viewer"));
+
+    interface.start();
+
+    CloudConstPtr temp_cloud;
+    std::vector<pcl::Vertices> temp_verts;
+
+    while (!view->wasStopped()) {
+      if (!cloud_ || !mtx_.try_lock()) {
+        std::this_thread::sleep_for(1ms);
+        continue;
       }
-    }
 
-    void
-    run (int argc, char **argv)
-    {
-      pcl::OpenNIGrabber interface {device_id_};
-
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
-
-      view.reset (new pcl::visualization::PCLVisualizer (argc, argv, "PCL OpenNI Mesh Viewer"));
-
-      interface.start ();
-      
-      CloudConstPtr temp_cloud;
-      std::vector<pcl::Vertices> temp_verts;
-
-      while (!view->wasStopped ())
-      {
-        if (!cloud_ || !mtx_.try_lock ())
-        {
-          std::this_thread::sleep_for(1ms);
-          continue;
-        }
-
-        temp_cloud = cloud_;
-        temp_verts = std::move (vertices_);
-        mtx_.unlock ();
-
-        if (!view->updatePolygonMesh<PointType> (temp_cloud, temp_verts, "surface"))
-        {
-          view->addPolygonMesh<PointType> (temp_cloud, temp_verts, "surface");
-          view->resetCameraViewpoint ("surface");
-        }
-
-        FPS_CALC ("visualization");
-        view->spinOnce (1);
+      temp_cloud = cloud_;
+      temp_verts = std::move(vertices_);
+      mtx_.unlock();
+
+      if (!view->updatePolygonMesh<PointType>(temp_cloud, temp_verts, "surface")) {
+        view->addPolygonMesh<PointType>(temp_cloud, temp_verts, "surface");
+        view->resetCameraViewpoint("surface");
       }
 
-      interface.stop ();
+      FPS_CALC("visualization");
+      view->spinOnce(1);
     }
 
-    pcl::OrganizedFastMesh<PointType> ofm;
-    std::string device_id_;
-    std::mutex mtx_;
-    // Data
-    CloudConstPtr cloud_;
-    std::vector<pcl::Vertices> vertices_;
-    pcl::PolygonMesh::Ptr mesh_;
+    interface.stop();
+  }
+
+  pcl::OrganizedFastMesh<PointType> ofm;
+  std::string device_id_;
+  std::mutex mtx_;
+  // Data
+  CloudConstPtr cloud_;
+  std::vector<pcl::Vertices> vertices_;
+  pcl::PolygonMesh::Ptr mesh_;
 
-    pcl::visualization::PCLVisualizer::Ptr view;
+  pcl::visualization::PCLVisualizer::Ptr view;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
-      std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
-              << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
-      std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
-           << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
-           << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      std::cout << "Device: " << deviceIdx + 1
+                << ", vendor: " << driver.getVendorName(deviceIdx)
+                << ", product: " << driver.getProductName(deviceIdx)
+                << ", connected: " << driver.getBus(deviceIdx) << " @ "
+                << driver.getAddress(deviceIdx) << ", serial number: \'"
+                << driver.getSerialNumber(deviceIdx) << "\'" << std::endl;
+      std::cout << "device_id may be #1, #2, ... for the first second etc device in "
+                   "the list or"
+                << std::endl
+                << "                 bus@address for the device connected to a "
+                   "specific usb-bus / address combination (works only in Linux) or"
+                << std::endl
+                << "                 <serial-number> (only in Linux and for devices "
+                   "which provide serial numbers)"
+                << std::endl;
     }
   }
   else
@@ -174,30 +181,27 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+    arg = std::string(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    PCL_INFO ("PointXYZRGBA mode enabled.\n");
-    OpenNIFastMesh<pcl::PointXYZRGBA> v ("");
-    v.run (argc, argv);
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    PCL_INFO("PointXYZRGBA mode enabled.\n");
+    OpenNIFastMesh<pcl::PointXYZRGBA> v("");
+    v.run(argc, argv);
   }
-  else
-  {
-    PCL_INFO ("PointXYZ mode enabled.\n");
-    OpenNIFastMesh<pcl::PointXYZ> v ("");
-    v.run (argc, argv);
+  else {
+    PCL_INFO("PointXYZ mode enabled.\n");
+    OpenNIFastMesh<pcl::PointXYZ> v("");
+    v.run(argc, argv);
   }
-  return (0);
+  return 0;
 }
index 5701189cf138ab83b70a13f655dd696bf3f58af0..dc873032fcb6aef38e13ea546828a707676fb311 100644 (file)
  *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/console/parse.h>
 #include <pcl/common/time.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/features/multiscale_feature_persistence.h>
+#include <pcl/console/parse.h>
 #include <pcl/features/fpfh_omp.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/filters/extract_indices.h>
+#include <pcl/features/multiscale_feature_persistence.h>
 #include <pcl/features/normal_3d_omp.h>
+#include <pcl/filters/extract_indices.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
 
 using namespace std::chrono_literals;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 const float default_subsampling_leaf_size = 0.02f;
 const float default_normal_search_radius = 0.041f;
-const double aux [] = {0.21, 0.32};
-const std::vector<double> default_scales_vector (aux, aux + 2);
+const double aux[] = {0.21, 0.32};
+const std::vector<double> default_scales_vector(aux, aux + 2);
 const float default_alpha = 1.2f;
 
 template <typename PointType>
-class OpenNIFeaturePersistence
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIFeaturePersistence (float &subsampling_leaf_size,
-                              double &normal_search_radius,
-                              std::vector<float> &scales_vector,
-                              float &alpha,
-                              const std::string& device_id = "")
-      : viewer ("PCL OpenNI Feature Persistence Viewer")
-    , device_id_(device_id)
-    {
-      std::cout << "Launching with parameters:\n"
-                << "    octree_leaf_size = " << subsampling_leaf_size << "\n"
-                << "    normal_search_radius = " << normal_search_radius << "\n"
-                << "    persistence_alpha = " << alpha << "\n"
-                << "    scales = "; for (const float scale : scales_vector) std::cout << scale << " ";
-      std::cout << "\n";
-
-      subsampling_filter_.setLeafSize (subsampling_leaf_size, subsampling_leaf_size, subsampling_leaf_size);
-      typename pcl::search::KdTree<PointType>::Ptr normal_search_tree (new typename pcl::search::KdTree<PointType>);
-      normal_estimation_filter_.setSearchMethod (normal_search_tree);
-      normal_estimation_filter_.setRadiusSearch (normal_search_radius);
-
-      feature_persistence_.setScalesVector (scales_vector);
-      feature_persistence_.setAlpha (alpha);
-
-      fpfh_estimation_.reset (new typename pcl::FPFHEstimationOMP<PointType, pcl::Normal, pcl::FPFHSignature33> ());
-      typename pcl::search::KdTree<PointType>::Ptr fpfh_tree (new typename pcl::search::KdTree<PointType> ());
-      fpfh_estimation_->setSearchMethod (fpfh_tree);
-      feature_persistence_.setFeatureEstimator (fpfh_estimation_);
-      feature_persistence_.setDistanceMetric (pcl::CS);
-
-      new_cloud_ = false;
-    }
+class OpenNIFeaturePersistence {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIFeaturePersistence(float& subsampling_leaf_size,
+                           double& normal_search_radius,
+                           std::vector<float>& scales_vector,
+                           float& alpha,
+                           const std::string& device_id = "")
+  : viewer("PCL OpenNI Feature Persistence Viewer"), device_id_(device_id)
+  {
+    std::cout << "Launching with parameters:\n"
+              << "    octree_leaf_size = " << subsampling_leaf_size << "\n"
+              << "    normal_search_radius = " << normal_search_radius << "\n"
+              << "    persistence_alpha = " << alpha << "\n"
+              << "    scales = ";
+    for (const float scale : scales_vector)
+      std::cout << scale << " ";
+    std::cout << "\n";
+
+    subsampling_filter_.setLeafSize(
+        subsampling_leaf_size, subsampling_leaf_size, subsampling_leaf_size);
+    typename pcl::search::KdTree<PointType>::Ptr normal_search_tree(
+        new typename pcl::search::KdTree<PointType>);
+    normal_estimation_filter_.setSearchMethod(normal_search_tree);
+    normal_estimation_filter_.setRadiusSearch(normal_search_radius);
+
+    feature_persistence_.setScalesVector(scales_vector);
+    feature_persistence_.setAlpha(alpha);
+
+    fpfh_estimation_.reset(new typename pcl::FPFHEstimationOMP<PointType,
+                                                               pcl::Normal,
+                                                               pcl::FPFHSignature33>());
+    typename pcl::search::KdTree<PointType>::Ptr fpfh_tree(
+        new typename pcl::search::KdTree<PointType>());
+    fpfh_estimation_->setSearchMethod(fpfh_tree);
+    feature_persistence_.setFeatureEstimator(fpfh_estimation_);
+    feature_persistence_.setDistanceMetric(pcl::CS);
+
+    new_cloud_ = false;
+  }
 
+  void
+  cloud_cb(const CloudConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    // lock while we set our cloud;
+    FPS_CALC("computation");
 
-    void
-    cloud_cb (const CloudConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      //lock while we set our cloud;
-      FPS_CALC ("computation");
+    // Create temporary clouds
+    cloud_subsampled_.reset(new typename pcl::PointCloud<PointType>());
+    normals_.reset(new pcl::PointCloud<pcl::Normal>());
+    features_.reset(new pcl::PointCloud<pcl::FPFHSignature33>());
+    feature_indices_.reset(new std::vector<int>());
+    feature_locations_.reset(new typename pcl::PointCloud<PointType>());
 
-      // Create temporary clouds
-      cloud_subsampled_.reset (new typename pcl::PointCloud<PointType> ());
-      normals_.reset (new pcl::PointCloud<pcl::Normal> ());
-      features_.reset (new pcl::PointCloud<pcl::FPFHSignature33> ());
-      feature_indices_.reset (new std::vector<int> ());
-      feature_locations_.reset (new typename pcl::PointCloud<PointType> ());
+    // Subsample input cloud
+    subsampling_filter_.setInputCloud(cloud);
+    subsampling_filter_.filter(*cloud_subsampled_);
 
-      // Subsample input cloud
-      subsampling_filter_.setInputCloud (cloud);
-      subsampling_filter_.filter (*cloud_subsampled_);
+    // Estimate normals
+    normal_estimation_filter_.setInputCloud(cloud_subsampled_);
+    normal_estimation_filter_.compute(*normals_);
 
-      // Estimate normals
-      normal_estimation_filter_.setInputCloud (cloud_subsampled_);
-      normal_estimation_filter_.compute (*normals_);
+    // Compute persistent features
+    fpfh_estimation_->setInputCloud(cloud_subsampled_);
+    fpfh_estimation_->setInputNormals(normals_);
+    feature_persistence_.determinePersistentFeatures(*features_, feature_indices_);
 
-      // Compute persistent features
-      fpfh_estimation_->setInputCloud (cloud_subsampled_);
-      fpfh_estimation_->setInputNormals (normals_);
-      feature_persistence_.determinePersistentFeatures (*features_, feature_indices_);
+    // Extract feature locations by using indices
+    extract_indices_filter_.setInputCloud(cloud_subsampled_);
+    extract_indices_filter_.setIndices(feature_indices_);
+    extract_indices_filter_.filter(*feature_locations_);
 
-      // Extract feature locations by using indices
-      extract_indices_filter_.setInputCloud (cloud_subsampled_);
-      extract_indices_filter_.setIndices (feature_indices_);
-      extract_indices_filter_.filter (*feature_locations_);
+    PCL_INFO("Persistent feature locations %d\n", feature_locations_->points.size());
 
-      PCL_INFO ("Persistent feature locations %d\n", feature_locations_->points.size ());
+    cloud_ = cloud;
 
-      cloud_ = cloud;
+    new_cloud_ = true;
+  }
 
-      new_cloud_ = true;
+  void
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    if (!cloud_) {
+      std::this_thread::sleep_for(1s);
+      return;
     }
 
-    void
-    viz_cb (pcl::visualization::PCLVisualizer& viz)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      if (!cloud_)
-      {
-        std::this_thread::sleep_for(1s);
-        return;
-      }
-
-      CloudConstPtr temp_cloud;
-      temp_cloud.swap (cloud_); //here we set cloud_ to null, so that
-
-//      if (!viz.updatePointCloud (temp_cloud, "OpenNICloud"))
-//      {
-//        viz.addPointCloud (temp_cloud, "OpenNICloud");
-//        viz.resetCameraViewpoint ("OpenNICloud");
-//      }
-      // Render the data
-      if (new_cloud_ && feature_locations_)
-      {
-        viz.removePointCloud ("featurecloud");
-        viz.removePointCloud ("OpenNICloud");
-        colors_.reset (new typename pcl::visualization::PointCloudColorHandlerCustom<PointType> (feature_locations_, 255.0, 0.0, 0.0));
-        viz.addPointCloud (feature_locations_, *colors_, "featurecloud");
-        viz.addPointCloud (temp_cloud, "OpenNICloud");
-        new_cloud_ = false;
-      }
+    CloudConstPtr temp_cloud;
+    temp_cloud.swap(cloud_); // here we set cloud_ to null, so that
+
+    // Render the data
+    if (new_cloud_ && feature_locations_) {
+      viz.removePointCloud("featurecloud");
+      viz.removePointCloud("OpenNICloud");
+      colors_.reset(
+          new typename pcl::visualization::PointCloudColorHandlerCustom<PointType>(
+              feature_locations_, 255.0, 0.0, 0.0));
+      viz.addPointCloud(feature_locations_, *colors_, "featurecloud");
+      viz.addPointCloud(temp_cloud, "OpenNICloud");
+      new_cloud_ = false;
     }
+  }
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
-
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
-      viewer.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      interface.start ();
+    viewer.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
 
-      while (!viewer.wasStopped ())
-      {
-        std::this_thread::sleep_for(1s);
-      }
+    interface.start();
 
-      interface.stop ();
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1s);
     }
 
+    interface.stop();
+  }
 
-    pcl::VoxelGrid<PointType> subsampling_filter_;
-    pcl::NormalEstimationOMP<PointType, pcl::Normal> normal_estimation_filter_;
-    typename pcl::FPFHEstimationOMP<PointType, pcl::Normal, pcl::FPFHSignature33>::Ptr fpfh_estimation_;
-    pcl::MultiscaleFeaturePersistence<PointType, pcl::FPFHSignature33> feature_persistence_;
-    pcl::ExtractIndices<PointType> extract_indices_filter_;
-
-    pcl::visualization::CloudViewer viewer;
-    std::string device_id_;
-    std::mutex mtx_;
-    // Data
-    CloudPtr feature_locations_, cloud_subsampled_;
-    pcl::PointCloud<pcl::Normal>::Ptr normals_;
-    pcl::PointCloud<pcl::FPFHSignature33>::Ptr features_;
-    typename pcl::visualization::PointCloudColorHandlerCustom<PointType>::Ptr colors_;
-    pcl::IndicesPtr feature_indices_;
-    CloudConstPtr cloud_;
-    bool new_cloud_;
+  pcl::VoxelGrid<PointType> subsampling_filter_;
+  pcl::NormalEstimationOMP<PointType, pcl::Normal> normal_estimation_filter_;
+  typename pcl::FPFHEstimationOMP<PointType, pcl::Normal, pcl::FPFHSignature33>::Ptr
+      fpfh_estimation_;
+  pcl::MultiscaleFeaturePersistence<PointType, pcl::FPFHSignature33>
+      feature_persistence_;
+  pcl::ExtractIndices<PointType> extract_indices_filter_;
+
+  pcl::visualization::CloudViewer viewer;
+  std::string device_id_;
+  std::mutex mtx_;
+  // Data
+  CloudPtr feature_locations_, cloud_subsampled_;
+  pcl::PointCloud<pcl::Normal>::Ptr normals_;
+  pcl::PointCloud<pcl::FPFHSignature33>::Ptr features_;
+  typename pcl::visualization::PointCloudColorHandlerCustom<PointType>::Ptr colors_;
+  pcl::IndicesPtr feature_indices_;
+  CloudConstPtr cloud_;
+  bool new_cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
+  // clang-format off
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n"
             << "where options are:\n"
             << "         -octree_leaf_size X = size of the leaf for the octree-based subsampling filter (default: " << default_subsampling_leaf_size << "\n"
             << "         -normal_search_radius X = size of the neighborhood to consider for calculating the local plane and extracting the normals (default: " << default_normal_search_radius << "\n"
             << "         -persistence_alpha X = value of alpha for the multiscale feature persistence (default: " << default_alpha << "\n"
             << "         -scales X1 X2 ... = values for the multiple scales for extracting features (default: ";
-  for (const double &i : default_scales_vector) std::cout << i << " ";
+  // clang-format on
+  for (const double& i : default_scales_vector)
+    std::cout << i << " ";
   std::cout << "\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -254,53 +260,45 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char **argv)
+main(int argc, char** argv)
 {
-  std::cout << "OpenNIFeaturePersistence - show persistent features based on the MultiscaleFeaturePersistence class using the FPFH features\n"
+  std::cout << "OpenNIFeaturePersistence - show persistent features based on the "
+               "MultiscaleFeaturePersistence class using the FPFH features\n"
             << "Use \"-h\" to get more info about the available options.\n";
 
-  if (pcl::console::find_argument (argc, argv, "-h") == -1)
-  {
-    usage (argv);
+  if (pcl::console::find_argument(argc, argv, "-h") == -1) {
+    usage(argv);
     return 1;
   }
 
   // Parse arguments
   float subsampling_leaf_size = default_subsampling_leaf_size;
-  pcl::console::parse_argument (argc, argv, "-octree_leaf_size", subsampling_leaf_size);
+  pcl::console::parse_argument(argc, argv, "-octree_leaf_size", subsampling_leaf_size);
   double normal_search_radius = default_normal_search_radius;
-  pcl::console::parse_argument (argc, argv, "-normal_search_radius", normal_search_radius);
+  pcl::console::parse_argument(
+      argc, argv, "-normal_search_radius", normal_search_radius);
   std::vector<double> scales_vector_double = default_scales_vector;
-  pcl::console::parse_multiple_arguments (argc, argv, "-scales", scales_vector_double);
-  std::vector<float> scales_vector (scales_vector_double.size ());
-  for (std::size_t i = 0; i < scales_vector_double.size (); ++i) scales_vector[i] = float (scales_vector_double[i]);
+  pcl::console::parse_multiple_arguments(argc, argv, "-scales", scales_vector_double);
+  std::vector<float> scales_vector(scales_vector_double.size());
+  for (std::size_t i = 0; i < scales_vector_double.size(); ++i)
+    scales_vector[i] = float(scales_vector_double[i]);
 
   float alpha = default_alpha;
-  pcl::console::parse_argument (argc, argv, "-persistence_alpha", alpha);
-
-
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    PCL_INFO ("PointXYZRGBA mode enabled.\n");
-    OpenNIFeaturePersistence<pcl::PointXYZRGBA> v (subsampling_leaf_size,
-                                                   normal_search_radius,
-                                                   scales_vector,
-                                                   alpha,
-                                                   "");
-    v.run ();
+  pcl::console::parse_argument(argc, argv, "-persistence_alpha", alpha);
+
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    PCL_INFO("PointXYZRGBA mode enabled.\n");
+    OpenNIFeaturePersistence<pcl::PointXYZRGBA> v(
+        subsampling_leaf_size, normal_search_radius, scales_vector, alpha, "");
+    v.run();
   }
-  else
-  {
-    PCL_INFO ("PointXYZ mode enabled.\n");
-    OpenNIFeaturePersistence<pcl::PointXYZ> v (subsampling_leaf_size,
-                                               normal_search_radius,
-                                               scales_vector,
-                                               alpha,
-                                               "");
-    v.run ();
+  else {
+    PCL_INFO("PointXYZ mode enabled.\n");
+    OpenNIFeaturePersistence<pcl::PointXYZ> v(
+        subsampling_leaf_size, normal_search_radius, scales_vector, alpha, "");
+    v.run();
   }
 
-  return (0);
+  return 0;
 }
-
index 03469c588355fcf7be70c57e7a909a060063f0e2..61489b250b7222a4479838267a79d63369f4caff 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  * Author: Nico Blodow (blodow@cs.tum.edu)
  *         Christian Potthast (potthast@usc.edu)
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/io/pcd_io.h>
 #include <pcl/common/time.h>
-#include <pcl/console/print.h>
 #include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <boost/filesystem.hpp>
 
@@ -52,228 +52,228 @@ using namespace std::chrono_literals;
 
 #define SHOW_FPS 1
 #if SHOW_FPS
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 #else
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-}while(false)
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+  } while (false)
 #endif
 
 using namespace pcl::console;
 using namespace boost::filesystem;
 
-template<typename PointType>
-class OpenNIGrabFrame
-{
+template <typename PointType>
+class OpenNIGrabFrame {
   using Cloud = pcl::PointCloud<PointType>;
-  using CloudConstPtr = typename Cloud::ConstPtr;  
-  public:
-    OpenNIGrabFrame (pcl::OpenNIGrabber &grabber)
-    : visualizer_ (new pcl::visualization::PCLVisualizer ("OpenNI Viewer"))
-    , writer_ ()
-    , quit_ (false)
-    , continuous_ (false)
-    , trigger_ (false)
-    , file_name_ ("")
-    , dir_name_ ("")
-    , format_ (4)
-    , grabber_ (grabber)
-    , visualizer_enable_ (true)
-    {
-    }
+  using CloudConstPtr = typename Cloud::ConstPtr;
 
-    void 
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      if (quit_)
-        return;
-      
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-        cloud_ = cloud;
-        
-      if (continuous_ || trigger_)
-        saveCloud ();
-      
-      trigger_ = false;
-    }
-    
-    void 
-    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      if (event.keyUp ())
-      {
-        switch (event.getKeyCode ())
-        {
-          case 27:
-          case 'Q':
-          case 'q': quit_ = true; visualizer_->close ();
-            break;
-          case 'V':
-          case 'v': visualizer_enable_ = !visualizer_enable_;
-            break;
-          case ' ': continuous_ = !continuous_;
-            break;
-        }
+public:
+  OpenNIGrabFrame(pcl::OpenNIGrabber& grabber)
+  : visualizer_(new pcl::visualization::PCLVisualizer("OpenNI Viewer"))
+  , writer_()
+  , quit_(false)
+  , continuous_(false)
+  , trigger_(false)
+  , file_name_("")
+  , dir_name_("")
+  , format_(4)
+  , grabber_(grabber)
+  , visualizer_enable_(true)
+  {}
+
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    if (quit_)
+      return;
+
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+
+    if (continuous_ || trigger_)
+      saveCloud();
+
+    trigger_ = false;
+  }
+
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    if (event.keyUp()) {
+      switch (event.getKeyCode()) {
+      case 27:
+      case 'Q':
+      case 'q':
+        quit_ = true;
+        visualizer_->close();
+        break;
+      case 'V':
+      case 'v':
+        visualizer_enable_ = !visualizer_enable_;
+        break;
+      case ' ':
+        continuous_ = !continuous_;
+        break;
       }
     }
-    
-    void 
-    mouse_callback (const pcl::visualization::MouseEvent& mouse_event, void*)
-    {
-      if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress && mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton)
-      {
-        trigger_ = true;
-      }
+  }
+
+  void
+  mouse_callback(const pcl::visualization::MouseEvent& mouse_event, void*)
+  {
+    if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress &&
+        mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton) {
+      trigger_ = true;
     }
-    
-    CloudConstPtr
-    getLatestCloud ()
-    {
-      //lock while we swap our cloud and reset it.
-      std::lock_guard<std::mutex> lock(cloud_mutex_);
-      CloudConstPtr temp_cloud;
-      temp_cloud.swap (cloud_); //here we set cloud_ to null, so that
-      //it is safe to set it again from our
-      //callback
-      return (temp_cloud);
+  }
+
+  CloudConstPtr
+  getLatestCloud()
+  {
+    // lock while we swap our cloud and reset it.
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    CloudConstPtr temp_cloud;
+    temp_cloud.swap(cloud_); // here we set cloud_ to null, so that
+    // it is safe to set it again from our
+    // callback
+    return temp_cloud;
+  }
+
+  void
+  saveCloud()
+  {
+    FPS_CALC("I/O");
+    std::stringstream ss;
+    ss << dir_name_ << "/" << file_name_ << "_"
+       << boost::posix_time::to_iso_string(
+              boost::posix_time::microsec_clock::local_time())
+       << ".pcd";
+
+    if (format_ & 1) {
+      writer_.writeBinary<PointType>(ss.str(), *cloud_);
+      // std::cerr << "Data saved in BINARY format to " << ss.str () << std::endl;
     }
-    
-    void saveCloud ()
-    {
-      FPS_CALC ("I/O");
-      std::stringstream ss;
-      ss << dir_name_ << "/" << file_name_ << "_" << boost::posix_time::to_iso_string (boost::posix_time::microsec_clock::local_time ()) << ".pcd";
-
-      if (format_ & 1)
-      {
-        writer_.writeBinary<PointType> (ss.str (), *cloud_);
-        //std::cerr << "Data saved in BINARY format to " << ss.str () << std::endl;
-      }
-      
-      if (format_ & 2)
-      {
-        writer_.writeBinaryCompressed<PointType> (ss.str (), *cloud_);
-        //std::cerr << "Data saved in BINARY COMPRESSED format to " << ss.str () << std::endl;
-      }
-      
-      if (format_ & 4)
-      {
-        writer_.writeBinaryCompressed<PointType> (ss.str (), *cloud_);
-        //std::cerr << "Data saved in BINARY COMPRESSED format to " << ss.str () << std::endl;
-      }
+
+    if (format_ & 2) {
+      writer_.writeBinaryCompressed<PointType>(ss.str(), *cloud_);
+    }
+
+    if (format_ & 4) {
+      writer_.writeBinaryCompressed<PointType>(ss.str(), *cloud_);
     }
-    
-    void 
-    run ()
-    {
-      // register the keyboard and mouse callback for the visualizer
-      visualizer_->registerMouseCallback (&OpenNIGrabFrame::mouse_callback, *this);
-      visualizer_->registerKeyboardCallback(&OpenNIGrabFrame::keyboard_callback, *this);
-      
-
-      // make callback function from member function
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-
-      // connect callback function for desired signal. In this case its a point cloud with color values
-      boost::signals2::connection c = grabber_.registerCallback (f);
-
-      // start receiving point clouds
-      grabber_.start ();
-
-      // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
-      while (!visualizer_->wasStopped())
-      {
-        std::this_thread::sleep_for(100us);
-
-        visualizer_->spinOnce ();
-        
-        if (!visualizer_enable_)
-          continue;
-
-        if (cloud_)
-        {
-          CloudConstPtr cloud = getLatestCloud ();
-          if (!visualizer_->updatePointCloud (cloud, "OpenNICloud"))
-          {
-            visualizer_->addPointCloud (cloud, "OpenNICloud");
-            visualizer_->resetCameraViewpoint ("OpenNICloud");
-          }          
+  }
+
+  void
+  run()
+  {
+    // register the keyboard and mouse callback for the visualizer
+    visualizer_->registerMouseCallback(&OpenNIGrabFrame::mouse_callback, *this);
+    visualizer_->registerKeyboardCallback(&OpenNIGrabFrame::keyboard_callback, *this);
+
+    // make callback function from member function
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+
+    // connect callback function for desired signal. In this case its a point cloud with
+    // color values
+    boost::signals2::connection c = grabber_.registerCallback(f);
+
+    // start receiving point clouds
+    grabber_.start();
+
+    // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
+    while (!visualizer_->wasStopped()) {
+      std::this_thread::sleep_for(100us);
+
+      visualizer_->spinOnce();
+
+      if (!visualizer_enable_)
+        continue;
+
+      if (cloud_) {
+        CloudConstPtr cloud = getLatestCloud();
+        if (!visualizer_->updatePointCloud(cloud, "OpenNICloud")) {
+          visualizer_->addPointCloud(cloud, "OpenNICloud");
+          visualizer_->resetCameraViewpoint("OpenNICloud");
         }
       }
-      
-      // stop the grabber
-      grabber_.stop ();
     }
 
-    void
-    setOptions (const std::string &filename, const std::string &pcd_format, bool paused, bool visualizer)
-    {
-      boost::filesystem::path path(filename);
+    // stop the grabber
+    grabber_.stop();
+  }
 
-      if (filename.empty ())
-      {
-        dir_name_ = ".";
-        file_name_ = "frame";
-      }
-      else
-      {
-        dir_name_ = path.parent_path ().string ();
-        
-        if (!dir_name_.empty () && !boost::filesystem::exists (path.parent_path ()))
-        {
-          std::cerr << "directory \"" << path.parent_path () << "\" does not exist!\n";
-          exit (1);
-        }
-        file_name_ = path.stem ().string ();
+  void
+  setOptions(const std::string& filename,
+             const std::string& pcd_format,
+             bool paused,
+             bool visualizer)
+  {
+    boost::filesystem::path path(filename);
+
+    if (filename.empty()) {
+      dir_name_ = ".";
+      file_name_ = "frame";
+    }
+    else {
+      dir_name_ = path.parent_path().string();
+
+      if (!dir_name_.empty() && !boost::filesystem::exists(path.parent_path())) {
+        std::cerr << "directory \"" << path.parent_path() << "\" does not exist!\n";
+        exit(1);
       }
-      
-      std::cout << "dir: " << dir_name_ << " :: " << path.parent_path () << std::endl;
-      std::cout << "file: " << file_name_ << " :: " << path.stem (). string () << std::endl;
-      
-      if (pcd_format == "b" || pcd_format == "all")
-        format_ |= 1;
-      else if (pcd_format == "ascii" || pcd_format == "all")
-        format_ |= 2;
-      else if (pcd_format == "bc" || pcd_format == "all")
-        format_ |= 4;
-    
-      continuous_ = !paused;
-      visualizer_enable_ = visualizer;
+      file_name_ = path.stem().string();
     }
 
-    pcl::visualization::PCLVisualizer::Ptr visualizer_;
-    pcl::PCDWriter writer_;
-    bool quit_;
-    bool continuous_;
-    bool trigger_;
-    std::string file_name_;
-    std::string dir_name_;
-    unsigned format_;
-    CloudConstPtr cloud_;
-    mutable std::mutex cloud_mutex_;
-    pcl::OpenNIGrabber &grabber_;
-    bool visualizer_enable_;
+    std::cout << "dir: " << dir_name_ << " :: " << path.parent_path() << std::endl;
+    std::cout << "file: " << file_name_ << " :: " << path.stem().string() << std::endl;
+
+    if (pcd_format == "b" || pcd_format == "all")
+      format_ |= 1;
+    else if (pcd_format == "ascii" || pcd_format == "all")
+      format_ |= 2;
+    else if (pcd_format == "bc" || pcd_format == "all")
+      format_ |= 4;
+
+    continuous_ = !paused;
+    visualizer_enable_ = visualizer;
+  }
+
+  pcl::visualization::PCLVisualizer::Ptr visualizer_;
+  pcl::PCDWriter writer_;
+  bool quit_;
+  bool continuous_;
+  bool trigger_;
+  std::string file_name_;
+  std::string dir_name_;
+  unsigned format_;
+  CloudConstPtr cloud_;
+  mutable std::mutex cloud_mutex_;
+  pcl::OpenNIGrabber& grabber_;
+  bool visualizer_enable_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <filename> <options>\n\n";
-  
+
+  // clang-format off
   print_info ("  filename: if no filename is provided a generic timestamp will be set as filename\n\n");
   print_info ("  where options are:\n");
   print_info ("                    -format = PCD file format (b=binary; bc=binary compressed; ascii=ascii; all=all) (default: bc)\n");
@@ -283,18 +283,18 @@ usage (char ** argv)
   print_info ("                    -imagemode = select the image mode (resolution, fps) for the grabber, see pcl::OpenNIGrabber::Mode for details.\n");
   print_info ("                    -depthmode = select the depth mode (resolution, fps) for the grabber, see pcl::OpenNIGrabber::Mode for details.\n");
   print_info ("                    -visualizer 0/1 = turn OFF or ON the visualization of point clouds in the viewer (can also be changed using 'v'/'V' in the viewer).\n");
+  // clang-format on
 }
 
-int 
-main (int argc, char** argv)
+int
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
+    arg = std::string(argv[1]);
 
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
@@ -306,43 +306,39 @@ main (int argc, char** argv)
   pcl::OpenNIGrabber::Mode depth_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
   pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
 
-  if (argc > 1)
-  {
+  if (argc > 1) {
     // Parse the command line arguments for .pcd file
     std::vector<int> p_file_indices;
-    p_file_indices = parse_file_extension_argument (argc, argv, ".pcd");
-    if (p_file_indices.size () > 0)
+    p_file_indices = parse_file_extension_argument(argc, argv, ".pcd");
+    if (p_file_indices.size() > 0)
       filename = argv[p_file_indices[0]];
-    
+
     std::cout << "fname: " << filename << std::endl;
     // Command line parsing
-    parse_argument (argc, argv, "-format", format);
-    xyz = find_switch (argc, argv, "-XYZ");
-    paused = find_switch (argc, argv, "-paused");
-    visualizer = find_switch (argc, argv, "-visualizer");
+    parse_argument(argc, argv, "-format", format);
+    xyz = find_switch(argc, argv, "-XYZ");
+    paused = find_switch(argc, argv, "-paused");
+    visualizer = find_switch(argc, argv, "-visualizer");
 
     unsigned mode;
     if (pcl::console::parse(argc, argv, "-depthmode", mode) != -1)
-      depth_mode = pcl::OpenNIGrabber::Mode (mode);
+      depth_mode = pcl::OpenNIGrabber::Mode(mode);
 
     if (pcl::console::parse(argc, argv, "-imagemode", mode) != -1)
-      image_mode = pcl::OpenNIGrabber::Mode (mode);
+      image_mode = pcl::OpenNIGrabber::Mode(mode);
   }
 
-  pcl::OpenNIGrabber grabber ("#1", depth_mode, image_mode);
+  pcl::OpenNIGrabber grabber("#1", depth_mode, image_mode);
 
-  if (xyz)
-  {
-    OpenNIGrabFrame<pcl::PointXYZ> grab_frame (grabber);
-    grab_frame.setOptions (filename, format, paused, visualizer);
-    grab_frame.run ();
+  if (xyz) {
+    OpenNIGrabFrame<pcl::PointXYZ> grab_frame(grabber);
+    grab_frame.setOptions(filename, format, paused, visualizer);
+    grab_frame.run();
   }
-  else
-  {
-    OpenNIGrabFrame<pcl::PointXYZRGBA> grab_frame (grabber);
-    grab_frame.setOptions (filename, format, paused, visualizer);
-    grab_frame.run ();
+  else {
+    OpenNIGrabFrame<pcl::PointXYZRGBA> grab_frame(grabber);
+    grab_frame.setOptions(filename, format, paused, visualizer);
+    grab_frame.run();
   }
-  return (0);
+  return 0;
 }
-
index 16d071a942aa4abec90de732d03afa2a3c31f1ef..94412ab5aef62198aa928116f0eccf8739fb6444 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  * Author: Nico Blodow (blodow@cs.tum.edu)
  *         Christian Potthast (potthast@usc.edu)
  */
 
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/io/pcd_io.h>
 #include <pcl/common/time.h>
-#include <pcl/console/print.h>
 #include <pcl/console/parse.h>
-#include <pcl/visualization/vtk.h>
-#include <pcl/visualization/image_viewer.h>
+#include <pcl/console/print.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/visualization/common/float_image_utils.h>
+#include <pcl/visualization/image_viewer.h>
+#include <pcl/visualization/vtk.h>
+#include <pcl/point_types.h>
 
 #include <boost/filesystem.hpp>
 
 using namespace pcl::console;
 using namespace boost::filesystem;
 
-class OpenNIGrabFrame
-{
-  public:
-    OpenNIGrabFrame (pcl::OpenNIGrabber& grabber, bool paused) 
-    : grabber_ (grabber)
-    , image_viewer_ ("RGB Image")
-    , depth_image_viewer_ ("Depth Image")
-    , quit_ (false)
-    , continuous_ (!paused)
-    , trigger_ (false)
-    , importer_ (vtkSmartPointer<vtkImageImport>::New ())
-    , depth_importer_ (vtkSmartPointer<vtkImageImport>::New ())
-    , writer_ (vtkSmartPointer<vtkTIFFWriter>::New ())
-    , flipper_ (vtkSmartPointer<vtkImageFlip>::New ())    
-    {
-      importer_->SetNumberOfScalarComponents (3);
-      importer_->SetDataScalarTypeToUnsignedChar ();
-      depth_importer_->SetNumberOfScalarComponents (1);
-      depth_importer_->SetDataScalarTypeToUnsignedShort ();
-      writer_->SetCompressionToPackBits ();
-      flipper_->SetFilteredAxes (1);      
+class OpenNIGrabFrame {
+public:
+  OpenNIGrabFrame(pcl::OpenNIGrabber& grabber, bool paused)
+  : grabber_(grabber)
+  , image_viewer_("RGB Image")
+  , depth_image_viewer_("Depth Image")
+  , quit_(false)
+  , continuous_(!paused)
+  , trigger_(false)
+  , importer_(vtkSmartPointer<vtkImageImport>::New())
+  , depth_importer_(vtkSmartPointer<vtkImageImport>::New())
+  , writer_(vtkSmartPointer<vtkTIFFWriter>::New())
+  , flipper_(vtkSmartPointer<vtkImageFlip>::New())
+  {
+    importer_->SetNumberOfScalarComponents(3);
+    importer_->SetDataScalarTypeToUnsignedChar();
+    depth_importer_->SetNumberOfScalarComponents(1);
+    depth_importer_->SetDataScalarTypeToUnsignedShort();
+    writer_->SetCompressionToPackBits();
+    flipper_->SetFilteredAxes(1);
+  }
+
+  void
+  image_callback(const openni_wrapper::Image::Ptr& image,
+                 const openni_wrapper::DepthImage::Ptr& depth_image,
+                 float)
+  {
+    std::lock_guard<std::mutex> lock(image_mutex_);
+    image_ = image;
+    depth_image_ = depth_image;
+    lock.unlock();
+  }
+
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    if (event.keyUp()) {
+      switch (event.getKeyCode()) {
+      case 27:
+      case 'Q':
+      case 'q':
+        quit_ = true;
+        break;
+      case ' ':
+        continuous_ = !continuous_;
+        break;
+      case 'G':
+      case 'g':
+        trigger_ = true;
+        break;
+      }
     }
+  }
 
-    void
-    image_callback (const openni_wrapper::Image::Ptr &image,
-                    const openni_wrapper::DepthImage::Ptr &depth_image, float)
-    {
-      std::lock_guard<std::mutex> lock (image_mutex_);
-      image_ = image;
-      depth_image_ = depth_image;
-      lock.unlock ();
+  void
+  mouse_callback(const pcl::visualization::MouseEvent& mouse_event, void*)
+  {
+    if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress &&
+        mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton) {
+      trigger_ = true;
     }
-    
-    void 
-    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      if (event.keyUp ())
-      {
-        switch (event.getKeyCode ())
-        {
-          case 27:
-          case 'Q':
-          case 'q': quit_ = true;
-            break;
-          case ' ': continuous_ = !continuous_;
-            break;
-          case 'G':
-          case 'g': trigger_ = true;
-            break;
+  }
+
+  void
+  saveImages()
+  {
+    std::string time = boost::posix_time::to_iso_string(
+        boost::posix_time::microsec_clock::local_time());
+    openni_wrapper::Image::Ptr image;
+    openni_wrapper::DepthImage::Ptr depth_image;
+
+    image_mutex_.lock();
+    image.swap(image_);
+    depth_image.swap(depth_image_);
+    image_mutex_.unlock();
+
+    if (image) {
+      const void* data;
+      if (image->getEncoding() != openni_wrapper::Image::RGB) {
+        static unsigned char* rgb_data = 0;
+        static unsigned rgb_data_size = 0;
+
+        if (rgb_data_size < image->getWidth() * image->getHeight()) {
+          delete[] rgb_data;
+          rgb_data_size = image->getWidth() * image->getHeight();
+          rgb_data = new unsigned char[rgb_data_size * 3];
         }
+        image->fillRGB(image->getWidth(), image->getHeight(), rgb_data);
+        data = reinterpret_cast<const void*>(rgb_data);
       }
+      else
+        data = reinterpret_cast<const void*>(image->getMetaData().Data());
+
+      importer_->SetWholeExtent(
+          0, image->getWidth() - 1, 0, image->getHeight() - 1, 0, 0);
+      importer_->SetDataExtentToWholeExtent();
+
+      std::stringstream ss;
+      ss << "frame_" + time + "_rgb.tiff";
+      importer_->SetImportVoidPointer(const_cast<void*>(data), 1);
+      importer_->Update();
+      flipper_->SetInputConnection(importer_->GetOutputPort());
+      flipper_->Update();
+      writer_->SetFileName(ss.str().c_str());
+      writer_->SetInputConnection(flipper_->GetOutputPort());
+      writer_->Write();
     }
-    
-    void 
-    mouse_callback (const pcl::visualization::MouseEvent& mouse_event, void*)
-    {
-      if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress && mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton)
-      {
-        trigger_ = true;
-      }
+    if (depth_image) {
+      std::stringstream ss;
+      ss << "frame_" + time + "_depth.tiff";
+
+      depth_importer_->SetWholeExtent(
+          0, depth_image->getWidth() - 1, 0, depth_image->getHeight() - 1, 0, 0);
+      depth_importer_->SetDataExtentToWholeExtent();
+      depth_importer_->SetImportVoidPointer(
+          const_cast<void*>(
+              reinterpret_cast<const void*>(depth_image->getDepthMetaData().Data())),
+          1);
+      depth_importer_->Update();
+      flipper_->SetInputConnection(depth_importer_->GetOutputPort());
+      flipper_->Update();
+      writer_->SetFileName(ss.str().c_str());
+      writer_->SetInputConnection(flipper_->GetOutputPort());
+      writer_->Write();
     }
-    
-    void saveImages ()
-    {
-      std::string time = boost::posix_time::to_iso_string (boost::posix_time::microsec_clock::local_time ());
+
+    trigger_ = false;
+  }
+
+  int
+  run()
+  {
+    // register the keyboard and mouse callback for the visualizer
+    image_viewer_.registerMouseCallback(&OpenNIGrabFrame::mouse_callback, *this);
+    image_viewer_.registerKeyboardCallback(&OpenNIGrabFrame::keyboard_callback, *this);
+    depth_image_viewer_.registerMouseCallback(&OpenNIGrabFrame::mouse_callback, *this);
+    depth_image_viewer_.registerKeyboardCallback(&OpenNIGrabFrame::keyboard_callback,
+                                                 *this);
+
+    std::function<void(const openni_wrapper::Image::Ptr&,
+                       const openni_wrapper::DepthImage::Ptr&,
+                       float)>
+        image_cb = [this](const openni_wrapper::Image::Ptr& img,
+                          const openni_wrapper::DepthImage::Ptr& depth,
+                          float f) { image_callback(img, depth, f); };
+    boost::signals2::connection image_connection = grabber_.registerCallback(image_cb);
+
+    // start receiving point clouds
+    grabber_.start();
+    unsigned char* rgb_data = 0;
+    unsigned rgb_data_size = 0;
+    unsigned char* depth_data = 0;
+
+    // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
+    while (!image_viewer_.wasStopped() && !quit_) {
+      std::string time = boost::posix_time::to_iso_string(
+          boost::posix_time::microsec_clock::local_time());
       openni_wrapper::Image::Ptr image;
       openni_wrapper::DepthImage::Ptr depth_image;
 
-      image_mutex_.lock ();
-      image.swap (image_);
-      depth_image.swap (depth_image_);
-      image_mutex_.unlock ();
+      if (image_mutex_.try_lock()) {
+        image.swap(image_);
+        depth_image.swap(depth_image_);
+        image_mutex_.unlock();
+      }
 
-      if (image)
-      {
+      if (image) {
         const void* data;
-        if (image->getEncoding() != openni_wrapper::Image::RGB)
-        {
-          static unsigned char* rgb_data = 0;
-          static unsigned rgb_data_size = 0;
-
-          if (rgb_data_size < image->getWidth () * image->getHeight ())
-          {
-            if (rgb_data)
-              delete [] rgb_data;
-            rgb_data_size = image->getWidth () * image->getHeight ();
-            rgb_data = new unsigned char [rgb_data_size * 3];
+        if (image->getEncoding() != openni_wrapper::Image::RGB) {
+          if (rgb_data_size < image->getWidth() * image->getHeight()) {
+            delete[] rgb_data;
+            rgb_data_size = image->getWidth() * image->getHeight();
+            rgb_data = new unsigned char[rgb_data_size * 3];
           }
-          image->fillRGB (image->getWidth (), image->getHeight (), rgb_data);
-          data = reinterpret_cast<const void*> (rgb_data);
+          image->fillRGB(image->getWidth(), image->getHeight(), rgb_data);
+          data = reinterpret_cast<const void*>(rgb_data);
         }
         else
-          data = reinterpret_cast<const void*> (image->getMetaData ().Data ());
-
-        importer_->SetWholeExtent (0, image->getWidth () - 1, 0, image->getHeight () - 1, 0, 0);
-        importer_->SetDataExtentToWholeExtent ();
-        
-        std::stringstream ss;
-        ss << "frame_" + time + "_rgb.tiff";
-        importer_->SetImportVoidPointer (const_cast<void*>(data), 1);
-        importer_->Update ();
-        flipper_->SetInputConnection (importer_->GetOutputPort ());
-        flipper_->Update ();
-        writer_->SetFileName (ss.str ().c_str ());
-        writer_->SetInputConnection (flipper_->GetOutputPort ());
-        writer_->Write ();     
-      }
-      if (depth_image)
-      {
-        std::stringstream ss;
-        ss << "frame_" + time + "_depth.tiff";
-
-        depth_importer_->SetWholeExtent (0, depth_image->getWidth () - 1, 0, depth_image->getHeight () - 1, 0, 0);
-        depth_importer_->SetDataExtentToWholeExtent ();
-        depth_importer_->SetImportVoidPointer (const_cast<void*> (reinterpret_cast<const void*> (depth_image->getDepthMetaData ().Data ())), 1);
-        depth_importer_->Update ();
-        flipper_->SetInputConnection (depth_importer_->GetOutputPort ());
-        flipper_->Update ();
-        writer_->SetFileName (ss.str ().c_str ());
-        writer_->SetInputConnection (flipper_->GetOutputPort ());
-        writer_->Write ();
-      }
+          data = reinterpret_cast<const void*>(image->getMetaData().Data());
+        image_viewer_.addRGBImage(
+            (const unsigned char*)data, image->getWidth(), image->getHeight());
 
-      trigger_ = false;
-    }
-    
-    int 
-    run ()
-    {
-      // register the keyboard and mouse callback for the visualizer
-      image_viewer_.registerMouseCallback (&OpenNIGrabFrame::mouse_callback, *this);
-      image_viewer_.registerKeyboardCallback(&OpenNIGrabFrame::keyboard_callback, *this);
-      depth_image_viewer_.registerMouseCallback (&OpenNIGrabFrame::mouse_callback, *this);
-      depth_image_viewer_.registerKeyboardCallback(&OpenNIGrabFrame::keyboard_callback, *this);
-
-      std::function<void (const openni_wrapper::Image::Ptr&,
-                          const openni_wrapper::DepthImage::Ptr&,
-                          float) > image_cb = [this] (const openni_wrapper::Image::Ptr& img,
-                                                      const openni_wrapper::DepthImage::Ptr& depth,
-                                                      float f)
-      {
-        image_callback (img, depth, f);
-      };
-      boost::signals2::connection image_connection = grabber_.registerCallback (image_cb);
-      
-      // start receiving point clouds
-      grabber_.start ();
-      unsigned char* rgb_data = 0;
-      unsigned rgb_data_size = 0;
-      unsigned char* depth_data = 0;
-
-      // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
-      while (!image_viewer_.wasStopped() && !quit_)
-      {
-        std::string time = boost::posix_time::to_iso_string (boost::posix_time::microsec_clock::local_time ());
-        openni_wrapper::Image::Ptr image;
-        openni_wrapper::DepthImage::Ptr depth_image;
-        
-        if (image_mutex_.try_lock ())
-        {
-          image.swap (image_);
-          depth_image.swap (depth_image_);
-          image_mutex_.unlock ();
+        if (continuous_ || trigger_) {
+          importer_->SetWholeExtent(
+              0, image->getWidth() - 1, 0, image->getHeight() - 1, 0, 0);
+          importer_->SetDataExtentToWholeExtent();
+
+          std::stringstream ss;
+          ss << "frame_" + time + "_rgb.tiff";
+          importer_->SetImportVoidPointer(const_cast<void*>(data), 1);
+          importer_->Update();
+          flipper_->SetInputConnection(importer_->GetOutputPort());
+          flipper_->Update();
+          writer_->SetFileName(ss.str().c_str());
+          writer_->SetInputConnection(flipper_->GetOutputPort());
+          writer_->Write();
+          std::cout << "writing rgb frame: " << ss.str() << std::endl;
         }
-        
-        if (image)
-        {
-          const void* data;
-          if (image->getEncoding() != openni_wrapper::Image::RGB)
-          {
-            if (rgb_data_size < image->getWidth () * image->getHeight ())
-            {
-              if (rgb_data)
-                delete [] rgb_data;
-              rgb_data_size = image->getWidth () * image->getHeight ();
-              rgb_data = new unsigned char [rgb_data_size * 3];
-            }
-            image->fillRGB (image->getWidth (), image->getHeight (), rgb_data);
-            data = reinterpret_cast<const void*> (rgb_data);
-          }
-          else
-            data = reinterpret_cast<const void*> (image->getMetaData ().Data ());            
-          image_viewer_.addRGBImage ((const unsigned char*) data, image->getWidth (), image->getHeight ());
-          
-          if (continuous_ || trigger_)
-          {
-            importer_->SetWholeExtent (0, image->getWidth () - 1, 0, image->getHeight () - 1, 0, 0);
-            importer_->SetDataExtentToWholeExtent ();
-
-            std::stringstream ss;
-            ss << "frame_" + time + "_rgb.tiff";
-            importer_->SetImportVoidPointer (const_cast<void*>(data), 1);
-            importer_->Update ();
-            flipper_->SetInputConnection (importer_->GetOutputPort ());
-            flipper_->Update ();
-            writer_->SetFileName (ss.str ().c_str ());
-            writer_->SetInputConnection (flipper_->GetOutputPort ());
-            writer_->Write ();
-            std::cout << "writing rgb frame: " << ss.str () << std::endl;
-          }
-        } // if (image_)
-        
-        
-        if (depth_image)
-        {
-          if (depth_data)
-            delete[] depth_data;
-          depth_data = pcl::visualization::FloatImageUtils::getVisualImage (
-              reinterpret_cast<const unsigned short*> (depth_image->getDepthMetaData ().Data ()),
-                depth_image->getWidth (), depth_image->getHeight (),
-                std::numeric_limits<unsigned short>::min (), 
-                // Scale so that the colors look brigher on screen
-                std::numeric_limits<unsigned short>::max () / 10, 
-                true);
-          
-          depth_image_viewer_.addRGBImage (depth_data, depth_image->getWidth (), depth_image->getHeight ());
-          if (continuous_ || trigger_)
-          {
-            std::stringstream ss;
-            ss << "frame_" + time + "_depth.tiff";
-
-            depth_importer_->SetWholeExtent (0, depth_image->getWidth () - 1, 0, depth_image->getHeight () - 1, 0, 0);
-            depth_importer_->SetDataExtentToWholeExtent ();
-            depth_importer_->SetImportVoidPointer (const_cast<void*> (reinterpret_cast<const void*> (depth_image->getDepthMetaData ().Data ())), 1);
-            depth_importer_->Update ();
-            flipper_->SetInputConnection (depth_importer_->GetOutputPort ());
-            flipper_->Update ();
-            writer_->SetFileName (ss.str ().c_str ());
-            writer_->SetInputConnection (flipper_->GetOutputPort ());
-            writer_->Write ();
-            std::cout << "writing depth frame: " << ss.str () << std::endl;
-          }
+      }
+
+      if (depth_image) {
+        delete[] depth_data;
+        depth_data = pcl::visualization::FloatImageUtils::getVisualImage(
+            reinterpret_cast<const unsigned short*>(
+                depth_image->getDepthMetaData().Data()),
+            depth_image->getWidth(),
+            depth_image->getHeight(),
+            std::numeric_limits<unsigned short>::min(),
+            // Scale so that the colors look brigher on screen
+            std::numeric_limits<unsigned short>::max() / 10,
+            true);
+
+        depth_image_viewer_.addRGBImage(
+            depth_data, depth_image->getWidth(), depth_image->getHeight());
+        if (continuous_ || trigger_) {
+          std::stringstream ss;
+          ss << "frame_" + time + "_depth.tiff";
+
+          depth_importer_->SetWholeExtent(
+              0, depth_image->getWidth() - 1, 0, depth_image->getHeight() - 1, 0, 0);
+          depth_importer_->SetDataExtentToWholeExtent();
+          depth_importer_->SetImportVoidPointer(
+              const_cast<void*>(reinterpret_cast<const void*>(
+                  depth_image->getDepthMetaData().Data())),
+              1);
+          depth_importer_->Update();
+          flipper_->SetInputConnection(depth_importer_->GetOutputPort());
+          flipper_->Update();
+          writer_->SetFileName(ss.str().c_str());
+          writer_->SetInputConnection(flipper_->GetOutputPort());
+          writer_->Write();
+          std::cout << "writing depth frame: " << ss.str() << std::endl;
         }
-        trigger_ = false;
-        image_viewer_.spinOnce ();
-        depth_image_viewer_.spinOnce ();
       }
-      
-      image_mutex_.lock ();
-      // stop the grabber
-      grabber_.stop ();
-      image_mutex_.unlock ();
-      return 0;
+      trigger_ = false;
+      image_viewer_.spinOnce();
+      depth_image_viewer_.spinOnce();
     }
 
-    pcl::OpenNIGrabber& grabber_;
-    pcl::visualization::ImageViewer image_viewer_;
-    pcl::visualization::ImageViewer depth_image_viewer_;
-    bool quit_;
-    bool continuous_;
-    bool trigger_;
-    mutable std::mutex image_mutex_;
-    openni_wrapper::Image::Ptr image_;
-    openni_wrapper::DepthImage::Ptr depth_image_;
-    vtkSmartPointer<vtkImageImport> importer_, depth_importer_;
-    vtkSmartPointer<vtkTIFFWriter> writer_;
-    vtkSmartPointer<vtkImageFlip> flipper_;
+    image_mutex_.lock();
+    // stop the grabber
+    grabber_.stop();
+    image_mutex_.unlock();
+    return 0;
+  }
+
+  pcl::OpenNIGrabber& grabber_;
+  pcl::visualization::ImageViewer image_viewer_;
+  pcl::visualization::ImageViewer depth_image_viewer_;
+  bool quit_;
+  bool continuous_;
+  bool trigger_;
+  mutable std::mutex image_mutex_;
+  openni_wrapper::Image::Ptr image_;
+  openni_wrapper::DepthImage::Ptr depth_image_;
+  vtkSmartPointer<vtkImageImport> importer_, depth_importer_;
+  vtkSmartPointer<vtkTIFFWriter> writer_;
+  vtkSmartPointer<vtkImageFlip> flipper_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
-  std::cout << "usage: " << argv[0] << " [((<device_id> | <path-to-oni-file>) [-imagemode <mode>] [-depthformat <format>] [-paused] | -l [<device_id>]| -h | --help)]" << std::endl;
+  std::cout << "usage: " << argv[0]
+            << " [((<device_id> | <path-to-oni-file>) [-imagemode <mode>] "
+               "[-depthformat <format>] [-paused] | -l [<device_id>]| -h | --help)]"
+            << std::endl;
   std::cout << argv[0] << " -h | --help : shows this help" << std::endl;
   std::cout << argv[0] << " -l : list all available devices" << std::endl;
-  std::cout << argv[0] << " -l <device-id> : list all available modes for specified device" << std::endl;
+  std::cout << argv[0]
+            << " -l <device-id> : list all available modes for specified device"
+            << std::endl;
 
-  std::cout << "                 device_id may be #1, #2, ... for the first, second etc device in the list"
+  std::cout << "                 device_id may be #1, #2, ... for the first, second "
+               "etc device in the list"
 #ifndef _WIN32
-       << " or" << std::endl
-       << "                 bus@address for the device connected to a specific usb-bus / address combination or" << std::endl
-       << "                 <serial-number>"
+            << " or" << std::endl
+            << "                 bus@address for the device connected to a specific "
+               "usb-bus / address combination or"
+            << std::endl
+            << "                 <serial-number>"
 #endif
-       << std::endl;
-  std::cout << "                 -paused : start grabber in paused mode. Toggle pause by pressing the space bar\n";
-  std::cout << "                           or grab single frames by just pressing the left mouse button.\n";
+            << std::endl;
+  std::cout << "                 -paused : start grabber in paused mode. Toggle pause "
+               "by pressing the space bar\n";
+  std::cout << "                           or grab single frames by just pressing the "
+               "left mouse button.\n";
   std::cout << std::endl;
   std::cout << "examples:" << std::endl;
   std::cout << argv[0] << " \"#1\"" << std::endl;
   std::cout << "    uses the first device." << std::endl;
   std::cout << argv[0] << " \"./temp/test.oni\"" << std::endl;
-  std::cout << "    uses the oni-player device to play back oni file given by path." << std::endl;
+  std::cout << "    uses the oni-player device to play back oni file given by path."
+            << std::endl;
   std::cout << argv[0] << " -l" << std::endl;
   std::cout << "    lists all available devices." << std::endl;
   std::cout << argv[0] << " -l \"#2\"" << std::endl;
   std::cout << "    lists all available modes for the second device" << std::endl;
 #ifndef _WIN32
   std::cout << argv[0] << " A00361800903049A" << std::endl;
-  std::cout << "    uses the device with the serial number \'A00361800903049A\'." << std::endl;
+  std::cout << "    uses the device with the serial number \'A00361800903049A\'."
+            << std::endl;
   std::cout << argv[0] << " 1@16" << std::endl;
   std::cout << "    uses the device on address 16 at USB bus 1." << std::endl;
-#endif  
+#endif
 }
 
-int 
-main (int argc, char** argv)
+int
+main(int argc, char** argv)
 {
-  std::string device_id ("");
+  std::string device_id("");
   pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
-  
-  if (argc >= 2)
-  {
+
+  if (argc >= 2) {
     device_id = argv[1];
-    if (device_id == "--help" || device_id == "-h")
-    {
-      usage (argv);
-      return (0);
+    if (device_id == "--help" || device_id == "-h") {
+      usage(argv);
+      return 0;
     }
-    else if (device_id == "-l")
-    {
-      if (argc >= 3)
-      {
-        pcl::OpenNIGrabber grabber (argv[2]);
-        auto device = grabber.getDevice ();
-        std::vector<std::pair<int, XnMapOutputMode> > modes;
-
-        if (device->hasImageStream ())
-        {
-          std::cout << std::endl << "Supported image modes for device: " << device->getVendorName () << " , " << device->getProductName () << std::endl;
-          modes = grabber.getAvailableImageModes ();
-          for (std::vector<std::pair<int, XnMapOutputMode> >::const_iterator it = modes.begin (); it != modes.end (); ++it)
-          {
-            std::cout << it->first << " = " << it->second.nXRes << " x " << it->second.nYRes << " @ " << it->second.nFPS << std::endl;
+    else if (device_id == "-l") {
+      if (argc >= 3) {
+        pcl::OpenNIGrabber grabber(argv[2]);
+        auto device = grabber.getDevice();
+        std::vector<std::pair<int, XnMapOutputMode>> modes;
+
+        if (device->hasImageStream()) {
+          std::cout << std::endl
+                    << "Supported image modes for device: " << device->getVendorName()
+                    << " , " << device->getProductName() << std::endl;
+          modes = grabber.getAvailableImageModes();
+          for (std::vector<std::pair<int, XnMapOutputMode>>::const_iterator it =
+                   modes.begin();
+               it != modes.end();
+               ++it) {
+            std::cout << it->first << " = " << it->second.nXRes << " x "
+                      << it->second.nYRes << " @ " << it->second.nFPS << std::endl;
           }
         }
       }
-      else
-      {
-        openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-        if (driver.getNumberDevices () > 0)
-        {
-          for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-          {
-            std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
-              << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
+      else {
+        openni_wrapper::OpenNIDriver& driver =
+            openni_wrapper::OpenNIDriver::getInstance();
+        if (driver.getNumberDevices() > 0) {
+          for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices();
+               ++deviceIdx) {
+            std::cout << "Device: " << deviceIdx + 1
+                      << ", vendor: " << driver.getVendorName(deviceIdx)
+                      << ", product: " << driver.getProductName(deviceIdx)
+                      << ", connected: " << driver.getBus(deviceIdx) << " @ "
+                      << driver.getAddress(deviceIdx) << ", serial number: \'"
+                      << driver.getSerialNumber(deviceIdx) << "\'" << std::endl;
           }
-
         }
         else
           std::cout << "No devices connected." << std::endl;
-        
-        std::cout <<"Virtual Devices available: ONI player" << std::endl;
+
+        std::cout << "Virtual Devices available: ONI player" << std::endl;
       }
-      return (0);
+      return 0;
     }
   }
-  else
-  {
-    openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
+  else {
+    openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
     if (driver.getNumberDevices() > 0)
       std::cout << "Device Id not set, using first device." << std::endl;
   }
-  
+
   unsigned mode;
-  if (pcl::console::parse (argc, argv, "-imagemode", mode) != -1)
-    image_mode = static_cast<pcl::OpenNIGrabber::Mode> (mode);
-  
+  if (pcl::console::parse(argc, argv, "-imagemode", mode) != -1)
+    image_mode = static_cast<pcl::OpenNIGrabber::Mode>(mode);
+
   int depthformat = openni_wrapper::OpenNIDevice::OpenNI_12_bit_depth;
-  pcl::console::parse_argument (argc, argv, "-depthformat", depthformat);
+  pcl::console::parse_argument(argc, argv, "-depthformat", depthformat);
 
-  pcl::OpenNIGrabber grabber (device_id, pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);
+  pcl::OpenNIGrabber grabber(
+      device_id, pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);
   // Set the depth output format
-  grabber.getDevice ()->setDepthOutputFormat (static_cast<openni_wrapper::OpenNIDevice::DepthMode> (depthformat));
+  grabber.getDevice()->setDepthOutputFormat(
+      static_cast<openni_wrapper::OpenNIDevice::DepthMode>(depthformat));
 
-  bool paused = find_switch (argc, argv, "-paused");
-  
-  OpenNIGrabFrame grabFrame (grabber, paused);
-  return grabFrame.run ();
-}
+  bool paused = find_switch(argc, argv, "-paused");
 
+  OpenNIGrabFrame grabFrame(grabber, paused);
+  return grabFrame.run();
+}
index 4a3e720769db415038f368651aee890853000d5d..6d59fa55b37e32f20e7c5099bd9aa20b4f86f763 100644 (file)
  *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/features/integral_image_normal.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/features/integral_image_normal.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
 #include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
 
 using namespace std::chrono_literals;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 template <typename PointType>
-class OpenNIIntegralImageNormalEstimation
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIIntegralImageNormalEstimation (const std::string& device_id = "")
-      : viewer ("PCL OpenNI NormalEstimation Viewer")
-    , device_id_(device_id)
-    {
-      //ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::AVERAGE_3D_GRADIENT);
-      ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::COVARIANCE_MATRIX);
-      ne_.setNormalSmoothingSize (11.0);
-      new_cloud_ = false;
-      viewer.registerKeyboardCallback(&OpenNIIntegralImageNormalEstimation::keyboard_callback, *this);
-    }
+class OpenNIIntegralImageNormalEstimation {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIIntegralImageNormalEstimation(const std::string& device_id = "")
+  : viewer("PCL OpenNI NormalEstimation Viewer"), device_id_(device_id)
+  {
+    ne_.setNormalEstimationMethod(
+        pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::COVARIANCE_MATRIX);
+    ne_.setNormalSmoothingSize(11.0);
+    new_cloud_ = false;
+    viewer.registerKeyboardCallback(
+        &OpenNIIntegralImageNormalEstimation::keyboard_callback, *this);
+  }
 
+  void
+  cloud_cb(const CloudConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    // lock while we set our cloud;
 
-    void
-    cloud_cb (const CloudConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      //lock while we set our cloud;
-      //FPS_CALC ("computation");
-      // Estimate surface normals
+    normals_.reset(new pcl::PointCloud<pcl::Normal>);
 
-      normals_.reset (new pcl::PointCloud<pcl::Normal>);
+    ne_.setInputCloud(cloud);
+    ne_.compute(*normals_);
+    cloud_ = cloud;
 
-      //double start = pcl::getTime ();
-      ne_.setInputCloud (cloud);
-      ne_.compute (*normals_);
-      //double stop = pcl::getTime ();
-      //std::cout << "Time for normal estimation: " << (stop - start) * 1000.0 << " ms" << std::endl;
-      cloud_ = cloud;
+    new_cloud_ = true;
+  }
 
-      new_cloud_ = true;
+  void
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
+  {
+    mtx_.lock();
+    if (!cloud_ || !normals_) {
+      mtx_.unlock();
+      return;
     }
 
-    void
-    viz_cb (pcl::visualization::PCLVisualizer& viz)
-    {
-      mtx_.lock ();
-      if (!cloud_ || !normals_)
-      {
-        mtx_.unlock ();
-        return;
-      }
-
-      CloudConstPtr temp_cloud;
-      pcl::PointCloud<pcl::Normal>::Ptr temp_normals;
-      temp_cloud.swap (cloud_); //here we set cloud_ to null, so that
-      temp_normals.swap (normals_);
-      mtx_.unlock ();
-
-      if (!viz.updatePointCloud (temp_cloud, "OpenNICloud"))
-      {
-        viz.addPointCloud (temp_cloud, "OpenNICloud");
-        viz.resetCameraViewpoint ("OpenNICloud");
-      }
-      // Render the data
-      if (new_cloud_)
-      {
-        viz.removePointCloud ("normalcloud");
-        viz.addPointCloudNormals<PointType, pcl::Normal> (temp_cloud, temp_normals, 100, 0.05f, "normalcloud");
-        new_cloud_ = false;
-      }
-    }
+    CloudConstPtr temp_cloud;
+    pcl::PointCloud<pcl::Normal>::Ptr temp_normals;
+    temp_cloud.swap(cloud_); // here we set cloud_ to null, so that
+    temp_normals.swap(normals_);
+    mtx_.unlock();
 
-    void
-    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      switch (event.getKeyCode ())
-      {
-        case '1':
-          ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::COVARIANCE_MATRIX);
-          std::cout << "switched to COVARIANCE_MATRIX method\n";
-          break;
-        case '2':
-          ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::AVERAGE_3D_GRADIENT);
-          std::cout << "switched to AVERAGE_3D_GRADIENT method\n";
-          break;
-        case '3':
-          ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::AVERAGE_DEPTH_CHANGE);
-          std::cout << "switched to AVERAGE_DEPTH_CHANGE method\n";
-          break;
-        case '4':
-          ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::SIMPLE_3D_GRADIENT);
-          std::cout << "switched to SIMPLE_3D_GRADIENT method\n";
-          break;
-      }
+    if (!viz.updatePointCloud(temp_cloud, "OpenNICloud")) {
+      viz.addPointCloud(temp_cloud, "OpenNICloud");
+      viz.resetCameraViewpoint("OpenNICloud");
+    }
+    // Render the data
+    if (new_cloud_) {
+      viz.removePointCloud("normalcloud");
+      viz.addPointCloudNormals<PointType, pcl::Normal>(
+          temp_cloud, temp_normals, 100, 0.05f, "normalcloud");
+      new_cloud_ = false;
     }
+  }
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    switch (event.getKeyCode()) {
+    case '1':
+      ne_.setNormalEstimationMethod(
+          pcl::IntegralImageNormalEstimation<PointType,
+                                             pcl::Normal>::COVARIANCE_MATRIX);
+      std::cout << "switched to COVARIANCE_MATRIX method\n";
+      break;
+    case '2':
+      ne_.setNormalEstimationMethod(
+          pcl::IntegralImageNormalEstimation<PointType,
+                                             pcl::Normal>::AVERAGE_3D_GRADIENT);
+      std::cout << "switched to AVERAGE_3D_GRADIENT method\n";
+      break;
+    case '3':
+      ne_.setNormalEstimationMethod(
+          pcl::IntegralImageNormalEstimation<PointType,
+                                             pcl::Normal>::AVERAGE_DEPTH_CHANGE);
+      std::cout << "switched to AVERAGE_DEPTH_CHANGE method\n";
+      break;
+    case '4':
+      ne_.setNormalEstimationMethod(
+          pcl::IntegralImageNormalEstimation<PointType,
+                                             pcl::Normal>::SIMPLE_3D_GRADIENT);
+      std::cout << "switched to SIMPLE_3D_GRADIENT method\n";
+      break;
+    }
+  }
 
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
-      viewer.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      interface.start ();
+    viewer.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
 
-      while (!viewer.wasStopped ())
-      {
-        std::this_thread::sleep_for(1s);
-      }
+    interface.start();
 
-      interface.stop ();
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1s);
     }
 
-    pcl::IntegralImageNormalEstimation<PointType, pcl::Normal> ne_;
-    pcl::visualization::CloudViewer viewer;
-    std::string device_id_;
-    std::mutex mtx_;
-    // Data
-    pcl::PointCloud<pcl::Normal>::Ptr normals_;
-    CloudConstPtr cloud_;
-    bool new_cloud_;
+    interface.stop();
+  }
+
+  pcl::IntegralImageNormalEstimation<PointType, pcl::Normal> ne_;
+  pcl::visualization::CloudViewer viewer;
+  std::string device_id_;
+  std::mutex mtx_;
+  // Data
+  pcl::PointCloud<pcl::Normal>::Ptr normals_;
+  CloudConstPtr cloud_;
+  bool new_cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " [<device_id>]\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -210,39 +211,38 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
+    arg = std::string(argv[1]);
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (arg == "--help" || arg == "-h" || driver.getNumberDevices () == 0)
-  {
-    usage (argv);
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (arg == "--help" || arg == "-h" || driver.getNumberDevices() == 0) {
+    usage(argv);
     return 1;
   }
 
+  // clang-format off
   std::cout << "Press following keys to switch to the different integral image normal estimation methods:\n";
   std::cout << "<1> COVARIANCE_MATRIX method\n";
   std::cout << "<2> AVERAGE_3D_GRADIENT method\n";
   std::cout << "<3> AVERAGE_DEPTH_CHANGE method\n";
   std::cout << "<4> SIMPLE_3D_GRADIENT method\n";
   std::cout << "<Q,q> quit\n\n";
+  // clang-format on
 
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    PCL_INFO ("PointXYZRGBA mode enabled.\n");
-    OpenNIIntegralImageNormalEstimation<pcl::PointXYZRGBA> v ("");
-    v.run ();
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    PCL_INFO("PointXYZRGBA mode enabled.\n");
+    OpenNIIntegralImageNormalEstimation<pcl::PointXYZRGBA> v("");
+    v.run();
   }
-  else
-  {
-    PCL_INFO ("PointXYZ mode enabled.\n");
-    OpenNIIntegralImageNormalEstimation<pcl::PointXYZ> v ("");
-    v.run ();
+  else {
+    PCL_INFO("PointXYZ mode enabled.\n");
+    OpenNIIntegralImageNormalEstimation<pcl::PointXYZ> v("");
+    v.run();
   }
 
-  return (0);
+  return 0;
 }
index cc86899f99c17b76eddff19bb39af33479f77670..43bfe2118f278b88e17f8044251d2dd9f359769e 100644 (file)
 
 #define MEASURE_FUNCTION_TIME
 #include <pcl/common/time.h> //fps calculations
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/boost.h>
-#include <pcl/visualization/image_viewer.h>
-#include <pcl/console/print.h>
 #include <pcl/console/parse.h>
-#include <pcl/tracking/pyramidal_klt.h>
+#include <pcl/console/print.h>
+#include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/keypoints/harris_2d.h>
+#include <pcl/tracking/pyramidal_klt.h>
+#include <pcl/visualization/boost.h>
+#include <pcl/visualization/image_viewer.h>
 
 #include <mutex>
 
 #define SHOW_FPS 1
 #if SHOW_FPS
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 #else
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-}while(false)
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+  } while (false)
 #endif
 
 void
-printHelp (int, char **argv)
+printHelp(int, char** argv)
 {
   using pcl::console::print_error;
   using pcl::console::print_info;
 
+  // clang-format off
   print_error ("Syntax is: %s [((<device_id> | <path-to-oni-file>) [-depthmode <mode>] [-imagemode <mode>] [-xyz] | -l [<device_id>]| -h | --help)]\n", argv [0]);
   print_info ("%s -h | --help : shows this help\n", argv [0]);
   print_info ("%s -xyz : use only XYZ values and ignore RGB components (this flag is required for use with ASUS Xtion Pro) \n", argv [0]);
@@ -85,229 +86,217 @@ printHelp (int, char **argv)
   print_info ("\t\t                   bus@address for the device connected to a specific usb-bus / address combination\n");
   print_info ("\t\t                   <serial-number>\n");
 #endif
-  print_info ("\n\nexamples:\n");
-  print_info ("%s \"#1\"\n", argv [0]);
-  print_info ("\t\t uses the first device.\n");
-  print_info ("%s  \"./temp/test.oni\"\n", argv [0]);
-  print_info ("\t\t uses the oni-player device to play back oni file given by path.\n");
-  print_info ("%s -l\n", argv [0]);
-  print_info ("\t\t list all available devices.\n");
-  print_info ("%s -l \"#2\"\n", argv [0]);
-  print_info ("\t\t list all available modes for the second device.\n");
-  #ifndef _WIN32
-  print_info ("%s A00361800903049A\n", argv [0]);
-  print_info ("\t\t uses the device with the serial number \'A00361800903049A\'.\n");
-  print_info ("%s 1@16\n", argv [0]);
-  print_info ("\t\t uses the device on address 16 at USB bus 1.\n");
-  #endif
+  print_info("\n\nexamples:\n");
+  print_info("%s \"#1\"\n", argv[0]);
+  print_info("\t\t uses the first device.\n");
+  print_info("%s  \"./temp/test.oni\"\n", argv[0]);
+  print_info("\t\t uses the oni-player device to play back oni file given by path.\n");
+  print_info("%s -l\n", argv[0]);
+  print_info("\t\t list all available devices.\n");
+  print_info("%s -l \"#2\"\n", argv[0]);
+  print_info("\t\t list all available modes for the second device.\n");
+#ifndef _WIN32
+  print_info("%s A00361800903049A\n", argv[0]);
+  print_info("\t\t uses the device with the serial number \'A00361800903049A\'.\n");
+  print_info("%s 1@16\n", argv[0]);
+  print_info("\t\t uses the device on address 16 at USB bus 1.\n");
+#endif
+  // clang-format on
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointType>
-class OpenNIViewer
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIViewer (pcl::Grabber& grabber)
-      : grabber_ (grabber)
-      , rgb_data_ (nullptr), rgb_data_size_ (0)
-    { }
-
-    void
-    detect_keypoints (const CloudConstPtr& cloud)
-    {
-      pcl::HarrisKeypoint2D<PointType, pcl::PointXYZI> harris;
-      harris.setInputCloud (cloud);
-      harris.setNumberOfThreads (6);
-      harris.setNonMaxSupression (true);
-      harris.setRadiusSearch (0.01);
-      harris.setMethod (pcl::HarrisKeypoint2D<PointType, pcl::PointXYZI>::TOMASI);
-      harris.setThreshold (0.05);
-      harris.setWindowWidth (5);
-      harris.setWindowHeight (5);
-      pcl::PointCloud<pcl::PointXYZI>::Ptr response (new pcl::PointCloud<pcl::PointXYZI>);
-      harris.compute (*response);
-      points_ = harris.getKeypointsIndices ();
-    }
+class OpenNIViewer {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudConstPtr = typename Cloud::ConstPtr;
 
-    void
-    cloud_callback (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("cloud callback");
-      std::lock_guard<std::mutex> lock (cloud_mutex_);
-      cloud_ = cloud;
-      // Compute Tomasi keypoints
-      tracker_->setInputCloud (cloud_);
-      // if (!points_)
-      // {
-      if (!points_ || (counter_ % 10 == 0))
-      {
-        detect_keypoints (cloud_);
-        tracker_->setPointsToTrack (points_);
-      }
+  OpenNIViewer(pcl::Grabber& grabber)
+  : grabber_(grabber), rgb_data_(nullptr), rgb_data_size_(0)
+  {}
 
-      // }
-      tracker_->compute ();
-      ++counter_;
-    }
+  void
+  detect_keypoints(const CloudConstPtr& cloud)
+  {
+    pcl::HarrisKeypoint2D<PointType, pcl::PointXYZI> harris;
+    harris.setInputCloud(cloud);
+    harris.setNumberOfThreads(6);
+    harris.setNonMaxSupression(true);
+    harris.setRadiusSearch(0.01);
+    harris.setMethod(pcl::HarrisKeypoint2D<PointType, pcl::PointXYZI>::TOMASI);
+    harris.setThreshold(0.05);
+    harris.setWindowWidth(5);
+    harris.setWindowHeight(5);
+    pcl::PointCloud<pcl::PointXYZI>::Ptr response(new pcl::PointCloud<pcl::PointXYZI>);
+    harris.compute(*response);
+    points_ = harris.getKeypointsIndices();
+  }
 
-    void
-    image_callback (const openni_wrapper::Image::Ptr& image)
-    {
-      FPS_CALC ("image callback");
-      std::lock_guard<std::mutex> lock (image_mutex_);
-      image_ = image;
-
-      if (image->getEncoding () != openni_wrapper::Image::RGB)
-      {
-        if (rgb_data_size_ < image->getWidth () * image->getHeight ())
-        {
-          if (rgb_data_)
-            delete [] rgb_data_;
-          rgb_data_size_ = image->getWidth () * image->getHeight ();
-          rgb_data_ = new unsigned char [rgb_data_size_ * 3];
-        }
-        image_->fillRGB (image_->getWidth (), image_->getHeight (), rgb_data_);
-      }
+  void
+  cloud_callback(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("cloud callback");
+    std::lock_guard<std::mutex> lock(cloud_mutex_);
+    cloud_ = cloud;
+    // Compute Tomasi keypoints
+    tracker_->setInputCloud(cloud_);
+    if (!points_ || (counter_ % 10 == 0)) {
+      detect_keypoints(cloud_);
+      tracker_->setPointsToTrack(points_);
     }
+    tracker_->compute();
+    ++counter_;
+  }
 
-    void
-    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      static pcl::PCDWriter writer;
-      static std::ostringstream frame;
-      if (event.keyUp ())
-      {
-        if ((event.getKeyCode () == 's') || (event.getKeyCode () == 'S'))
-        {
-          std::lock_guard<std::mutex> lock (cloud_mutex_);
-          frame.str ("frame-");
-          frame << boost::posix_time::to_iso_string (boost::posix_time::microsec_clock::local_time ()) << ".pcd";
-          writer.writeBinaryCompressed (frame.str (), *cloud_);
-          PCL_INFO ("Written cloud %s.\n", frame.str ().c_str ());
-        }
+  void
+  image_callback(const openni_wrapper::Image::Ptr& image)
+  {
+    FPS_CALC("image callback");
+    std::lock_guard<std::mutex> lock(image_mutex_);
+    image_ = image;
+
+    if (image->getEncoding() != openni_wrapper::Image::RGB) {
+      if (rgb_data_size_ < image->getWidth() * image->getHeight()) {
+        delete[] rgb_data_;
+        rgb_data_size_ = image->getWidth() * image->getHeight();
+        rgb_data_ = new unsigned char[rgb_data_size_ * 3];
       }
+      image_->fillRGB(image_->getWidth(), image_->getHeight(), rgb_data_);
     }
+  }
 
-    void
-    mouse_callback (const pcl::visualization::MouseEvent& mouse_event, void*)
-    {
-      if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress && mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton)
-      {
-        std::cout << "left button pressed @ " << mouse_event.getX () << " , " << mouse_event.getY () << std::endl;
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    static pcl::PCDWriter writer;
+    static std::ostringstream frame;
+    if (event.keyUp()) {
+      if ((event.getKeyCode() == 's') || (event.getKeyCode() == 'S')) {
+        std::lock_guard<std::mutex> lock(cloud_mutex_);
+        frame.str("frame-");
+        frame << boost::posix_time::to_iso_string(
+                     boost::posix_time::microsec_clock::local_time())
+              << ".pcd";
+        writer.writeBinaryCompressed(frame.str(), *cloud_);
+        PCL_INFO("Written cloud %s.\n", frame.str().c_str());
       }
     }
+  }
 
-    /**
-     * @brief starts the main loop
-     */
-    void
-    run ()
-    {
-      std::function<void (const CloudConstPtr&) > cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback (cloud); };
-      boost::signals2::connection cloud_connection = grabber_.registerCallback (cloud_cb);
-
-      boost::signals2::connection image_connection;
-      if (grabber_.providesCallback<void (const openni_wrapper::Image::Ptr&)>())
-      {
-        image_viewer_.reset (new pcl::visualization::ImageViewer ("Pyramidal KLT Tracker"));
-        std::function<void (const openni_wrapper::Image::Ptr&) > image_cb = [this] (const openni_wrapper::Image::Ptr& img) { image_callback (img); };
-        image_connection = grabber_.registerCallback (image_cb);
-      }
+  void
+  mouse_callback(const pcl::visualization::MouseEvent& mouse_event, void*)
+  {
+    if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress &&
+        mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton) {
+      std::cout << "left button pressed @ " << mouse_event.getX() << " , "
+                << mouse_event.getY() << std::endl;
+    }
+  }
 
-      tracker_.reset (new pcl::tracking::PyramidalKLTTracker<PointType>);
+  /**
+   * \brief starts the main loop
+   */
+  void
+  run()
+  {
+    std::function<void(const CloudConstPtr&)> cloud_cb =
+        [this](const CloudConstPtr& cloud) { cloud_callback(cloud); };
+    boost::signals2::connection cloud_connection = grabber_.registerCallback(cloud_cb);
+
+    boost::signals2::connection image_connection;
+    if (grabber_.providesCallback<void(const openni_wrapper::Image::Ptr&)>()) {
+      image_viewer_.reset(new pcl::visualization::ImageViewer("Pyramidal KLT Tracker"));
+      std::function<void(const openni_wrapper::Image::Ptr&)> image_cb =
+          [this](const openni_wrapper::Image::Ptr& img) { image_callback(img); };
+      image_connection = grabber_.registerCallback(image_cb);
+    }
 
-      bool image_init = false;
+    tracker_.reset(new pcl::tracking::PyramidalKLTTracker<PointType>);
 
-      grabber_.start ();
+    bool image_init = false;
 
-      while (!image_viewer_->wasStopped ())
-      {
-        openni_wrapper::Image::Ptr image;
-        CloudConstPtr cloud;
+    grabber_.start();
 
-        // See if we can get a cloud
-        if (cloud_mutex_.try_lock ())
-        {
-          cloud_.swap (cloud);
-          cloud_mutex_.unlock ();
-        }
+    while (!image_viewer_->wasStopped()) {
+      openni_wrapper::Image::Ptr image;
+      CloudConstPtr cloud;
 
-        // See if we can get an image
-        if (image_mutex_.try_lock ())
-        {
-          image_.swap (image);
-          image_mutex_.unlock ();
-        }
+      // See if we can get a cloud
+      if (cloud_mutex_.try_lock()) {
+        cloud_.swap(cloud);
+        cloud_mutex_.unlock();
+      }
 
-        if (image)
-        {
-          if (!image_init && cloud && cloud->width != 0)
-          {
-            image_viewer_->setPosition (0, 0);
-            image_viewer_->setSize (cloud->width, cloud->height);
-            image_init = true;
-          }
+      // See if we can get an image
+      if (image_mutex_.try_lock()) {
+        image_.swap(image);
+        image_mutex_.unlock();
+      }
 
-          if (image->getEncoding() == openni_wrapper::Image::RGB)
-            image_viewer_->addRGBImage (image->getMetaData ().Data (), image->getWidth (), image->getHeight ());
-          else
-            image_viewer_->addRGBImage (rgb_data_, image->getWidth (), image->getHeight ());
-          image_viewer_->spinOnce ();
+      if (image) {
+        if (!image_init && cloud && cloud->width != 0) {
+          image_viewer_->setPosition(0, 0);
+          image_viewer_->setSize(cloud->width, cloud->height);
+          image_init = true;
         }
 
-        if (tracker_->getInitialized () && cloud_)
-        {
-          if (points_mutex_.try_lock ())
-          {
-            keypoints_ = tracker_->getTrackedPoints ();
-            points_status_ = tracker_->getPointsToTrackStatus ();
-            points_mutex_.unlock ();
-          }
+        if (image->getEncoding() == openni_wrapper::Image::RGB)
+          image_viewer_->addRGBImage(
+              image->getMetaData().Data(), image->getWidth(), image->getHeight());
+        else
+          image_viewer_->addRGBImage(rgb_data_, image->getWidth(), image->getHeight());
+        image_viewer_->spinOnce();
+      }
 
-          std::vector<float> markers;
-          markers.reserve (keypoints_->size () * 2);
-          for (std::size_t i = 0; i < keypoints_->size (); ++i)
-          {
-            if (points_status_->indices[i] < 0)
-              continue;
-            const pcl::PointUV &uv = keypoints_->points[i];
-            markers.push_back (uv.u);
-            markers.push_back (uv.v);
-          }
-          image_viewer_->removeLayer ("tracked");
-          image_viewer_->markPoints (markers, pcl::visualization::blue_color,
-                                     pcl::visualization::red_color, 5, "tracked", 1.0);
+      if (tracker_->getInitialized() && cloud_) {
+        if (points_mutex_.try_lock()) {
+          keypoints_ = tracker_->getTrackedPoints();
+          points_status_ = tracker_->getPointsToTrackStatus();
+          points_mutex_.unlock();
+        }
 
+        std::vector<float> markers;
+        markers.reserve(keypoints_->size() * 2);
+        for (std::size_t i = 0; i < keypoints_->size(); ++i) {
+          if (points_status_->indices[i] < 0)
+            continue;
+          const pcl::PointUV& uv = keypoints_->points[i];
+          markers.push_back(uv.u);
+          markers.push_back(uv.v);
         }
+        image_viewer_->removeLayer("tracked");
+        image_viewer_->markPoints(markers,
+                                  pcl::visualization::blue_color,
+                                  pcl::visualization::red_color,
+                                  5,
+                                  "tracked",
+                                  1.0);
       }
+    }
 
-      grabber_.stop ();
+    grabber_.stop();
 
-      cloud_connection.disconnect ();
-      image_connection.disconnect ();
-      if (rgb_data_)
-        delete[] rgb_data_;
-    }
+    cloud_connection.disconnect();
+    image_connection.disconnect();
+    delete[] rgb_data_;
+  }
 
-    pcl::visualization::ImageViewer::Ptr image_viewer_;
-
-    pcl::Grabber& grabber_;
-    std::mutex cloud_mutex_;
-    std::mutex image_mutex_;
-    std::mutex points_mutex_;
-
-    CloudConstPtr cloud_;
-    openni_wrapper::Image::Ptr image_;
-    unsigned char* rgb_data_;
-    unsigned rgb_data_size_;
-    typename pcl::tracking::PyramidalKLTTracker<PointType>::Ptr tracker_;
-    pcl::PointCloud<pcl::PointUV>::ConstPtr keypoints_;
-    pcl::PointIndicesConstPtr points_;
-    pcl::PointIndicesConstPtr points_status_;
-    int counter_;
+  pcl::visualization::ImageViewer::Ptr image_viewer_;
+
+  pcl::Grabber& grabber_;
+  std::mutex cloud_mutex_;
+  std::mutex image_mutex_;
+  std::mutex points_mutex_;
+
+  CloudConstPtr cloud_;
+  openni_wrapper::Image::Ptr image_;
+  unsigned char* rgb_data_;
+  unsigned rgb_data_size_;
+  typename pcl::tracking::PyramidalKLTTracker<PointType>::Ptr tracker_;
+  pcl::PointCloud<pcl::PointUV>::ConstPtr keypoints_;
+  pcl::PointIndicesConstPtr points_;
+  pcl::PointIndicesConstPtr points_status_;
+  int counter_;
 };
 
 // Create the PCLVisualizer object
@@ -315,66 +304,72 @@ pcl::visualization::ImageViewer::Ptr img;
 
 /* ---[ */
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
   std::string device_id;
   pcl::OpenNIGrabber::Mode depth_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
   pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
   bool xyz = false;
 
-  if (argc >= 2)
-  {
+  if (argc >= 2) {
     device_id = argv[1];
-    if (device_id == "--help" || device_id == "-h")
-    {
+    if (device_id == "--help" || device_id == "-h") {
       printHelp(argc, argv);
       return 0;
     }
-    if (device_id == "-l")
-    {
-      if (argc >= 3)
-      {
+    if (device_id == "-l") {
+      if (argc >= 3) {
         pcl::OpenNIGrabber grabber(argv[2]);
         auto device = grabber.getDevice();
-        std::cout << "Supported depth modes for device: " << device->getVendorName() << " , " << device->getProductName() << std::endl;
-        std::vector<std::pair<int, XnMapOutputMode > > modes = grabber.getAvailableDepthModes();
-        for (std::vector<std::pair<int, XnMapOutputMode > >::const_iterator it = modes.begin(); it != modes.end(); ++it)
-        {
-          std::cout << it->first << " = " << it->second.nXRes << " x " << it->second.nYRes << " @ " << it->second.nFPS << std::endl;
+        std::cout << "Supported depth modes for device: " << device->getVendorName()
+                  << " , " << device->getProductName() << std::endl;
+        std::vector<std::pair<int, XnMapOutputMode>> modes =
+            grabber.getAvailableDepthModes();
+        for (std::vector<std::pair<int, XnMapOutputMode>>::const_iterator it =
+                 modes.begin();
+             it != modes.end();
+             ++it) {
+          std::cout << it->first << " = " << it->second.nXRes << " x "
+                    << it->second.nYRes << " @ " << it->second.nFPS << std::endl;
         }
 
-        if (device->hasImageStream ())
-        {
-          std::cout << std::endl << "Supported image modes for device: " << device->getVendorName() << " , " << device->getProductName() << std::endl;
+        if (device->hasImageStream()) {
+          std::cout << std::endl
+                    << "Supported image modes for device: " << device->getVendorName()
+                    << " , " << device->getProductName() << std::endl;
           modes = grabber.getAvailableImageModes();
-          for (std::vector<std::pair<int, XnMapOutputMode > >::const_iterator it = modes.begin(); it != modes.end(); ++it)
-          {
-            std::cout << it->first << " = " << it->second.nXRes << " x " << it->second.nYRes << " @ " << it->second.nFPS << std::endl;
+          for (std::vector<std::pair<int, XnMapOutputMode>>::const_iterator it =
+                   modes.begin();
+               it != modes.end();
+               ++it) {
+            std::cout << it->first << " = " << it->second.nXRes << " x "
+                      << it->second.nYRes << " @ " << it->second.nFPS << std::endl;
           }
         }
       }
-      else
-      {
-        openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
-        if (driver.getNumberDevices() > 0)
-        {
-          for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx)
-          {
-            std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName(deviceIdx) << ", product: " << driver.getProductName(deviceIdx)
-              << ", connected: " << driver.getBus(deviceIdx) << " @ " << driver.getAddress(deviceIdx) << ", serial number: \'" << driver.getSerialNumber(deviceIdx) << "\'" << std::endl;
+      else {
+        openni_wrapper::OpenNIDriver& driver =
+            openni_wrapper::OpenNIDriver::getInstance();
+        if (driver.getNumberDevices() > 0) {
+          for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices();
+               ++deviceIdx) {
+            std::cout << "Device: " << deviceIdx + 1
+                      << ", vendor: " << driver.getVendorName(deviceIdx)
+                      << ", product: " << driver.getProductName(deviceIdx)
+                      << ", connected: " << driver.getBus(deviceIdx) << " @ "
+                      << driver.getAddress(deviceIdx) << ", serial number: \'"
+                      << driver.getSerialNumber(deviceIdx) << "\'" << std::endl;
           }
-
         }
         else
           std::cout << "No devices connected." << std::endl;
 
-        std::cout <<"Virtual Devices available: ONI player" << std::endl;
+        std::cout << "Virtual Devices available: ONI player" << std::endl;
       }
       return 0;
     }
   }
-  else
-  {
+  else {
     openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
     if (driver.getNumberDevices() > 0)
       std::cout << "Device Id not set, using first device." << std::endl;
@@ -382,27 +377,26 @@ main (int argc, char** argv)
 
   unsigned mode;
   if (pcl::console::parse(argc, argv, "-depthmode", mode) != -1)
-    depth_mode = pcl::OpenNIGrabber::Mode (mode);
+    depth_mode = pcl::OpenNIGrabber::Mode(mode);
 
   if (pcl::console::parse(argc, argv, "-imagemode", mode) != -1)
-    image_mode = pcl::OpenNIGrabber::Mode (mode);
+    image_mode = pcl::OpenNIGrabber::Mode(mode);
 
-  if (pcl::console::find_argument (argc, argv, "-xyz") != -1)
+  if (pcl::console::find_argument(argc, argv, "-xyz") != -1)
     xyz = true;
 
-  pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);
+  pcl::OpenNIGrabber grabber(device_id, depth_mode, image_mode);
 
-  if (xyz || !grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb> ())
-  {
-    OpenNIViewer<pcl::PointXYZ> openni_viewer (grabber);
-    openni_viewer.run ();
+  if (xyz ||
+      !grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb>()) {
+    OpenNIViewer<pcl::PointXYZ> openni_viewer(grabber);
+    openni_viewer.run();
   }
-  else
-  {
-    OpenNIViewer<pcl::PointXYZRGBA> openni_viewer (grabber);
-    openni_viewer.run ();
+  else {
+    OpenNIViewer<pcl::PointXYZRGBA> openni_viewer(grabber);
+    openni_viewer.run();
   }
 
-  return (0);
+  return 0;
 }
 /* ]--- */
index e389b2c6cb904299c084b81cb975eb5722abfd46..a13edff6a738e5c226604c0efed997be60c3cab9 100644 (file)
  *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/console/parse.h>
 #include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/io/openni_grabber.h>
 #include <pcl/surface/mls.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-      if (*stop_computing_) std::cout << "Press 's' to start computing!\n"; \
-    } \
-}while(false)
-
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+      if (*stop_computing_)                                                            \
+        std::cout << "Press 's' to start computing!\n";                                \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 int default_polynomial_order = 0;
-double default_search_radius = 0.0,
-    default_sqr_gauss_param = 0.0;
+double default_search_radius = 0.0, default_sqr_gauss_param = 0.0;
 
 template <typename PointType>
 class OpenNISmoothing;
 
-
-void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
-                            void *stop_void)
+void
+keyboardEventOccurred(const pcl::visualization::KeyboardEvent& event, void* stop_void)
 {
-  std::shared_ptr<bool> stop = *static_cast<std::shared_ptr<bool>*> (stop_void);
-  if (event.getKeySym () == "s" && event.keyDown ())
-  {
-    *stop = ! *stop;
-    if (*stop) std::cout << "Computing is now stopped!\n";
-    else std::cout << "Computing commencing!\n";
+  std::shared_ptr<bool> stop = *static_cast<std::shared_ptr<bool>*>(stop_void);
+  if (event.getKeySym() == "s" && event.keyDown()) {
+    *stop = !*stop;
+    if (*stop)
+      std::cout << "Computing is now stopped!\n";
+    else
+      std::cout << "Computing commencing!\n";
   }
 }
 
 template <typename PointType>
-class OpenNISmoothing
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNISmoothing (double search_radius, bool sqr_gauss_param_set, double sqr_gauss_param,
-                     int polynomial_order, const std::string& device_id = "")
-    : viewer ("PCL OpenNI MLS Smoothing")
-    , device_id_(device_id)
-    {
-      // Start 4 threads
-      smoother_.setSearchRadius (search_radius);
-      if (sqr_gauss_param_set) smoother_.setSqrGaussParam (sqr_gauss_param);
-      smoother_.setPolynomialOrder (polynomial_order);
-
-      typename pcl::search::KdTree<PointType>::Ptr tree (new typename pcl::search::KdTree<PointType> ());
-      smoother_.setSearchMethod (tree);
-
-      viewer.createViewPort (0.0, 0.0, 0.5, 1.0, viewport_input_);
-      viewer.setBackgroundColor (0, 0, 0, viewport_input_);
-      viewer.createViewPort (0.5, 0.0, 1.0, 1.0, viewport_smoothed_);
-      viewer.setBackgroundColor (0, 0, 0, viewport_smoothed_);
-
-      stop_computing_.reset (new bool(true));
-      cloud_.reset ();
-      cloud_smoothed_.reset (new Cloud);
-    }
+class OpenNISmoothing {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNISmoothing(double search_radius,
+                  bool sqr_gauss_param_set,
+                  double sqr_gauss_param,
+                  int polynomial_order,
+                  const std::string& device_id = "")
+  : viewer("PCL OpenNI MLS Smoothing"), device_id_(device_id)
+  {
+    // Start 4 threads
+    smoother_.setSearchRadius(search_radius);
+    if (sqr_gauss_param_set)
+      smoother_.setSqrGaussParam(sqr_gauss_param);
+    smoother_.setPolynomialOrder(polynomial_order);
+
+    typename pcl::search::KdTree<PointType>::Ptr tree(
+        new typename pcl::search::KdTree<PointType>());
+    smoother_.setSearchMethod(tree);
+
+    viewer.createViewPort(0.0, 0.0, 0.5, 1.0, viewport_input_);
+    viewer.setBackgroundColor(0, 0, 0, viewport_input_);
+    viewer.createViewPort(0.5, 0.0, 1.0, 1.0, viewport_smoothed_);
+    viewer.setBackgroundColor(0, 0, 0, viewport_smoothed_);
+
+    stop_computing_.reset(new bool(true));
+    cloud_.reset();
+    cloud_smoothed_.reset(new Cloud);
+  }
 
-    void
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      FPS_CALC ("computation");
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    FPS_CALC("computation");
 
-      mtx_.lock ();
-      if (! *stop_computing_)
-      {
-        smoother_.setInputCloud (cloud);
-        smoother_.process (*cloud_smoothed_);
-      }
-      cloud_ = cloud;
-      mtx_.unlock ();
+    mtx_.lock();
+    if (!*stop_computing_) {
+      smoother_.setInputCloud(cloud);
+      smoother_.process(*cloud_smoothed_);
     }
+    cloud_ = cloud;
+    mtx_.unlock();
+  }
 
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
-
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
-
-      viewer.registerKeyboardCallback (keyboardEventOccurred, reinterpret_cast<void*> (&stop_computing_));
-
+    viewer.registerKeyboardCallback(keyboardEventOccurred,
+                                    reinterpret_cast<void*>(&stop_computing_));
 
-      interface.start ();
+    interface.start();
 
-      while (!viewer.wasStopped ())
-      {
-        FPS_CALC ("visualization");
-        viewer.spinOnce ();
+    while (!viewer.wasStopped()) {
+      FPS_CALC("visualization");
+      viewer.spinOnce();
 
-        if (cloud_ && mtx_.try_lock ())
-        {
-          if (!viewer.updatePointCloud (cloud_, "input_cloud"))
-            viewer.addPointCloud (cloud_, "input_cloud", viewport_input_);
-          if (! *stop_computing_ && !viewer.updatePointCloud (cloud_smoothed_, "smoothed_cloud"))
-            viewer.addPointCloud (cloud_smoothed_, "smoothed_cloud", viewport_smoothed_);
-          mtx_.unlock ();
-        }
+      if (cloud_ && mtx_.try_lock()) {
+        if (!viewer.updatePointCloud(cloud_, "input_cloud"))
+          viewer.addPointCloud(cloud_, "input_cloud", viewport_input_);
+        if (!*stop_computing_ &&
+            !viewer.updatePointCloud(cloud_smoothed_, "smoothed_cloud"))
+          viewer.addPointCloud(cloud_smoothed_, "smoothed_cloud", viewport_smoothed_);
+        mtx_.unlock();
       }
-
-      interface.stop ();
     }
 
-    pcl::MovingLeastSquares<PointType, PointType> smoother_;
-    pcl::visualization::PCLVisualizer viewer;
-    std::string device_id_;
-    std::mutex mtx_;
-    CloudConstPtr cloud_;
-    CloudPtr cloud_smoothed_;
-    int viewport_input_, viewport_smoothed_;
-    std::shared_ptr<bool> stop_computing_;
+    interface.stop();
+  }
+
+  pcl::MovingLeastSquares<PointType, PointType> smoother_;
+  pcl::visualization::PCLVisualizer viewer;
+  std::string device_id_;
+  std::mutex mtx_;
+  CloudConstPtr cloud_;
+  CloudPtr cloud_smoothed_;
+  int viewport_input_, viewport_smoothed_;
+  std::shared_ptr<bool> stop_computing_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
+  // clang-format off
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n"
             << "where options are:\n"
             << "                     -search_radius X = sphere radius to be used for finding the k-nearest neighbors used for fitting (default: " << default_search_radius << ")\n"
             << "                     -sqr_gauss_param X = parameter used for the distance based weighting of neighbors (recommended = search_radius^2) (default: " << default_sqr_gauss_param << ")\n"
             << "                     -polynomial_order X = order of the polynomial to be fit (0 means tangent estimation) (default: " << default_polynomial_order << ")\n";
+  // clang-format on
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -196,19 +199,17 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
-  if (argc < 2)
-  {
-    usage (argv);
+  if (argc < 2) {
+    usage(argv);
     return 1;
   }
 
-  std::string arg (argv[1]);
+  std::string arg(argv[1]);
 
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
@@ -218,24 +219,23 @@ main (int argc, char ** argv)
   bool sqr_gauss_param_set = true;
   int polynomial_order = default_polynomial_order;
 
-  pcl::console::parse_argument (argc, argv, "-search_radius", search_radius);
-  if (pcl::console::parse_argument (argc, argv, "-sqr_gauss_param", sqr_gauss_param) == -1)
+  pcl::console::parse_argument(argc, argv, "-search_radius", search_radius);
+  if (pcl::console::parse_argument(argc, argv, "-sqr_gauss_param", sqr_gauss_param) ==
+      -1)
     sqr_gauss_param_set = false;
-  pcl::console::parse_argument (argc, argv, "-polynomial_order", polynomial_order);
+  pcl::console::parse_argument(argc, argv, "-polynomial_order", polynomial_order);
 
-  pcl::OpenNIGrabber grabber (arg);
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    OpenNISmoothing<pcl::PointXYZRGBA> v (search_radius, sqr_gauss_param_set, sqr_gauss_param, 
-                                          polynomial_order, arg);
-    v.run ();
+  pcl::OpenNIGrabber grabber(arg);
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    OpenNISmoothing<pcl::PointXYZRGBA> v(
+        search_radius, sqr_gauss_param_set, sqr_gauss_param, polynomial_order, arg);
+    v.run();
   }
-  else
-  {
-    OpenNISmoothing<pcl::PointXYZ> v (search_radius, sqr_gauss_param_set, sqr_gauss_param,
-                                      polynomial_order, arg);
-    v.run ();
+  else {
+    OpenNISmoothing<pcl::PointXYZ> v(
+        search_radius, sqr_gauss_param_set, sqr_gauss_param, polynomial_order, arg);
+    v.run();
   }
 
-  return (0);
+  return 0;
 }
index 2c272adb50294bc912bd380a31a0474b86fc047a..a678f5ddde25fda4cecd21d0782c1ca510575efc 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  *
  */
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <boost/asio.hpp>
 
 #include <mutex>
 #include <thread>
 
-
 using boost::asio::ip::tcp;
 using namespace std::chrono_literals;
 
-struct PointCloudBuffers
-{
+struct PointCloudBuffers {
   using Ptr = std::shared_ptr<PointCloudBuffers>;
   std::vector<short> points;
   std::vector<unsigned char> rgb;
 };
 
 void
-CopyPointCloudToBuffers (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud, PointCloudBuffers& cloud_buffers)
+CopyPointCloudToBuffers(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud,
+                        PointCloudBuffers& cloud_buffers)
 {
-  const std::size_t nr_points = cloud->points.size ();
+  const std::size_t nr_points = cloud->points.size();
 
-  cloud_buffers.points.resize (nr_points*3);
-  cloud_buffers.rgb.resize (nr_points*3);
+  cloud_buffers.points.resize(nr_points * 3);
+  cloud_buffers.rgb.resize(nr_points * 3);
 
-  const pcl::PointXYZ  bounds_min (-0.9f, -0.8f, 1.0f);
-  const pcl::PointXYZ  bounds_max (0.9f, 3.0f, 3.3f);
+  const pcl::PointXYZ bounds_min(-0.9f, -0.8f, 1.0f);
+  const pcl::PointXYZ bounds_max(0.9f, 3.0f, 3.3f);
 
   std::size_t j = 0;
-  for (std::size_t i = 0; i < nr_points; ++i)
-  {
+  for (std::size_t i = 0; i < nr_points; ++i) {
 
     const pcl::PointXYZRGBA& point = cloud->points[i];
 
-    if (!std::isfinite (point.x) || 
-        !std::isfinite (point.y) || 
-        !std::isfinite (point.z))
+    if (!std::isfinite(point.x) || !std::isfinite(point.y) || !std::isfinite(point.z))
       continue;
 
-    if (point.x < bounds_min.x ||
-        point.y < bounds_min.y ||
-        point.z < bounds_min.z ||
-        point.x > bounds_max.x ||
-        point.y > bounds_max.y ||
-        point.z > bounds_max.z)
+    if (point.x < bounds_min.x || point.y < bounds_min.y || point.z < bounds_min.z ||
+        point.x > bounds_max.x || point.y > bounds_max.y || point.z > bounds_max.z)
       continue;
 
     const int conversion_factor = 500;
 
-    cloud_buffers.points[j*3 + 0] = static_cast<short> (point.x * conversion_factor);
-    cloud_buffers.points[j*3 + 1] = static_cast<short> (point.y * conversion_factor);
-    cloud_buffers.points[j*3 + 2] = static_cast<short> (point.z * conversion_factor);
+    cloud_buffers.points[j * 3 + 0] = static_cast<short>(point.x * conversion_factor);
+    cloud_buffers.points[j * 3 + 1] = static_cast<short>(point.y * conversion_factor);
+    cloud_buffers.points[j * 3 + 2] = static_cast<short>(point.z * conversion_factor);
 
-    cloud_buffers.rgb[j*3 + 0] = point.r;
-    cloud_buffers.rgb[j*3 + 1] = point.g;
-    cloud_buffers.rgb[j*3 + 2] = point.b;
+    cloud_buffers.rgb[j * 3 + 0] = point.r;
+    cloud_buffers.rgb[j * 3 + 1] = point.g;
+    cloud_buffers.rgb[j * 3 + 2] = point.b;
 
     j++;
   }
 
-  cloud_buffers.points.resize (j * 3);
-  cloud_buffers.rgb.resize (j * 3);
+  cloud_buffers.points.resize(j * 3);
+  cloud_buffers.rgb.resize(j * 3);
 }
 
-
 template <typename PointType>
-class PCLMobileServer
-{
-  public:
-
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    PCLMobileServer (const std::string& device_id = "", int port = 11111,
-                     float leaf_size_x = 0.01, float leaf_size_y = 0.01, float leaf_size_z = 0.01)
-    : port_ (port),
-      device_id_ (device_id),
-      viewer_ ("PCL OpenNI Mobile Server")
-    {
-      voxel_grid_filter_.setLeafSize (leaf_size_x, leaf_size_y, leaf_size_z);
-    }
-    
-    void
-    handleIncomingCloud (const CloudConstPtr& new_cloud)
-    {
-      CloudPtr temp_cloud (new Cloud);
-      voxel_grid_filter_.setInputCloud (new_cloud);
-      voxel_grid_filter_.filter (*temp_cloud);
-
-      PointCloudBuffers::Ptr new_buffers = PointCloudBuffers::Ptr (new PointCloudBuffers);
-      CopyPointCloudToBuffers (temp_cloud, *new_buffers);
-
-      std::lock_guard<std::mutex> lock (mutex_);
-      filtered_cloud_ = temp_cloud;
-      buffers_ = new_buffers;
-    }
+class PCLMobileServer {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  PCLMobileServer(const std::string& device_id = "",
+                  int port = 11111,
+                  float leaf_size_x = 0.01,
+                  float leaf_size_y = 0.01,
+                  float leaf_size_z = 0.01)
+  : port_(port), device_id_(device_id), viewer_("PCL OpenNI Mobile Server")
+  {
+    voxel_grid_filter_.setLeafSize(leaf_size_x, leaf_size_y, leaf_size_z);
+  }
 
-    PointCloudBuffers::Ptr
-    getLatestBuffers ()
-    {
-      std::lock_guard<std::mutex> lock (mutex_);
-      return (buffers_);
-    }
+  void
+  handleIncomingCloud(const CloudConstPtr& new_cloud)
+  {
+    CloudPtr temp_cloud(new Cloud);
+    voxel_grid_filter_.setInputCloud(new_cloud);
+    voxel_grid_filter_.filter(*temp_cloud);
 
-    CloudPtr
-    getLatestPointCloud ()
-    {
-      std::lock_guard<std::mutex> lock (mutex_);
-      return (filtered_cloud_);
-    }
+    PointCloudBuffers::Ptr new_buffers = PointCloudBuffers::Ptr(new PointCloudBuffers);
+    CopyPointCloudToBuffers(temp_cloud, *new_buffers);
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber grabber (device_id_);
-      std::function<void (const CloudConstPtr&)> handler_function = [this] (const CloudConstPtr& cloud) { handleIncomingCloud (cloud); };
-      grabber.registerCallback (handler_function);
-      grabber.start ();
+    std::lock_guard<std::mutex> lock(mutex_);
+    filtered_cloud_ = temp_cloud;
+    buffers_ = new_buffers;
+  }
 
-      // wait for first cloud
-      while (!getLatestPointCloud ())
-        std::this_thread::sleep_for(10ms);
+  PointCloudBuffers::Ptr
+  getLatestBuffers()
+  {
+    std::lock_guard<std::mutex> lock(mutex_);
+    return buffers_;
+  }
 
-      viewer_.showCloud (getLatestPointCloud ());
+  CloudPtr
+  getLatestPointCloud()
+  {
+    std::lock_guard<std::mutex> lock(mutex_);
+    return filtered_cloud_;
+  }
 
+  void
+  run()
+  {
+    pcl::OpenNIGrabber grabber(device_id_);
+    std::function<void(const CloudConstPtr&)> handler_function =
+        [this](const CloudConstPtr& cloud) { handleIncomingCloud(cloud); };
+    grabber.registerCallback(handler_function);
+    grabber.start();
 
-      boost::asio::io_service io_service;
-      tcp::endpoint endpoint (tcp::v4 (), static_cast<unsigned short> (port_));
-      tcp::acceptor acceptor (io_service, endpoint);
-      tcp::socket socket (io_service);
+    // wait for first cloud
+    while (!getLatestPointCloud())
+      std::this_thread::sleep_for(10ms);
 
-      std::cout << "Listening on port " << port_ << "..." << std::endl;
-      acceptor.accept (socket);
+    viewer_.showCloud(getLatestPointCloud());
 
-      std::cout << "Client connected." << std::endl;
+    boost::asio::io_service io_service;
+    tcp::endpoint endpoint(tcp::v4(), static_cast<unsigned short>(port_));
+    tcp::acceptor acceptor(io_service, endpoint);
+    tcp::socket socket(io_service);
 
-      double start_time = pcl::getTime ();
-      int counter = 0;
+    std::cout << "Listening on port " << port_ << "..." << std::endl;
+    acceptor.accept(socket);
 
-      while (!viewer_.wasStopped ())
-      {
+    std::cout << "Client connected." << std::endl;
 
-        // wait for client
-        unsigned int nr_points = 0;
-        boost::asio::read (socket, boost::asio::buffer (&nr_points, sizeof (nr_points)));
+    double start_time = pcl::getTime();
+    int counter = 0;
 
-        PointCloudBuffers::Ptr buffers_to_send = getLatestBuffers ();
+    while (!viewer_.wasStopped()) {
 
-        nr_points = static_cast<unsigned int> (buffers_to_send->points.size()/3);
-        boost::asio::write (socket, boost::asio::buffer (&nr_points, sizeof (nr_points)));
+      // wait for client
+      unsigned int nr_points = 0;
+      boost::asio::read(socket, boost::asio::buffer(&nr_points, sizeof(nr_points)));
 
-        if (nr_points)
-        {
-          boost::asio::write (socket, boost::asio::buffer (&buffers_to_send->points.front(), nr_points * 3 * sizeof (short)));
-          boost::asio::write (socket, boost::asio::buffer (&buffers_to_send->rgb.front(), nr_points * 3 * sizeof (unsigned char)));
-        }
+      PointCloudBuffers::Ptr buffers_to_send = getLatestBuffers();
 
-        counter++;
+      nr_points = static_cast<unsigned int>(buffers_to_send->points.size() / 3);
+      boost::asio::write(socket, boost::asio::buffer(&nr_points, sizeof(nr_points)));
 
-        double new_time = pcl::getTime ();
-        double elapsed_time = new_time - start_time;
-        if (elapsed_time > 1.0)
-        {
-          double frames_per_second = counter / elapsed_time;
-          start_time = new_time;
-          counter = 0;
-          std::cout << "fps: " << frames_per_second << std::endl;
-        }
+      if (nr_points) {
+        boost::asio::write(socket,
+                           boost::asio::buffer(&buffers_to_send->points.front(),
+                                               nr_points * 3 * sizeof(short)));
+        boost::asio::write(socket,
+                           boost::asio::buffer(&buffers_to_send->rgb.front(),
+                                               nr_points * 3 * sizeof(unsigned char)));
+      }
 
-        viewer_.showCloud (getLatestPointCloud ());
+      counter++;
+
+      double new_time = pcl::getTime();
+      double elapsed_time = new_time - start_time;
+      if (elapsed_time > 1.0) {
+        double frames_per_second = counter / elapsed_time;
+        start_time = new_time;
+        counter = 0;
+        std::cout << "fps: " << frames_per_second << std::endl;
       }
 
-      grabber.stop ();
+      viewer_.showCloud(getLatestPointCloud());
     }
 
-    int port_;
-    std::string device_id_;
-    std::mutex mutex_;
+    grabber.stop();
+  }
 
-    pcl::VoxelGrid<PointType> voxel_grid_filter_;
-    pcl::visualization::CloudViewer viewer_;
+  int port_;
+  std::string device_id_;
+  std::mutex mutex_;
 
-    CloudPtr filtered_cloud_;
-    PointCloudBuffers::Ptr buffers_;
+  pcl::VoxelGrid<PointType> voxel_grid_filter_;
+  pcl::visualization::CloudViewer viewer_;
+
+  CloudPtr filtered_cloud_;
+  PointCloudBuffers::Ptr buffers_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <options>\n"
             << "where options are:\n"
@@ -236,34 +228,31 @@ usage (char ** argv)
             << "  -leaf x, y, z  :: set the voxel grid leaf size (default: 0.01)\n";
 }
 
-
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
-  if (pcl::console::find_argument (argc, argv, "-h") != -1)
-  {
-    usage (argv);
-    return (0);
+  if (pcl::console::find_argument(argc, argv, "-h") != -1) {
+    usage(argv);
+    return 0;
   }
 
   int port = 11111;
   float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f;
   std::string device_id;
 
-  pcl::console::parse_argument (argc, argv, "-port", port);
-  pcl::console::parse_3x_arguments (argc, argv, "-leaf", leaf_x, leaf_y, leaf_z, false);
+  pcl::console::parse_argument(argc, argv, "-port", port);
+  pcl::console::parse_3x_arguments(argc, argv, "-leaf", leaf_x, leaf_y, leaf_z, false);
 
-  pcl::OpenNIGrabber grabber ("");
-  if (!grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
+  pcl::OpenNIGrabber grabber("");
+  if (!grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
     std::cout << "OpenNI grabber does not provide the rgba cloud format." << std::endl;
-    return (1);
+    return 1;
   }
 
-  PCL_INFO ("Using %f, %f, %f as a leaf size for VoxelGrid.\n", leaf_x, leaf_y, leaf_z);
+  PCL_INFO("Using %f, %f, %f as a leaf size for VoxelGrid.\n", leaf_x, leaf_y, leaf_z);
 
-  PCLMobileServer<pcl::PointXYZRGBA> server (device_id, port, leaf_x, leaf_y, leaf_z);
-  server.run ();
+  PCLMobileServer<pcl::PointXYZRGBA> server(device_id, port, leaf_x, leaf_y, leaf_z);
+  server.run();
 
-  return (0);
+  return 0;
 }
index 96871d28a0ab5e0586b75c87f02d1ce6e95e75fb..10342e2f161391b4122f2158cbd568d89869f4bd 100644 (file)
  * Author: Julius Kammerl (julius@kammerl.de)
  */
 
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/console/parse.h>
 #include <pcl/common/time.h>
+#include <pcl/compression/octree_pointcloud_compression.h>
+#include <pcl/console/parse.h>
 #include <pcl/filters/passthrough.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
-#include <pcl/compression/octree_pointcloud_compression.h>
+#include <boost/asio.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -53,8 +53,6 @@
 #include <thread>
 #include <vector>
 
-#include <boost/asio.hpp>
-
 using boost::asio::ip::tcp;
 
 using namespace pcl;
@@ -63,6 +61,7 @@ using namespace pcl::io;
 using namespace std;
 using namespace std::chrono_literals;
 
+// clang-format off
 char usage[] = "\n"
   "  PCL octree point cloud compression\n"
   "\n"
@@ -104,130 +103,134 @@ char usage[] = "\n"
   "  example:\n"
   "      ./pcl_openni_octree_compression -x -p highC -t -f pc_compressed.pcc \n"
   "\n";
-
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+// clang-format on
+
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 void
-print_usage (const std::string &msg)
+print_usage(const std::string& msg)
 {
   std::cerr << msg << std::endl;
   std::cout << usage << std::endl;
 }
 
-class SimpleOpenNIViewer
-{
-  public:
-    SimpleOpenNIViewer (ostream& outputFile_arg, OctreePointCloudCompression<PointXYZRGBA>* octreeEncoder_arg) :
-      viewer ("Input Point Cloud - PCL Compression Viewer"),
-      outputFile_(outputFile_arg), octreeEncoder_(octreeEncoder_arg)
-    {
-    }
+class SimpleOpenNIViewer {
+public:
+  SimpleOpenNIViewer(ostream& outputFile_arg,
+                     OctreePointCloudCompression<PointXYZRGBA>* octreeEncoder_arg)
+  : viewer("Input Point Cloud - PCL Compression Viewer")
+  , outputFile_(outputFile_arg)
+  , octreeEncoder_(octreeEncoder_arg)
+  {}
 
-    void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
-    {
-      if (!viewer.wasStopped ())
-      {
-        PointCloud<PointXYZRGBA>::Ptr cloudOut (new PointCloud<PointXYZRGBA>);
+  void
+  cloud_cb_(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
+  {
+    if (!viewer.wasStopped()) {
+      PointCloud<PointXYZRGBA>::Ptr cloudOut(new PointCloud<PointXYZRGBA>);
 
-        octreeEncoder_->encodePointCloud ( cloud, outputFile_);
+      octreeEncoder_->encodePointCloud(cloud, outputFile_);
 
-        viewer.showCloud (cloud);
-      }
+      viewer.showCloud(cloud);
     }
+  }
 
-    void run ()
-    {
-
-      // create a new grabber for OpenNI devices
-      pcl::OpenNIGrabber interface {};
-
-      // make callback function from member function
-      std::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
-        [this] (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) { cloud_cb_ (cloud); };
+  void
+  run()
+  {
 
-      // connect callback function for desired signal. In this case its a point cloud with color values
-      boost::signals2::connection c = interface.registerCallback (f);
+    // create a new grabber for OpenNI devices
+    pcl::OpenNIGrabber interface{};
 
-      // start receiving point clouds
-      interface.start ();
+    // make callback function from member function
+    std::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
+        [this](const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) {
+          cloud_cb_(cloud);
+        };
 
+    // connect callback function for desired signal. In this case its a point cloud with
+    // color values
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      while (!outputFile_.fail())
-      {
-        std::this_thread::sleep_for(1s);
-      }
+    // start receiving point clouds
+    interface.start();
 
-      interface.stop ();
+    while (!outputFile_.fail()) {
+      std::this_thread::sleep_for(1s);
     }
 
-    pcl::visualization::CloudViewer viewer;
-    ostream& outputFile_;
-    OctreePointCloudCompression<PointXYZRGBA>* octreeEncoder_;
+    interface.stop();
+  }
+
+  pcl::visualization::CloudViewer viewer;
+  ostream& outputFile_;
+  OctreePointCloudCompression<PointXYZRGBA>* octreeEncoder_;
 };
 
-struct EventHelper
-{
-  EventHelper (ostream& outputFile_arg, OctreePointCloudCompression<PointXYZRGBA>* octreeEncoder_arg,
-               const std::string& field_name = "z", float min_v = 0, float max_v = 3.0) :
-    outputFile_ (outputFile_arg), octreeEncoder_ (octreeEncoder_arg)
+struct EventHelper {
+  EventHelper(ostream& outputFile_arg,
+              OctreePointCloudCompression<PointXYZRGBA>* octreeEncoder_arg,
+              const std::string& field_name = "z",
+              float min_v = 0,
+              float max_v = 3.0)
+  : outputFile_(outputFile_arg), octreeEncoder_(octreeEncoder_arg)
   {
-      pass_.setFilterFieldName (field_name);
-      pass_.setFilterLimits (min_v, max_v);
+    pass_.setFilterFieldName(field_name);
+    pass_.setFilterLimits(min_v, max_v);
   }
 
   void
-  cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
+  cloud_cb_(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
   {
-    if (!outputFile_.fail ())
-    {
-      PointCloud<PointXYZRGBA>::Ptr cloud_out (new PointCloud<PointXYZRGBA>);
+    if (!outputFile_.fail()) {
+      PointCloud<PointXYZRGBA>::Ptr cloud_out(new PointCloud<PointXYZRGBA>);
 
       // Use a PassThrough filter to clean NaNs and remove data which is not interesting
-      pass_.setInputCloud (cloud);
-      pass_.filter (*cloud_out);
-      octreeEncoder_->encodePointCloud (cloud_out, outputFile_);
+      pass_.setInputCloud(cloud);
+      pass_.filter(*cloud_out);
+
+      octreeEncoder_->encodePointCloud(cloud_out, outputFile_);
     }
   }
 
   void
-  run ()
+  run()
   {
     // create a new grabber for OpenNI devices
-    pcl::OpenNIGrabber interface {};
+    pcl::OpenNIGrabber interface{};
 
     // make callback function from member function
-    std::function<void
-    (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f = [this] (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
-    {
-      cloud_cb_ (cloud);
-    };
+    std::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
+        [this](const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) {
+          cloud_cb_(cloud);
+        };
 
-    // connect callback function for desired signal. In this case its a point cloud with color values
-    boost::signals2::connection c = interface.registerCallback (f);
+    // connect callback function for desired signal. In this case its a point cloud with
+    // color values
+    boost::signals2::connection c = interface.registerCallback(f);
 
     // start receiving point clouds
-    interface.start ();
+    interface.start();
 
-    while (!outputFile_.fail ())
-    {
+    while (!outputFile_.fail()) {
       std::this_thread::sleep_for(1s);
     }
 
-    interface.stop ();
+    interface.stop();
   }
 
   pcl::PassThrough<PointXYZRGBA> pass_;
@@ -236,7 +239,7 @@ struct EventHelper
 };
 
 int
-main (int argc, char **argv)
+main(int argc, char** argv)
 {
   OctreePointCloudCompression<PointXYZRGBA>* octreeCoder;
 
@@ -276,92 +279,84 @@ main (int argc, char **argv)
   bEnDecode = false;
 
   float min_v = 0.0f, max_v = 3.0f;
-  pcl::console::parse_2x_arguments (argc, argv, "-minmax", min_v, max_v, false);
-  std::string field_name ("z");
-  pcl::console::parse_argument (argc, argv, "-field", field_name);
+  pcl::console::parse_2x_arguments(argc, argv, "-minmax", min_v, max_v, false);
+  std::string field_name("z");
+  pcl::console::parse_argument(argc, argv, "-field", field_name);
 
-  if (pcl::console::find_argument (argc, argv, "-e")>0) 
+  if (pcl::console::find_argument(argc, argv, "-e") > 0)
     bShowInputCloud = true;
 
-  if (pcl::console::find_argument (argc, argv, "-s")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-s") > 0) {
     bEnDecode = true;
     bServerFileMode = true;
     validArguments = true;
   }
 
-  if (pcl::console::parse_argument (argc, argv, "-c", hostName)>0) 
-  {
+  if (pcl::console::parse_argument(argc, argv, "-c", hostName) > 0) {
     bEnDecode = false;
     bServerFileMode = true;
     validArguments = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-x")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-x") > 0) {
     bEnDecode = true;
     bServerFileMode = false;
     validArguments = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-d")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-d") > 0) {
     bEnDecode = false;
     bServerFileMode = false;
     validArguments = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-t")>0) 
+  if (pcl::console::find_argument(argc, argv, "-t") > 0)
     showStatistics = true;
 
-  if (pcl::console::find_argument (argc, argv, "-a")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-a") > 0) {
     doColorEncoding = true;
     compressionProfile = pcl::io::MANUAL_CONFIGURATION;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-v")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-v") > 0) {
     doVoxelGridDownDownSampling = true;
     compressionProfile = pcl::io::MANUAL_CONFIGURATION;
   }
 
-  pcl::console::parse_argument (argc, argv, "-f", fileName);
-  pcl::console::parse_argument (argc, argv, "-r", pointResolution);
-  pcl::console::parse_argument (argc, argv, "-i", iFrameRate);
-  pcl::console::parse_argument (argc, argv, "-o", octreeResolution);
-  pcl::console::parse_argument (argc, argv, "-b", colorBitResolution);
+  pcl::console::parse_argument(argc, argv, "-f", fileName);
+  pcl::console::parse_argument(argc, argv, "-r", pointResolution);
+  pcl::console::parse_argument(argc, argv, "-i", iFrameRate);
+  pcl::console::parse_argument(argc, argv, "-o", octreeResolution);
+  pcl::console::parse_argument(argc, argv, "-b", colorBitResolution);
 
   std::string profile;
-  if (pcl::console::parse_argument (argc, argv, "-p", profile)>0)
-  {
+  if (pcl::console::parse_argument(argc, argv, "-p", profile) > 0) {
     if (profile == "lowC")
       compressionProfile = pcl::io::LOW_RES_OFFLINE_COMPRESSION_WITH_COLOR;
     else if (profile == "lowNC")
       compressionProfile = pcl::io::LOW_RES_OFFLINE_COMPRESSION_WITHOUT_COLOR;
     else if (profile == "medC")
       compressionProfile = pcl::io::MED_RES_OFFLINE_COMPRESSION_WITH_COLOR;
-    else if (profile =="medNC")
+    else if (profile == "medNC")
       compressionProfile = pcl::io::MED_RES_OFFLINE_COMPRESSION_WITHOUT_COLOR;
     else if (profile == "highC")
       compressionProfile = pcl::io::HIGH_RES_OFFLINE_COMPRESSION_WITH_COLOR;
     else if (profile == "highNC")
       compressionProfile = pcl::io::HIGH_RES_OFFLINE_COMPRESSION_WITHOUT_COLOR;
-    else
-    {
-      print_usage ("Unknown profile parameter..\n");
+    else {
+      print_usage("Unknown profile parameter..\n");
       return -1;
     }
 
-    if (compressionProfile != MANUAL_CONFIGURATION)
-    {
+    if (compressionProfile != MANUAL_CONFIGURATION) {
       // apply selected compression profile
       // retrieve profile settings
-      const pcl::io::configurationProfile_t selectedProfile = pcl::io::compressionProfiles_[compressionProfile];
+      const pcl::io::configurationProfile_t selectedProfile =
+          pcl::io::compressionProfiles_[compressionProfile];
 
       // apply profile settings
       pointResolution = selectedProfile.pointResolution;
-      octreeResolution = float (selectedProfile.octreeResolution);
+      octreeResolution = float(selectedProfile.octreeResolution);
       doVoxelGridDownDownSampling = selectedProfile.doVoxelGridDownSampling;
       iFrameRate = selectedProfile.iFrameRate;
       doColorEncoding = selectedProfile.doColorEncoding;
@@ -369,130 +364,115 @@ main (int argc, char **argv)
     }
   }
 
-  if (pcl::console::find_argument (argc, argv, "-?")>0) 
-  {
-    print_usage ("");
+  if (pcl::console::find_argument(argc, argv, "-?") > 0) {
+    print_usage("");
     return 1;
   }
 
-  if (!validArguments)
-  {
-    print_usage ("Please specify compression mode..\n");
+  if (!validArguments) {
+    print_usage("Please specify compression mode..\n");
     return -1;
   }
 
-  octreeCoder = new OctreePointCloudCompression<PointXYZRGBA> (compressionProfile, showStatistics, pointResolution,
-                                                               octreeResolution, doVoxelGridDownDownSampling, iFrameRate,
-                                                               doColorEncoding, static_cast<unsigned char> (colorBitResolution));
-
-
-  if (!bServerFileMode) 
-  {
-    if (bEnDecode) 
-    {
+  octreeCoder = new OctreePointCloudCompression<PointXYZRGBA>(
+      compressionProfile,
+      showStatistics,
+      pointResolution,
+      octreeResolution,
+      doVoxelGridDownDownSampling,
+      iFrameRate,
+      doColorEncoding,
+      static_cast<unsigned char>(colorBitResolution));
+
+  if (!bServerFileMode) {
+    if (bEnDecode) {
       // ENCODING
       ofstream compressedPCFile;
-      compressedPCFile.open (fileName.c_str(), ios::out | ios::trunc | ios::binary);
-
-      if (!bShowInputCloud) 
-      {
-        EventHelper v (compressedPCFile, octreeCoder, field_name, min_v, max_v);
-        v.run ();
-      } 
-      else
-      {
-        SimpleOpenNIViewer v (compressedPCFile, octreeCoder);
-        v.run ();
-      }
+      compressedPCFile.open(fileName.c_str(), ios::out | ios::trunc | ios::binary);
 
-    } else
-    {
+      if (!bShowInputCloud) {
+        EventHelper v(compressedPCFile, octreeCoder, field_name, min_v, max_v);
+        v.run();
+      }
+      else {
+        SimpleOpenNIViewer v(compressedPCFile, octreeCoder);
+        v.run();
+      }
+    }
+    else {
       // DECODING
       ifstream compressedPCFile;
-      compressedPCFile.open (fileName.c_str(), ios::in | ios::binary);
-      compressedPCFile.seekg (0);
-      compressedPCFile.unsetf (ios_base::skipws);
+      compressedPCFile.open(fileName.c_str(), ios::in | ios::binary);
+      compressedPCFile.seekg(0);
+      compressedPCFile.unsetf(ios_base::skipws);
 
-      pcl::visualization::CloudViewer viewer ("PCL Compression Viewer");
+      pcl::visualization::CloudViewer viewer("PCL Compression Viewer");
 
-      while (!compressedPCFile.eof())
-      {
-        PointCloud<PointXYZRGBA>::Ptr cloudOut (new PointCloud<PointXYZRGBA> ());
-        octreeCoder->decodePointCloud ( compressedPCFile, cloudOut);
-        viewer.showCloud (cloudOut);
+      while (!compressedPCFile.eof()) {
+        PointCloud<PointXYZRGBA>::Ptr cloudOut(new PointCloud<PointXYZRGBA>());
+        octreeCoder->decodePointCloud(compressedPCFile, cloudOut);
+        viewer.showCloud(cloudOut);
       }
     }
-  } else
-  {
-    if (bEnDecode)
-    {
+  }
+  else {
+    if (bEnDecode) {
       // ENCODING
-      try
-      {
+      try {
         boost::asio::io_service io_service;
-        tcp::endpoint endpoint (tcp::v4 (), 6666);
-        tcp::acceptor acceptor (io_service, endpoint);
+        tcp::endpoint endpoint(tcp::v4(), 6666);
+        tcp::acceptor acceptor(io_service, endpoint);
 
         tcp::iostream socketStream;
 
         std::cout << "Waiting for connection.." << std::endl;
 
-        acceptor.accept (*socketStream.rdbuf ());
+        acceptor.accept(*socketStream.rdbuf());
 
         std::cout << "Connected!" << std::endl;
 
-        if (!bShowInputCloud) 
-        {
-          EventHelper v (socketStream, octreeCoder, field_name, min_v, max_v);
-          v.run ();
-        } 
-        else
-        {
-          SimpleOpenNIViewer v (socketStream, octreeCoder);
-          v.run ();
+        if (!bShowInputCloud) {
+          EventHelper v(socketStream, octreeCoder, field_name, min_v, max_v);
+          v.run();
+        }
+        else {
+          SimpleOpenNIViewer v(socketStream, octreeCoder);
+          v.run();
         }
 
         std::cout << "Disconnected!" << std::endl;
 
         std::this_thread::sleep_for(3s);
 
-      }
-      catch (std::exception& e)
-      {
-        std::cerr << e.what () << std::endl;
+      } catch (std::exception& e) {
+        std::cerr << e.what() << std::endl;
       }
     }
-    else
-    {
+    else {
       // DECODING
       std::cout << "Connecting to: " << hostName << ".." << std::endl;
 
-      try
-      {
-        tcp::iostream socketStream (hostName.c_str (), "6666");
+      try {
+        tcp::iostream socketStream(hostName.c_str(), "6666");
 
         std::cout << "Connected!" << std::endl;
 
-        pcl::visualization::CloudViewer viewer ("Decoded Point Cloud - PCL Compression Viewer");
+        pcl::visualization::CloudViewer viewer(
+            "Decoded Point Cloud - PCL Compression Viewer");
 
-        while (!socketStream.fail()) 
-        {
-          FPS_CALC ("drawing");
-          PointCloud<PointXYZRGBA>::Ptr cloudOut (new PointCloud<PointXYZRGBA> ());
-          octreeCoder->decodePointCloud (socketStream, cloudOut);
-          viewer.showCloud (cloudOut);
+        while (!socketStream.fail()) {
+          FPS_CALC("drawing");
+          PointCloud<PointXYZRGBA>::Ptr cloudOut(new PointCloud<PointXYZRGBA>());
+          octreeCoder->decodePointCloud(socketStream, cloudOut);
+          viewer.showCloud(cloudOut);
         }
 
-      }
-      catch (std::exception& e)
-      {
-        std::cout << "Exception: " << e.what () << std::endl;
+      } catch (std::exception& e) {
+        std::cout << "Exception: " << e.what() << std::endl;
       }
     }
   }
 
-
-  delete (octreeCoder);
-  return (0);
+  delete octreeCoder;
+  return 0;
 }
-
index 417c98f0ee955db959875196e314244d1432a84d..806a7a393e341b923de9372872f02126a6eecc26 100644 (file)
  * Author: Julius Kammerl (julius@kammerl.de)
  */
 
-#include <thread>
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/compression/organized_pointcloud_compression.h>
+#include <pcl/console/parse.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
-#include <pcl/compression/organized_pointcloud_compression.h>
+#include <boost/asio.hpp>
 
-#include <iostream>
-#include <vector>
 #include <cstdio>
-#include <sstream>
 #include <cstdlib>
 #include <iostream>
+#include <sstream>
 #include <string>
-
-#include <boost/asio.hpp>
+#include <thread>
+#include <vector>
 
 using boost::asio::ip::tcp;
 
@@ -64,233 +61,247 @@ using namespace std;
 using namespace std::chrono_literals;
 
 char usage[] = "\n"
-  "  PCL organized point cloud stream compression\n"
-  "\n"
-  "  usage: ./pcl_openni_organized_compression [mode] [parameters]\n"
-  "\n"
-  "  I/O: \n"
-  "      -f file  : file name \n"
-  "\n"
-  "  file compression mode:\n"
-  "      -x: encode point cloud stream to file\n"
-  "      -d: decode from file and display point cloud stream\n"
-  "\n"
-  "  network streaming mode:\n"
-  "      -s       : start server on localhost\n"
-  "      -c host  : connect to server and display decoded cloud stream\n"
-  "\n"
-  "  optional compression parameters:\n"
-  "      -a       : enable color coding\n"
-  "      -t       : output statistics\n"
-  "      -e       : show input cloud during encoding\n"
-  "      -r       : raw encoding of disparity maps\n"
-  "      -g       : gray scale conversion\n"
-
-  "\n"
-  "  example:\n"
-  "      ./pcl_openni_organized_compression -x -t -f pc_compressed.pcc \n"
-  "\n";
-
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+               "  PCL organized point cloud stream compression\n"
+               "\n"
+               "  usage: ./pcl_openni_organized_compression [mode] [parameters]\n"
+               "\n"
+               "  I/O: \n"
+               "      -f file  : file name \n"
+               "\n"
+               "  file compression mode:\n"
+               "      -x: encode point cloud stream to file\n"
+               "      -d: decode from file and display point cloud stream\n"
+               "\n"
+               "  network streaming mode:\n"
+               "      -s       : start server on localhost\n"
+               "      -c host  : connect to server and display decoded cloud stream\n"
+               "\n"
+               "  optional compression parameters:\n"
+               "      -a       : enable color coding\n"
+               "      -t       : output statistics\n"
+               "      -e       : show input cloud during encoding\n"
+               "      -r       : raw encoding of disparity maps\n"
+               "      -g       : gray scale conversion\n"
+
+               "\n"
+               "  example:\n"
+               "      ./pcl_openni_organized_compression -x -t -f pc_compressed.pcc \n"
+               "\n";
+
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
 void
-print_usage (const std::string &msg)
+print_usage(const std::string& msg)
 {
   std::cerr << msg << std::endl;
   std::cout << usage << std::endl;
 }
 
-class SimpleOpenNIViewer
-{
-  public:
-    SimpleOpenNIViewer (ostream& outputFile_arg,
-                        OrganizedPointCloudCompression<PointXYZRGBA>* octreeEncoder_arg,
-                        bool doColorEncoding_arg,
-                        bool bShowStatistics_arg,
-                        bool bRawImageEncoding_arg,
-                        bool bGrayScaleConversion_arg,
-                        int pngLevel_arg = -1) :
-    viewer ("Input Point Cloud - PCL Compression Viewer"),
-    outputFile_ (outputFile_arg),
-    organizedEncoder_ (octreeEncoder_arg),
-    doColorEncoding_ (doColorEncoding_arg),
-    bShowStatistics_ (bShowStatistics_arg),
-    bRawImageEncoding_ (bRawImageEncoding_arg),
-    bGrayScaleConversion_(bGrayScaleConversion_arg),
-    pngLevel_ (pngLevel_arg)
-    {
-    }
-
-    void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
-    {
-      if (!viewer.wasStopped ())
-      {
-        organizedEncoder_->encodePointCloud (cloud, outputFile_, doColorEncoding_,bGrayScaleConversion_,bShowStatistics_, pngLevel_);
+class SimpleOpenNIViewer {
+public:
+  SimpleOpenNIViewer(ostream& outputFile_arg,
+                     OrganizedPointCloudCompression<PointXYZRGBA>* octreeEncoder_arg,
+                     bool doColorEncoding_arg,
+                     bool bShowStatistics_arg,
+                     bool bRawImageEncoding_arg,
+                     bool bGrayScaleConversion_arg,
+                     int pngLevel_arg = -1)
+  : viewer("Input Point Cloud - PCL Compression Viewer")
+  , outputFile_(outputFile_arg)
+  , organizedEncoder_(octreeEncoder_arg)
+  , doColorEncoding_(doColorEncoding_arg)
+  , bShowStatistics_(bShowStatistics_arg)
+  , bRawImageEncoding_(bRawImageEncoding_arg)
+  , bGrayScaleConversion_(bGrayScaleConversion_arg)
+  , pngLevel_(pngLevel_arg)
+  {}
 
-        viewer.showCloud (cloud);
-      }
+  void
+  cloud_cb_(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
+  {
+    if (!viewer.wasStopped()) {
+      organizedEncoder_->encodePointCloud(cloud,
+                                          outputFile_,
+                                          doColorEncoding_,
+                                          bGrayScaleConversion_,
+                                          bShowStatistics_,
+                                          pngLevel_);
+
+      viewer.showCloud(cloud);
     }
+  }
 
+  void
+  run()
+  {
 
+    if (!bRawImageEncoding_) {
+      // create a new grabber for OpenNI devices
+      pcl::OpenNIGrabber interface{};
 
-    void run ()
-    {
-
-      if (!bRawImageEncoding_)
-      {
-        // create a new grabber for OpenNI devices
-        pcl::OpenNIGrabber interface {};
-
-        // make callback function from member function
-        std::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
-          [this] (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) { cloud_cb_ (cloud); };
-
-        // connect callback function for desired signal. In this case its a point cloud with color values
-        boost::signals2::connection c = interface.registerCallback (f);
-
-        // start receiving point clouds
-        interface.start ();
+      // make callback function from member function
+      std::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
+          [this](const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) {
+            cloud_cb_(cloud);
+          };
 
+      // connect callback function for desired signal. In this case its a point cloud
+      // with color values
+      boost::signals2::connection c = interface.registerCallback(f);
 
-        while (!outputFile_.fail())
-        {
-          std::this_thread::sleep_for(1s);
-        }
+      // start receiving point clouds
+      interface.start();
 
-        interface.stop ();
+      while (!outputFile_.fail()) {
+        std::this_thread::sleep_for(1s);
       }
 
+      interface.stop();
     }
+  }
 
-    pcl::visualization::CloudViewer viewer;
-    ostream& outputFile_;
-    OrganizedPointCloudCompression<PointXYZRGBA>* organizedEncoder_;
-    bool doColorEncoding_;
-    bool bShowStatistics_;
-    bool bRawImageEncoding_;
-    bool bGrayScaleConversion_;
-    int pngLevel_;
+  pcl::visualization::CloudViewer viewer;
+  ostream& outputFile_;
+  OrganizedPointCloudCompression<PointXYZRGBA>* organizedEncoder_;
+  bool doColorEncoding_;
+  bool bShowStatistics_;
+  bool bRawImageEncoding_;
+  bool bGrayScaleConversion_;
+  int pngLevel_;
 };
 
-struct EventHelper
-{
-  EventHelper (ostream& outputFile_arg,
-               OrganizedPointCloudCompression<PointXYZRGBA>* octreeEncoder_arg,
-               bool doColorEncoding_arg,
-               bool bShowStatistics_arg,
-               bool bRawImageEncoding_arg,
-               bool bGrayScaleConversion_arg,
-               int pngLevel_arg = -1) :
-  outputFile_ (outputFile_arg),
-  organizedEncoder_ (octreeEncoder_arg),
-  doColorEncoding_ (doColorEncoding_arg),
-  bShowStatistics_ (bShowStatistics_arg),
-  bRawImageEncoding_ (bRawImageEncoding_arg),
-  bGrayScaleConversion_(bGrayScaleConversion_arg) ,
-  pngLevel_ (pngLevel_arg)
-  {
-  }
+struct EventHelper {
+  EventHelper(ostream& outputFile_arg,
+              OrganizedPointCloudCompression<PointXYZRGBA>* octreeEncoder_arg,
+              bool doColorEncoding_arg,
+              bool bShowStatistics_arg,
+              bool bRawImageEncoding_arg,
+              bool bGrayScaleConversion_arg,
+              int pngLevel_arg = -1)
+  : outputFile_(outputFile_arg)
+  , organizedEncoder_(octreeEncoder_arg)
+  , doColorEncoding_(doColorEncoding_arg)
+  , bShowStatistics_(bShowStatistics_arg)
+  , bRawImageEncoding_(bRawImageEncoding_arg)
+  , bGrayScaleConversion_(bGrayScaleConversion_arg)
+  , pngLevel_(pngLevel_arg)
+  {}
 
   void
-  cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
+  cloud_cb_(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
   {
-    if (!outputFile_.fail ())
-    {
-      organizedEncoder_->encodePointCloud (cloud, outputFile_, doColorEncoding_, bGrayScaleConversion_, bShowStatistics_, pngLevel_);
+    if (!outputFile_.fail()) {
+      organizedEncoder_->encodePointCloud(cloud,
+                                          outputFile_,
+                                          doColorEncoding_,
+                                          bGrayScaleConversion_,
+                                          bShowStatistics_,
+                                          pngLevel_);
     }
   }
 
   void
-  image_callback (const openni_wrapper::Image::Ptr &image,
-                  const openni_wrapper::DepthImage::Ptr &depth_image, float)
+  image_callback(const openni_wrapper::Image::Ptr& image,
+                 const openni_wrapper::DepthImage::Ptr& depth_image,
+                 float)
   {
 
     std::vector<std::uint16_t> disparity_data;
     std::vector<std::uint8_t> rgb_data;
 
-    std::uint32_t width=depth_image->getWidth ();
-    std::uint32_t height=depth_image->getHeight ();
-
-    disparity_data.resize(width*height);
-    depth_image->fillDepthImageRaw (width, height, &disparity_data[0], static_cast<unsigned int> (width * sizeof (std::uint16_t)));
-
-    if (image->getEncoding() != openni_wrapper::Image::RGB)
-    {
-      rgb_data.resize(width*height*3);
-      image->fillRGB(width, height, &rgb_data[0], static_cast<unsigned int> (width * sizeof (std::uint8_t) * 3));
+    std::uint32_t width = depth_image->getWidth();
+    std::uint32_t height = depth_image->getHeight();
+
+    disparity_data.resize(width * height);
+    depth_image->fillDepthImageRaw(
+        width,
+        height,
+        &disparity_data[0],
+        static_cast<unsigned int>(width * sizeof(std::uint16_t)));
+
+    if (image->getEncoding() != openni_wrapper::Image::RGB) {
+      rgb_data.resize(width * height * 3);
+      image->fillRGB(width,
+                     height,
+                     &rgb_data[0],
+                     static_cast<unsigned int>(width * sizeof(std::uint8_t) * 3));
     }
 
-    organizedEncoder_->encodeRawDisparityMapWithColorImage (disparity_data, rgb_data, width, height, outputFile_, doColorEncoding_, bGrayScaleConversion_, bShowStatistics_, pngLevel_);
-
+    organizedEncoder_->encodeRawDisparityMapWithColorImage(disparity_data,
+                                                           rgb_data,
+                                                           width,
+                                                           height,
+                                                           outputFile_,
+                                                           doColorEncoding_,
+                                                           bGrayScaleConversion_,
+                                                           bShowStatistics_,
+                                                           pngLevel_);
   }
 
   void
-  run ()
+  run()
   {
-    if (!bRawImageEncoding_)
-    {
+    if (!bRawImageEncoding_) {
       // create a new grabber for OpenNI devices
-      pcl::OpenNIGrabber interface {};
+      pcl::OpenNIGrabber interface{};
 
       // make callback function from member function
-      std::function<void
-      (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f = [this] (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud)
-      {
-        cloud_cb_ (cloud);
-      };
+      std::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
+          [this](const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& cloud) {
+            cloud_cb_(cloud);
+          };
 
-      // connect callback function for desired signal. In this case its a point cloud with color values
-      boost::signals2::connection c = interface.registerCallback (f);
+      // connect callback function for desired signal. In this case its a point cloud
+      // with color values
+      boost::signals2::connection c = interface.registerCallback(f);
 
       // start receiving point clouds
-      interface.start ();
+      interface.start();
 
-      while (!outputFile_.fail ())
-      {
+      while (!outputFile_.fail()) {
         std::this_thread::sleep_for(1s);
       }
 
-      interface.stop ();
-    } else
-    {
+      interface.stop();
+    }
+    else {
       pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
       int depthformat = openni_wrapper::OpenNIDevice::OpenNI_shift_values;
 
-      pcl::OpenNIGrabber grabber ("", pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);
+      pcl::OpenNIGrabber grabber(
+          "", pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);
 
       // Set the depth output format
-      grabber.getDevice ()->setDepthOutputFormat (static_cast<openni_wrapper::OpenNIDevice::DepthMode> (depthformat));
-
-      std::function<void (const openni_wrapper::Image::Ptr&,
-                          const openni_wrapper::DepthImage::Ptr&,
-                          float) > image_cb = [this] (const openni_wrapper::Image::Ptr& img,
-                                                      const openni_wrapper::DepthImage::Ptr& depth,
-                                                      float f)
-      {
-        image_callback (img, depth, f);
-      };
-      boost::signals2::connection image_connection = grabber.registerCallback (image_cb);
-
-      grabber.start ();
-      while (!outputFile_.fail())
-      {
+      grabber.getDevice()->setDepthOutputFormat(
+          static_cast<openni_wrapper::OpenNIDevice::DepthMode>(depthformat));
+
+      std::function<void(const openni_wrapper::Image::Ptr&,
+                         const openni_wrapper::DepthImage::Ptr&,
+                         float)>
+          image_cb = [this](const openni_wrapper::Image::Ptr& img,
+                            const openni_wrapper::DepthImage::Ptr& depth,
+                            float f) { image_callback(img, depth, f); };
+      boost::signals2::connection image_connection = grabber.registerCallback(image_cb);
+
+      grabber.start();
+      while (!outputFile_.fail()) {
         std::this_thread::sleep_for(1s);
       }
-      grabber.stop ();
-
+      grabber.stop();
     }
   }
 
@@ -304,7 +315,7 @@ struct EventHelper
 };
 
 int
-main (int argc, char **argv)
+main(int argc, char** argv)
 {
   OrganizedPointCloudCompression<PointXYZRGBA>* organizedCoder;
 
@@ -331,175 +342,169 @@ main (int argc, char **argv)
   bRawImageEncoding = false;
   bGrayScaleConversion = false;
 
-  if (pcl::console::find_argument (argc, argv, "-e")>0) 
+  if (pcl::console::find_argument(argc, argv, "-e") > 0)
     bShowInputCloud = true;
 
-  if (pcl::console::find_argument (argc, argv, "-r")>0)
+  if (pcl::console::find_argument(argc, argv, "-r") > 0)
     bRawImageEncoding = true;
 
-  if (pcl::console::find_argument (argc, argv, "-g")>0)
+  if (pcl::console::find_argument(argc, argv, "-g") > 0)
     bGrayScaleConversion = true;
 
-  if (pcl::console::find_argument (argc, argv, "-s")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-s") > 0) {
     bEnDecode = true;
     bServerFileMode = true;
     validArguments = true;
   }
 
-  if (pcl::console::parse_argument (argc, argv, "-c", hostName)>0) 
-  {
+  if (pcl::console::parse_argument(argc, argv, "-c", hostName) > 0) {
     bEnDecode = false;
     bServerFileMode = true;
     validArguments = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-a")>0)
-  {
+  if (pcl::console::find_argument(argc, argv, "-a") > 0) {
     doColorEncoding = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-x")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-x") > 0) {
     bEnDecode = true;
     bServerFileMode = false;
     validArguments = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-d")>0) 
-  {
+  if (pcl::console::find_argument(argc, argv, "-d") > 0) {
     bEnDecode = false;
     bServerFileMode = false;
     validArguments = true;
   }
 
-  if (pcl::console::find_argument (argc, argv, "-t")>0) 
+  if (pcl::console::find_argument(argc, argv, "-t") > 0)
     showStatistics = true;
 
-  pcl::console::parse_argument (argc, argv, "-f", fileName);
-
+  pcl::console::parse_argument(argc, argv, "-f", fileName);
 
-  if (pcl::console::find_argument (argc, argv, "-?")>0) 
-  {
-    print_usage ("");
+  if (pcl::console::find_argument(argc, argv, "-?") > 0) {
+    print_usage("");
     return 1;
   }
 
-  if (!validArguments)
-  {
-    print_usage ("Please specify compression mode..\n");
+  if (!validArguments) {
+    print_usage("Please specify compression mode..\n");
     return -1;
   }
 
-  organizedCoder = new OrganizedPointCloudCompression<PointXYZRGBA> ();
+  organizedCoder = new OrganizedPointCloudCompression<PointXYZRGBA>();
 
-
-  if (!bServerFileMode) 
-  {
-    if (bEnDecode) 
-    {
+  if (!bServerFileMode) {
+    if (bEnDecode) {
       // ENCODING
       ofstream compressedPCFile;
-      compressedPCFile.open (fileName.c_str(), ios::out | ios::trunc | ios::binary);
-
-      if (!bShowInputCloud) 
-      {
-        EventHelper v (compressedPCFile, organizedCoder, doColorEncoding, showStatistics, bRawImageEncoding, bGrayScaleConversion);
-        v.run ();
-      } 
-      else
-      {
-        SimpleOpenNIViewer v (compressedPCFile, organizedCoder, doColorEncoding, showStatistics, bRawImageEncoding, bGrayScaleConversion);
-        v.run ();
+      compressedPCFile.open(fileName.c_str(), ios::out | ios::trunc | ios::binary);
+
+      if (!bShowInputCloud) {
+        EventHelper v(compressedPCFile,
+                      organizedCoder,
+                      doColorEncoding,
+                      showStatistics,
+                      bRawImageEncoding,
+                      bGrayScaleConversion);
+        v.run();
       }
-
-    } else
-    {
+      else {
+        SimpleOpenNIViewer v(compressedPCFile,
+                             organizedCoder,
+                             doColorEncoding,
+                             showStatistics,
+                             bRawImageEncoding,
+                             bGrayScaleConversion);
+        v.run();
+      }
+    }
+    else {
       // DECODING
       ifstream compressedPCFile;
-      compressedPCFile.open (fileName.c_str(), ios::in | ios::binary);
-      compressedPCFile.seekg (0);
-      compressedPCFile.unsetf (ios_base::skipws);
+      compressedPCFile.open(fileName.c_str(), ios::in | ios::binary);
+      compressedPCFile.seekg(0);
+      compressedPCFile.unsetf(ios_base::skipws);
 
-      pcl::visualization::CloudViewer viewer ("PCL Compression Viewer");
+      pcl::visualization::CloudViewer viewer("PCL Compression Viewer");
 
-      while (!compressedPCFile.eof())
-      {
-        PointCloud<PointXYZRGBA>::Ptr cloudOut (new PointCloud<PointXYZRGBA> ());
-        organizedCoder->decodePointCloud ( compressedPCFile, cloudOut );
-        viewer.showCloud (cloudOut);
+      while (!compressedPCFile.eof()) {
+        PointCloud<PointXYZRGBA>::Ptr cloudOut(new PointCloud<PointXYZRGBA>());
+        organizedCoder->decodePointCloud(compressedPCFile, cloudOut);
+        viewer.showCloud(cloudOut);
       }
     }
-  } else
-  {
-    if (bEnDecode)
-    {
+  }
+  else {
+    if (bEnDecode) {
       // ENCODING
-      try
-      {
+      try {
         boost::asio::io_service io_service;
-        tcp::endpoint endpoint (tcp::v4 (), 6666);
-        tcp::acceptor acceptor (io_service, endpoint);
+        tcp::endpoint endpoint(tcp::v4(), 6666);
+        tcp::acceptor acceptor(io_service, endpoint);
 
         tcp::iostream socketStream;
 
         std::cout << "Waiting for connection.." << std::endl;
 
-        acceptor.accept (*socketStream.rdbuf ());
+        acceptor.accept(*socketStream.rdbuf());
 
         std::cout << "Connected!" << std::endl;
 
-        if (!bShowInputCloud) 
-        {
-          EventHelper v (socketStream, organizedCoder, doColorEncoding, showStatistics, bRawImageEncoding, bGrayScaleConversion);
-          v.run ();
-        } 
-        else
-        {
-          SimpleOpenNIViewer v (socketStream, organizedCoder, doColorEncoding, showStatistics, bRawImageEncoding, bGrayScaleConversion);
-          v.run ();
+        if (!bShowInputCloud) {
+          EventHelper v(socketStream,
+                        organizedCoder,
+                        doColorEncoding,
+                        showStatistics,
+                        bRawImageEncoding,
+                        bGrayScaleConversion);
+          v.run();
+        }
+        else {
+          SimpleOpenNIViewer v(socketStream,
+                               organizedCoder,
+                               doColorEncoding,
+                               showStatistics,
+                               bRawImageEncoding,
+                               bGrayScaleConversion);
+          v.run();
         }
 
         std::cout << "Disconnected!" << std::endl;
 
         std::this_thread::sleep_for(3s);
 
-      }
-      catch (std::exception& e)
-      {
-        std::cerr << e.what () << std::endl;
+      } catch (std::exception& e) {
+        std::cerr << e.what() << std::endl;
       }
     }
-    else
-    {
+    else {
       // DECODING
       std::cout << "Connecting to: " << hostName << ".." << std::endl;
 
-      try
-      {
-        tcp::iostream socketStream (hostName.c_str (), "6666");
+      try {
+        tcp::iostream socketStream(hostName.c_str(), "6666");
 
         std::cout << "Connected!" << std::endl;
 
-        pcl::visualization::CloudViewer viewer ("Decoded Point Cloud - PCL Compression Viewer");
+        pcl::visualization::CloudViewer viewer(
+            "Decoded Point Cloud - PCL Compression Viewer");
 
-        while (!socketStream.fail()) 
-        {
-          FPS_CALC ("drawing");
-          PointCloud<PointXYZRGBA>::Ptr cloudOut (new PointCloud<PointXYZRGBA> ());
-          organizedCoder->decodePointCloud (socketStream, cloudOut);
-          viewer.showCloud (cloudOut);
+        while (!socketStream.fail()) {
+          FPS_CALC("drawing");
+          PointCloud<PointXYZRGBA>::Ptr cloudOut(new PointCloud<PointXYZRGBA>());
+          organizedCoder->decodePointCloud(socketStream, cloudOut);
+          viewer.showCloud(cloudOut);
         }
 
-      }
-      catch (std::exception& e)
-      {
-        std::cout << "Exception: " << e.what () << std::endl;
+      } catch (std::exception& e) {
+        std::cout << "Exception: " << e.what() << std::endl;
       }
     }
   }
 
-  delete (organizedCoder);
-  return (0);
+  delete organizedCoder;
+  return 0;
 }
-
index d5d40fa3b4828e075a070fb6c193f3f5c10136e1..b06f8c2e4ec77923585cb21ffa806bcd5438d7eb 100644 (file)
@@ -33,7 +33,6 @@
  *
  */
 
-
 #include <pcl/common/time.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/features/organized_edge_detection.h>
 
 using PointT = pcl::PointXYZRGBA;
 
-class OpenNIOrganizedEdgeDetection
-{
-  private:
-    pcl::visualization::PCLVisualizer::Ptr viewer;
-    pcl::PointCloud<PointT> cloud_;
-    std::mutex cloud_mutex;
+class OpenNIOrganizedEdgeDetection {
+private:
+  pcl::visualization::PCLVisualizer::Ptr viewer;
+  pcl::PointCloud<PointT> cloud_;
+  std::mutex cloud_mutex;
 
-  public:
-    OpenNIOrganizedEdgeDetection ()
-      : viewer (new pcl::visualization::PCLVisualizer ("PCL Organized Edge Detection"))
-    {
+public:
+  OpenNIOrganizedEdgeDetection()
+  : viewer(new pcl::visualization::PCLVisualizer("PCL Organized Edge Detection"))
+  {}
+  ~OpenNIOrganizedEdgeDetection() {}
 
+  pcl::visualization::PCLVisualizer::Ptr
+  initCloudViewer(const pcl::PointCloud<PointT>::ConstPtr& cloud)
+  {
+    viewer->setSize(640, 480);
+    viewer->addPointCloud<PointT>(cloud, "cloud");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
+    viewer->addCoordinateSystem(0.2f, "global");
+    viewer->initCameraParameters();
+    viewer->registerKeyboardCallback(&OpenNIOrganizedEdgeDetection::keyboard_callback,
+                                     *this);
+    viewer->resetCameraViewpoint("cloud");
+
+    const int point_size = 2;
+    viewer->addPointCloud<PointT>(cloud, "nan boundary edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
+        point_size,
+        "nan boundary edges");
+    viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
+                                             0.0f,
+                                             0.0f,
+                                             1.0f,
+                                             "nan boundary edges");
+
+    viewer->addPointCloud<PointT>(cloud, "occluding edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluding edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 0.0f, "occluding edges");
+
+    viewer->addPointCloud<PointT>(cloud, "occluded edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluded edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_COLOR, 1.0f, 0.0f, 0.0f, "occluded edges");
+
+    viewer->addPointCloud<PointT>(cloud, "high curvature edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
+        point_size,
+        "high curvature edges");
+    viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
+                                             1.0f,
+                                             1.0f,
+                                             0.0f,
+                                             "high curvature edges");
+
+    viewer->addPointCloud<PointT>(cloud, "rgb edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "rgb edges");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 1.0f, "rgb edges");
+
+    return viewer;
+  }
+
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    if (event.keyUp()) {
+      double opacity;
+      switch (event.getKeyCode()) {
+      case '1':
+        viewer->getPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "nan boundary edges");
+        viewer->setPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY,
+            1.0 - opacity,
+            "nan boundary edges");
+        break;
+      case '2':
+        viewer->getPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluding edges");
+        viewer->setPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY,
+            1.0 - opacity,
+            "occluding edges");
+        break;
+      case '3':
+        viewer->getPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluded edges");
+        viewer->setPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY,
+            1.0 - opacity,
+            "occluded edges");
+        break;
+      case '4':
+        viewer->getPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY,
+            opacity,
+            "high curvature edges");
+        viewer->setPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY,
+            1.0 - opacity,
+            "high curvature edges");
+        break;
+      case '5':
+        viewer->getPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "rgb edges");
+        viewer->setPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0 - opacity, "rgb edges");
+        break;
+      }
     }
-    ~OpenNIOrganizedEdgeDetection ()
-    {
-    }
+  }
 
-    pcl::visualization::PCLVisualizer::Ptr
-    initCloudViewer (const pcl::PointCloud<PointT>::ConstPtr& cloud)
-    {
-      viewer->setSize (640, 480);
-      viewer->addPointCloud<PointT> (cloud, "cloud");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
-      viewer->addCoordinateSystem (0.2f, "global");
-      viewer->initCameraParameters ();
-      viewer->registerKeyboardCallback (&OpenNIOrganizedEdgeDetection::keyboard_callback, *this);
-      viewer->resetCameraViewpoint ("cloud");
-
-      const int point_size = 2;
-      viewer->addPointCloud<PointT> (cloud, "nan boundary edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "nan boundary edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 0.0f, 1.0f, "nan boundary edges");
-
-      viewer->addPointCloud<PointT> (cloud, "occluding edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluding edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 0.0f, "occluding edges");
-
-      viewer->addPointCloud<PointT> (cloud, "occluded edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluded edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0f, 0.0f, 0.0f, "occluded edges");
-
-      viewer->addPointCloud<PointT> (cloud, "high curvature edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "high curvature edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0f, 1.0f, 0.0f, "high curvature edges");
-
-      viewer->addPointCloud<PointT> (cloud, "rgb edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "rgb edges");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 1.0f, "rgb edges");
-
-      return (viewer);
+  void
+  cloud_cb_(const pcl::PointCloud<PointT>::ConstPtr& cloud)
+  {
+    if (!viewer->wasStopped()) {
+      cloud_mutex.lock();
+      cloud_ = *cloud;
+      cloud_mutex.unlock();
     }
+  }
+
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{};
 
-    void
-    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      if (event.keyUp())
-      {
-        double opacity;
-        switch (event.getKeyCode())
-        {
-        case '1':
-          viewer->getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "nan boundary edges");
-          viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "nan boundary edges");
-          break;
-        case '2':
-          viewer->getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluding edges");
-          viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "occluding edges");
-          break;
-        case '3':
-          viewer->getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluded edges");
-          viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "occluded edges");
-          break;
-        case '4':
-          viewer->getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "high curvature edges");
-          viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "high curvature edges");
-          break;
-        case '5':
-          viewer->getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "rgb edges");
-          viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "rgb edges");
-          break;
+    std::function<void(const pcl::PointCloud<PointT>::ConstPtr&)> f =
+        [this](const pcl::PointCloud<PointT>::ConstPtr& cloud) { cloud_cb_(cloud); };
+
+    // Make and initialize a cloud viewer
+    pcl::PointCloud<PointT>::Ptr init_cloud_ptr(new pcl::PointCloud<PointT>);
+    viewer = initCloudViewer(init_cloud_ptr);
+    boost::signals2::connection c = interface.registerCallback(f);
+
+    interface.start();
+
+    pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
+    ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+    ne.setNormalSmoothingSize(10.0f);
+    ne.setBorderPolicy(ne.BORDER_POLICY_MIRROR);
+
+    float th_dd = 0.04f;
+    int max_search = 100;
+    pcl::OrganizedEdgeFromRGBNormals<PointT, pcl::Normal, pcl::Label> oed;
+    oed.setDepthDisconThreshold(th_dd);
+    oed.setMaxSearchNeighbors(max_search);
+
+    oed.setEdgeType(oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING |
+                    oed.EDGELABEL_OCCLUDED);
+    // oed.setEdgeType (oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING |
+    // oed.EDGELABEL_OCCLUDED | oed.EDGELABEL_HIGH_CURVATURE | oed.EDGELABEL_RGB_CANNY);
+
+    pcl::PointCloud<pcl::Label> labels;
+    std::vector<pcl::PointIndices> label_indices;
+
+    while (!viewer->wasStopped()) {
+      viewer->spinOnce();
+
+      if (cloud_mutex.try_lock()) {
+        labels.clear();
+        label_indices.clear();
+
+        double normal_start = pcl::getTime();
+
+        if (oed.getEdgeType() & oed.EDGELABEL_HIGH_CURVATURE) {
+          pcl::PointCloud<pcl::Normal>::Ptr normal_cloud(
+              new pcl::PointCloud<pcl::Normal>);
+          ne.setInputCloud(cloud_.makeShared());
+          ne.compute(*normal_cloud);
+          double normal_end = pcl::getTime();
+          std::cout << "Normal Estimation took " << double(normal_end - normal_start)
+                    << std::endl;
+
+          oed.setInputNormals(normal_cloud);
         }
-      }
-    }
 
-    void
-    cloud_cb_ (const pcl::PointCloud<PointT>::ConstPtr& cloud)
-    {
-      if (!viewer->wasStopped ())
-      {
-        cloud_mutex.lock ();
-        cloud_ = *cloud;
-        cloud_mutex.unlock ();
-      }
-    }
+        double oed_start = pcl::getTime();
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {};
-
-      std::function<void(const pcl::PointCloud<PointT>::ConstPtr&)> f = [this] (const pcl::PointCloud<PointT>::ConstPtr& cloud) { cloud_cb_ (cloud); };
-
-      // Make and initialize a cloud viewer
-      pcl::PointCloud<PointT>::Ptr init_cloud_ptr (new pcl::PointCloud<PointT>);
-      viewer = initCloudViewer (init_cloud_ptr);
-      boost::signals2::connection c = interface.registerCallback (f);
-
-      interface.start ();
-
-      pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
-      ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-      ne.setNormalSmoothingSize (10.0f);
-      ne.setBorderPolicy (ne.BORDER_POLICY_MIRROR);
-
-      float th_dd = 0.04f;
-      int max_search = 100;
-      pcl::OrganizedEdgeFromRGBNormals<PointT, pcl::Normal, pcl::Label> oed;
-      oed.setDepthDisconThreshold (th_dd);
-      oed.setMaxSearchNeighbors (max_search);
-
-      oed.setEdgeType (oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING | oed.EDGELABEL_OCCLUDED);
-      //oed.setEdgeType (oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING | oed.EDGELABEL_OCCLUDED | oed.EDGELABEL_HIGH_CURVATURE | oed.EDGELABEL_RGB_CANNY);
-
-      pcl::PointCloud<pcl::Label> labels;
-      std::vector<pcl::PointIndices> label_indices;
-
-      while (!viewer->wasStopped ())
-      {
-        viewer->spinOnce ();
-
-        if (cloud_mutex.try_lock ())
-        {
-          labels.clear ();
-          label_indices.clear ();
-          
-          double normal_start = pcl::getTime ();
-
-          if (oed.getEdgeType () & oed.EDGELABEL_HIGH_CURVATURE)
-          {
-            pcl::PointCloud<pcl::Normal>::Ptr normal_cloud (new pcl::PointCloud<pcl::Normal>);
-            ne.setInputCloud (cloud_.makeShared ());
-            ne.compute (*normal_cloud);
-            double normal_end = pcl::getTime ();
-            std::cout << "Normal Estimation took " << double (normal_end - normal_start) << std::endl;
-
-            oed.setInputNormals (normal_cloud);
-          }
-
-          double oed_start = pcl::getTime ();
-
-          oed.setInputCloud (cloud_.makeShared ());
-          oed.compute (labels, label_indices);
-
-          double oed_end = pcl::getTime ();
-          std::cout << "Edge Detection took " << double (oed_end - oed_start) << std::endl;
-          std::cout << "Frame took " << double (oed_end - normal_start) << std::endl;
-
-          // Make gray point cloud
-          for (auto &point : cloud_.points)
-          {
-            std::uint8_t gray = std::uint8_t((point.r + point.g + point.b)/3);
-            point.r = point.g = point.b = gray;
-          }
-
-          // Show the gray point cloud
-          if (!viewer->updatePointCloud (cloud_.makeShared (), "cloud"))
-            viewer->addPointCloud (cloud_.makeShared (), "cloud");
-
-          // Show edges
-          pcl::PointCloud<PointT>::Ptr occluding_edges (new pcl::PointCloud<PointT>), 
-            occluded_edges (new pcl::PointCloud<PointT>), 
-            nan_boundary_edges (new pcl::PointCloud<PointT>),
-            high_curvature_edges (new pcl::PointCloud<PointT>),
-            rgb_edges (new pcl::PointCloud<PointT>);
-
-          pcl::copyPointCloud (cloud_, label_indices[0].indices, *nan_boundary_edges);
-          pcl::copyPointCloud (cloud_, label_indices[1].indices, *occluding_edges);
-          pcl::copyPointCloud (cloud_, label_indices[2].indices, *occluded_edges);
-          pcl::copyPointCloud (cloud_, label_indices[3].indices, *high_curvature_edges);
-          pcl::copyPointCloud (cloud_, label_indices[4].indices, *rgb_edges);
-
-          if (!viewer->updatePointCloud<PointT> (nan_boundary_edges, "nan boundary edges"))
-            viewer->addPointCloud<PointT> (nan_boundary_edges, "nan boundary edges");
-
-          if (!viewer->updatePointCloud<PointT> (occluding_edges, "occluding edges"))
-            viewer->addPointCloud<PointT> (occluding_edges, "occluding edges");
-          
-          if (!viewer->updatePointCloud<PointT> (occluded_edges, "occluded edges"))
-            viewer->addPointCloud<PointT> (occluded_edges, "occluded edges");
-
-          if (!viewer->updatePointCloud<PointT> (high_curvature_edges, "high curvature edges"))
-            viewer->addPointCloud<PointT> (high_curvature_edges, "high curvature edges");
-
-          if (!viewer->updatePointCloud<PointT> (rgb_edges, "rgb edges"))
-            viewer->addPointCloud<PointT> (rgb_edges, "rgb edges");
-
-          cloud_mutex.unlock ();
+        oed.setInputCloud(cloud_.makeShared());
+        oed.compute(labels, label_indices);
+
+        double oed_end = pcl::getTime();
+        std::cout << "Edge Detection took " << double(oed_end - oed_start) << std::endl;
+        std::cout << "Frame took " << double(oed_end - normal_start) << std::endl;
+
+        // Make gray point cloud
+        for (auto& point : cloud_.points) {
+          std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3);
+          point.r = point.g = point.b = gray;
         }
-      }
 
-      interface.stop ();
+        // Show the gray point cloud
+        if (!viewer->updatePointCloud(cloud_.makeShared(), "cloud"))
+          viewer->addPointCloud(cloud_.makeShared(), "cloud");
+
+        // Show edges
+        pcl::PointCloud<PointT>::Ptr occluding_edges(new pcl::PointCloud<PointT>),
+            occluded_edges(new pcl::PointCloud<PointT>),
+            nan_boundary_edges(new pcl::PointCloud<PointT>),
+            high_curvature_edges(new pcl::PointCloud<PointT>),
+            rgb_edges(new pcl::PointCloud<PointT>);
+
+        pcl::copyPointCloud(cloud_, label_indices[0].indices, *nan_boundary_edges);
+        pcl::copyPointCloud(cloud_, label_indices[1].indices, *occluding_edges);
+        pcl::copyPointCloud(cloud_, label_indices[2].indices, *occluded_edges);
+        pcl::copyPointCloud(cloud_, label_indices[3].indices, *high_curvature_edges);
+        pcl::copyPointCloud(cloud_, label_indices[4].indices, *rgb_edges);
+
+        if (!viewer->updatePointCloud<PointT>(nan_boundary_edges, "nan boundary edges"))
+          viewer->addPointCloud<PointT>(nan_boundary_edges, "nan boundary edges");
+
+        if (!viewer->updatePointCloud<PointT>(occluding_edges, "occluding edges"))
+          viewer->addPointCloud<PointT>(occluding_edges, "occluding edges");
+
+        if (!viewer->updatePointCloud<PointT>(occluded_edges, "occluded edges"))
+          viewer->addPointCloud<PointT>(occluded_edges, "occluded edges");
+
+        if (!viewer->updatePointCloud<PointT>(high_curvature_edges,
+                                              "high curvature edges"))
+          viewer->addPointCloud<PointT>(high_curvature_edges, "high curvature edges");
+
+        if (!viewer->updatePointCloud<PointT>(rgb_edges, "rgb edges"))
+          viewer->addPointCloud<PointT>(rgb_edges, "rgb edges");
+
+        cloud_mutex.unlock();
+      }
     }
+
+    interface.stop();
+  }
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
@@ -271,18 +306,18 @@ usage (char ** argv)
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   std::string arg;
   if (argc > 1)
-    arg = std::string (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+    arg = std::string(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
-  
+
+  // clang-format off
   std::cout << "Press following keys to enable/disable the different edge types:" << std::endl;
   std::cout << "<1> EDGELABEL_NAN_BOUNDARY edge" << std::endl;
   std::cout << "<2> EDGELABEL_OCCLUDING edge" << std::endl;
@@ -290,16 +325,14 @@ main (int argc, char ** argv)
   //std::cout << "<4> EDGELABEL_HIGH_CURVATURE edge" << std::endl;
   //std::cout << "<5> EDGELABEL_RGB_CANNY edge" << std::endl;
   std::cout << "<Q,q> quit" << std::endl;
-
-
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb> ())
-  {
+  // clang-format on
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb>()) {
     OpenNIOrganizedEdgeDetection app;
-    app.run ();
+    app.run();
   }
   else
-    PCL_ERROR ("The input device does not provide a PointXYZRGBA mode.\n");
+    PCL_ERROR("The input device does not provide a PointXYZRGBA mode.\n");
 
-  return (0);
+  return 0;
 }
index c6dccdbc54083527fa8ad38e2d662711cc7fcd72..a2a2ad03808f0c4176be47f433f1cfce6b8832ee 100644 (file)
  *
  */
 
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/io/io.h>
 #include <pcl/common/time.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/ModelCoefficients.h>
-#include <pcl/segmentation/planar_region.h>
-#include <pcl/segmentation/organized_multi_plane_segmentation.h>
-#include <pcl/segmentation/organized_connected_component_segmentation.h>
 #include <pcl/filters/extract_indices.h>
+#include <pcl/io/io.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/segmentation/organized_connected_component_segmentation.h>
+#include <pcl/segmentation/organized_multi_plane_segmentation.h>
+#include <pcl/segmentation/planar_region.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/ModelCoefficients.h>
 
 #include <mutex>
 
-
 using PointT = pcl::PointXYZRGBA;
 
-class OpenNIOrganizedMultiPlaneSegmentation
-{
-  private:
-    pcl::visualization::PCLVisualizer::Ptr viewer;
-    pcl::PointCloud<PointT>::ConstPtr prev_cloud;
-    std::mutex cloud_mutex;
-
-  public:
-    OpenNIOrganizedMultiPlaneSegmentation ()
-    {
-
+class OpenNIOrganizedMultiPlaneSegmentation {
+private:
+  pcl::visualization::PCLVisualizer::Ptr viewer;
+  pcl::PointCloud<PointT>::ConstPtr prev_cloud;
+  std::mutex cloud_mutex;
+
+public:
+  OpenNIOrganizedMultiPlaneSegmentation() {}
+  ~OpenNIOrganizedMultiPlaneSegmentation() {}
+
+  pcl::visualization::PCLVisualizer::Ptr
+  cloudViewer(const pcl::PointCloud<PointT>::ConstPtr& cloud)
+  {
+    pcl::visualization::PCLVisualizer::Ptr viewer(
+        new pcl::visualization::PCLVisualizer("Viewer"));
+    viewer->setBackgroundColor(0, 0, 0);
+    pcl::visualization::PointCloudColorHandlerCustom<PointT> single_color(
+        cloud, 0, 255, 0);
+    viewer->addPointCloud<PointT>(cloud, single_color, "cloud");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_OPACITY, 0.15, "cloud");
+    viewer->addCoordinateSystem(1.0, "global");
+    viewer->initCameraParameters();
+    return viewer;
+  }
+
+  void
+  cloud_cb_(const pcl::PointCloud<PointT>::ConstPtr& cloud)
+  {
+    if (!viewer->wasStopped()) {
+      cloud_mutex.lock();
+      prev_cloud = cloud;
+      cloud_mutex.unlock();
     }
-    ~OpenNIOrganizedMultiPlaneSegmentation ()
-    {
+  }
+
+  void
+  removePreviousDataFromScreen(std::size_t prev_models_size)
+  {
+    char name[1024];
+    for (std::size_t i = 0; i < prev_models_size; i++) {
+      sprintf(name, "normal_%lu", i);
+      viewer->removeShape(name);
+
+      sprintf(name, "plane_%02zu", i);
+      viewer->removePointCloud(name);
     }
-
-    pcl::visualization::PCLVisualizer::Ptr
-    cloudViewer (const pcl::PointCloud<PointT>::ConstPtr& cloud)
-    {
-      pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("Viewer"));
-      viewer->setBackgroundColor (0, 0, 0);
-      pcl::visualization::PointCloudColorHandlerCustom<PointT> single_color (cloud, 0, 255, 0);
-      viewer->addPointCloud<PointT> (cloud, single_color, "cloud");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
-      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.15, "cloud");
-      viewer->addCoordinateSystem (1.0, "global");
-      viewer->initCameraParameters ();
-      return (viewer);
-    }
-
-    void
-    cloud_cb_ (const pcl::PointCloud<PointT>::ConstPtr& cloud)
-    {
-      if (!viewer->wasStopped ())
-      {
-        cloud_mutex.lock ();
-        prev_cloud = cloud;
-        cloud_mutex.unlock ();
-      }
-    }
-
-    void
-    removePreviousDataFromScreen (std::size_t prev_models_size)
-    {
-      char name[1024];
-      for (std::size_t i = 0; i < prev_models_size; i++)
-      {
-        sprintf (name, "normal_%lu", i);
-        viewer->removeShape (name);
-
-        sprintf (name, "plane_%02zu", i);
-        viewer->removePointCloud (name);
-      }
-    }
-
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {};
-
-      std::function<void(const pcl::PointCloud<PointT>::ConstPtr&)> f = [this] (const pcl::PointCloud<PointT>::ConstPtr& cloud) { cloud_cb_ (cloud); };
-
-      //make a viewer
-      pcl::PointCloud<PointT>::Ptr init_cloud_ptr (new pcl::PointCloud<PointT>);
-      viewer = cloudViewer (init_cloud_ptr);
-      boost::signals2::connection c = interface.registerCallback (f);
-
-      interface.start ();
-
-      unsigned char red [6] = {255,   0,   0, 255, 255,   0};
-      unsigned char grn [6] = {  0, 255,   0, 255,   0, 255};
-      unsigned char blu [6] = {  0,   0, 255,   0, 255, 255};
-
-      pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
-      ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-      ne.setMaxDepthChangeFactor (0.03f);
-      ne.setNormalSmoothingSize (20.0f);
-
-      pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
-      mps.setMinInliers (10000);
-      mps.setAngularThreshold (0.017453 * 2.0); //3 degrees
-      mps.setDistanceThreshold (0.02); //2cm
-
-      std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > regions;
-      pcl::PointCloud<PointT>::Ptr contour (new pcl::PointCloud<PointT>);
-      std::size_t prev_models_size = 0;
-      char name[1024];
-
-      while (!viewer->wasStopped ())
-      {
-        viewer->spinOnce (100);
-
-        if (prev_cloud && cloud_mutex.try_lock ())
-        {
-          regions.clear ();
-          pcl::PointCloud<pcl::Normal>::Ptr normal_cloud (new pcl::PointCloud<pcl::Normal>);
-          double normal_start = pcl::getTime ();
-          ne.setInputCloud (prev_cloud);
-          ne.compute (*normal_cloud);
-          double normal_end = pcl::getTime ();
-          std::cout << "Normal Estimation took " << double (normal_end - normal_start) << std::endl;
-
-          double plane_extract_start = pcl::getTime ();
-          mps.setInputNormals (normal_cloud);
-          mps.setInputCloud (prev_cloud);
-          mps.segmentAndRefine (regions);
-          double plane_extract_end = pcl::getTime ();
-          std::cout << "Plane extraction took " << double (plane_extract_end - plane_extract_start) << std::endl;
-          std::cout << "Frame took " << double (plane_extract_end - normal_start) << std::endl;
-
-          pcl::PointCloud<PointT>::Ptr cluster (new pcl::PointCloud<PointT>);
-
-          if (!viewer->updatePointCloud<PointT> (prev_cloud, "cloud"))
-            viewer->addPointCloud<PointT> (prev_cloud, "cloud");
-
-          removePreviousDataFromScreen (prev_models_size);
-          //Draw Visualization
-          for (std::size_t i = 0; i < regions.size (); i++)
-          {
-            Eigen::Vector3f centroid = regions[i].getCentroid ();
-            Eigen::Vector4f model = regions[i].getCoefficients ();
-            pcl::PointXYZ pt1 = pcl::PointXYZ (centroid[0], centroid[1], centroid[2]);
-            pcl::PointXYZ pt2 = pcl::PointXYZ (centroid[0] + (0.5f * model[0]),
-                                               centroid[1] + (0.5f * model[1]),
-                                               centroid[2] + (0.5f * model[2]));
-            sprintf (name, "normal_%lu", i);
-            viewer->addArrow (pt2, pt1, 1.0, 0, 0, false, name);
-
-            contour->points = regions[i].getContour ();
-            sprintf (name, "plane_%02zu", i);
-            pcl::visualization::PointCloudColorHandlerCustom <PointT> color (contour, red[i], grn[i], blu[i]);
-            viewer->addPointCloud (contour, color, name);
-            viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, name);
-          }
-          prev_models_size = regions.size ();
-          cloud_mutex.unlock ();
+  }
+
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{};
+
+    std::function<void(const pcl::PointCloud<PointT>::ConstPtr&)> f =
+        [this](const pcl::PointCloud<PointT>::ConstPtr& cloud) { cloud_cb_(cloud); };
+
+    // make a viewer
+    pcl::PointCloud<PointT>::Ptr init_cloud_ptr(new pcl::PointCloud<PointT>);
+    viewer = cloudViewer(init_cloud_ptr);
+    boost::signals2::connection c = interface.registerCallback(f);
+
+    interface.start();
+
+    unsigned char red[6] = {255, 0, 0, 255, 255, 0};
+    unsigned char grn[6] = {0, 255, 0, 255, 0, 255};
+    unsigned char blu[6] = {0, 0, 255, 0, 255, 255};
+
+    pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
+    ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+    ne.setMaxDepthChangeFactor(0.03f);
+    ne.setNormalSmoothingSize(20.0f);
+
+    pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
+    mps.setMinInliers(10000);
+    mps.setAngularThreshold(0.017453 * 2.0); // 3 degrees
+    mps.setDistanceThreshold(0.02);          // 2cm
+
+    std::vector<pcl::PlanarRegion<PointT>,
+                Eigen::aligned_allocator<pcl::PlanarRegion<PointT>>>
+        regions;
+    pcl::PointCloud<PointT>::Ptr contour(new pcl::PointCloud<PointT>);
+    std::size_t prev_models_size = 0;
+    char name[1024];
+
+    while (!viewer->wasStopped()) {
+      viewer->spinOnce(100);
+
+      if (prev_cloud && cloud_mutex.try_lock()) {
+        regions.clear();
+        pcl::PointCloud<pcl::Normal>::Ptr normal_cloud(
+            new pcl::PointCloud<pcl::Normal>);
+        double normal_start = pcl::getTime();
+        ne.setInputCloud(prev_cloud);
+        ne.compute(*normal_cloud);
+        double normal_end = pcl::getTime();
+        std::cout << "Normal Estimation took " << double(normal_end - normal_start)
+                  << std::endl;
+
+        double plane_extract_start = pcl::getTime();
+        mps.setInputNormals(normal_cloud);
+        mps.setInputCloud(prev_cloud);
+        mps.segmentAndRefine(regions);
+        double plane_extract_end = pcl::getTime();
+        std::cout << "Plane extraction took "
+                  << double(plane_extract_end - plane_extract_start) << std::endl;
+        std::cout << "Frame took " << double(plane_extract_end - normal_start)
+                  << std::endl;
+
+        pcl::PointCloud<PointT>::Ptr cluster(new pcl::PointCloud<PointT>);
+
+        if (!viewer->updatePointCloud<PointT>(prev_cloud, "cloud"))
+          viewer->addPointCloud<PointT>(prev_cloud, "cloud");
+
+        removePreviousDataFromScreen(prev_models_size);
+        // Draw Visualization
+        for (std::size_t i = 0; i < regions.size(); i++) {
+          Eigen::Vector3f centroid = regions[i].getCentroid();
+          Eigen::Vector4f model = regions[i].getCoefficients();
+          pcl::PointXYZ pt1 = pcl::PointXYZ(centroid[0], centroid[1], centroid[2]);
+          pcl::PointXYZ pt2 = pcl::PointXYZ(centroid[0] + (0.5f * model[0]),
+                                            centroid[1] + (0.5f * model[1]),
+                                            centroid[2] + (0.5f * model[2]));
+          sprintf(name, "normal_%lu", i);
+          viewer->addArrow(pt2, pt1, 1.0, 0, 0, false, name);
+
+          contour->points = regions[i].getContour();
+          sprintf(name, "plane_%02zu", i);
+          pcl::visualization::PointCloudColorHandlerCustom<PointT> color(
+              contour, red[i], grn[i], blu[i]);
+          viewer->addPointCloud(contour, color, name);
+          viewer->setPointCloudRenderingProperties(
+              pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, name);
         }
+        prev_models_size = regions.size();
+        cloud_mutex.unlock();
       }
-
-      interface.stop ();
     }
+
+    interface.stop();
+  }
 };
 
 int
-main ()
+main()
 {
   OpenNIOrganizedMultiPlaneSegmentation multi_plane_app;
-  multi_plane_app.run ();
+  multi_plane_app.run();
   return 0;
 }
index ba59fce3e85806dff8410336bf46e9c4874185a3..3fbf00cccc9922262df8cf32125c2d100533e334 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <thread>
-
 #include <pcl/apps/openni_passthrough.h>
-// QT
+#include <pcl/console/parse.h>
+
 #include <QApplication>
-#include <QMutexLocker>
 #include <QEvent>
+#include <QMutexLocker>
 #include <QObject>
-// PCL
-#include <pcl/console/parse.h>
 
 #include <vtkRenderWindow.h>
 
+#include <thread>
+
 using namespace std::chrono_literals;
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-OpenNIPassthrough::OpenNIPassthrough (pcl::OpenNIGrabber& grabber) 
-  : grabber_(grabber)
-  , ui_ (new Ui::MainWindow)
-  , vis_timer_ (new QTimer (this))
+OpenNIPassthrough::OpenNIPassthrough(pcl::OpenNIGrabber& grabber)
+: grabber_(grabber), ui_(new Ui::MainWindow), vis_timer_(new QTimer(this))
 {
   // Create a timer and fire it up every 5ms
-  vis_timer_->start (5);
+  vis_timer_->start(5);
 
-  connect (vis_timer_, SIGNAL (timeout ()), this, SLOT (timeoutSlot ()));
+  connect(vis_timer_, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
 
-  ui_->setupUi (this);
+  ui_->setupUi(this);
 
-  this->setWindowTitle ("PCL OpenNI PassThrough Viewer");
-  vis_.reset (new pcl::visualization::PCLVisualizer ("", false));
-  ui_->qvtk_widget->SetRenderWindow (vis_->getRenderWindow ());
-  vis_->setupInteractor (ui_->qvtk_widget->GetInteractor (), ui_->qvtk_widget->GetRenderWindow ());
-  vis_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
-  ui_->qvtk_widget->update (); 
+  this->setWindowTitle("PCL OpenNI PassThrough Viewer");
+  vis_.reset(new pcl::visualization::PCLVisualizer("", false));
+  ui_->qvtk_widget->SetRenderWindow(vis_->getRenderWindow());
+  vis_->setupInteractor(ui_->qvtk_widget->GetInteractor(),
+                        ui_->qvtk_widget->GetRenderWindow());
+  vis_->getInteractorStyle()->setKeyboardModifier(
+      pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
+  ui_->qvtk_widget->update();
 
   // Start the OpenNI data acquision
-  std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-  boost::signals2::connection c = grabber_.registerCallback (f);
+  std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+    cloud_cb(cloud);
+  };
+  boost::signals2::connection c = grabber_.registerCallback(f);
 
-  grabber_.start ();
+  grabber_.start();
 
   // Set defaults
-  pass_.setFilterFieldName ("z");
-  pass_.setFilterLimits (0.5, 5.0);
-  
-  ui_->fieldValueSlider->setRange (5, 50);
-  ui_->fieldValueSlider->setValue (50);
-  connect (ui_->fieldValueSlider, SIGNAL (valueChanged (int)), this, SLOT (adjustPassThroughValues (int)));
+  pass_.setFilterFieldName("z");
+  pass_.setFilterLimits(0.5, 5.0);
+
+  ui_->fieldValueSlider->setRange(5, 50);
+  ui_->fieldValueSlider->setValue(50);
+  connect(ui_->fieldValueSlider,
+          SIGNAL(valueChanged(int)),
+          this,
+          SLOT(adjustPassThroughValues(int)));
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 void
-OpenNIPassthrough::cloud_cb (const CloudConstPtr& cloud)
+OpenNIPassthrough::cloud_cb(const CloudConstPtr& cloud)
 {
-  QMutexLocker locker (&mtx_);  
-  FPS_CALC ("computation");
+  QMutexLocker locker(&mtx_);
+  FPS_CALC("computation");
 
   // Computation goes here
-  cloud_pass_.reset (new Cloud);
-  pass_.setInputCloud (cloud);
-  pass_.filter (*cloud_pass_);
+  cloud_pass_.reset(new Cloud);
+  pass_.setInputCloud(cloud);
+  pass_.filter(*cloud_pass_);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 void
-OpenNIPassthrough::timeoutSlot ()
+OpenNIPassthrough::timeoutSlot()
 {
-  if (!cloud_pass_)
-  {
+  if (!cloud_pass_) {
     std::this_thread::sleep_for(1ms);
     return;
   }
 
   CloudPtr temp_cloud;
   {
-    QMutexLocker locker (&mtx_);
-    temp_cloud.swap (cloud_pass_); 
+    QMutexLocker locker(&mtx_);
+    temp_cloud.swap(cloud_pass_);
   }
   // Add to the 3D viewer
-  if (!vis_->updatePointCloud (temp_cloud, "cloud_pass"))
-  {
-    vis_->addPointCloud (temp_cloud, "cloud_pass");
-    vis_->resetCameraViewpoint ("cloud_pass");
+  if (!vis_->updatePointCloud(temp_cloud, "cloud_pass")) {
+    vis_->addPointCloud(temp_cloud, "cloud_pass");
+    vis_->resetCameraViewpoint("cloud_pass");
   }
-  FPS_CALC ("visualization");
-  ui_->qvtk_widget->update ();
+  FPS_CALC("visualization");
+  ui_->qvtk_widget->update();
 }
 
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
   // Initialize QT
-  QApplication app (argc, argv); 
+  QApplication app(argc, argv);
 
   // Open the first available camera
-  pcl::OpenNIGrabber grabber ("#1");
+  pcl::OpenNIGrabber grabber("#1");
   // Check if an RGB stream is provided
-  if (!grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb> ())
-  {
-    PCL_ERROR ("Device #1 does not provide an RGB stream!\n");
-    return (-1);
+  if (!grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb>()) {
+    PCL_ERROR("Device #1 does not provide an RGB stream!\n");
+    return -1;
   }
 
-  OpenNIPassthrough v (grabber);
-  v.show ();
-  return (QApplication::exec ());
+  OpenNIPassthrough v(grabber);
+  v.show();
+  return QApplication::exec();
 }
index e7fe128786455ccc6f8473b72ca148c5a8aeba6c..ba4deeae48d128ec513690ccb230572c491fe783 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/console/parse.h>
+#include <pcl/filters/project_inliers.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/io/openni_grabber.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
 #include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/filters/project_inliers.h>
 #include <pcl/surface/convex_hull.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 
 template <typename PointType>
-class OpenNIPlanarSegmentation
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIPlanarSegmentation (const std::string& device_id = "", double threshold = 0.01)
-      : viewer ("PCL OpenNI Planar Hull Segmentation Viewer"),
-        device_id_ (device_id)
-    {
-      grid_.setFilterFieldName ("z");
-      grid_.setFilterLimits (0.0, 3.0);
-      grid_.setLeafSize (0.01f, 0.01f, 0.01f);
-
-      seg_.setOptimizeCoefficients (true);
-      seg_.setModelType (pcl::SACMODEL_PLANE);
-      seg_.setMethodType (pcl::SAC_RANSAC);
-      seg_.setMaxIterations (1000);
-      seg_.setDistanceThreshold (threshold);
-
-      proj_.setModelType (pcl::SACMODEL_PLANE);
-    }
+class OpenNIPlanarSegmentation {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIPlanarSegmentation(const std::string& device_id = "", double threshold = 0.01)
+  : viewer("PCL OpenNI Planar Hull Segmentation Viewer"), device_id_(device_id)
+  {
+    grid_.setFilterFieldName("z");
+    grid_.setFilterLimits(0.0, 3.0);
+    grid_.setLeafSize(0.01f, 0.01f, 0.01f);
 
-    void 
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      set (cloud);
-    }
+    seg_.setOptimizeCoefficients(true);
+    seg_.setModelType(pcl::SACMODEL_PLANE);
+    seg_.setMethodType(pcl::SAC_RANSAC);
+    seg_.setMaxIterations(1000);
+    seg_.setDistanceThreshold(threshold);
 
-    void
-    set (const CloudConstPtr& cloud)
-    {
-      //lock while we set our cloud;
-      std::lock_guard<std::mutex> lock (mtx_);
-      cloud_  = cloud;
-    }
+    proj_.setModelType(pcl::SACMODEL_PLANE);
+  }
+
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    set(cloud);
+  }
 
-    CloudPtr
-    get ()
-    {
-      //lock while we swap our cloud and reset it.
-      std::lock_guard<std::mutex> lock (mtx_);
-      CloudPtr temp_cloud (new Cloud);
-      CloudPtr temp_cloud2 (new Cloud);
+  void
+  set(const CloudConstPtr& cloud)
+  {
+    // lock while we set our cloud;
+    std::lock_guard<std::mutex> lock(mtx_);
+    cloud_ = cloud;
+  }
 
-      grid_.setInputCloud (cloud_);
-      grid_.filter (*temp_cloud);
+  CloudPtr
+  get()
+  {
+    // lock while we swap our cloud and reset it.
+    std::lock_guard<std::mutex> lock(mtx_);
+    CloudPtr temp_cloud(new Cloud);
+    CloudPtr temp_cloud2(new Cloud);
 
-      pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
-      pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
+    grid_.setInputCloud(cloud_);
+    grid_.filter(*temp_cloud);
 
-      seg_.setInputCloud (temp_cloud);
-      seg_.segment (*inliers, *coefficients);
+    pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
+    pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
 
-      // Project the model inliers 
-      proj_.setInputCloud (temp_cloud);
-      proj_.setModelCoefficients (coefficients);
-      proj_.filter (*temp_cloud2);
+    seg_.setInputCloud(temp_cloud);
+    seg_.segment(*inliers, *coefficients);
 
-      // Create a Convex Hull representation of the projected inliers
-      chull_.setInputCloud (temp_cloud2);
-      chull_.reconstruct (*temp_cloud);
+    // Project the model inliers
+    proj_.setInputCloud(temp_cloud);
+    proj_.setModelCoefficients(coefficients);
+    proj_.filter(*temp_cloud2);
 
-      return (temp_cloud);
-    }
+    // Create a Convex Hull representation of the projected inliers
+    chull_.setInputCloud(temp_cloud2);
+    chull_.reconstruct(*temp_cloud);
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
-
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
-      
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        if (cloud_)
-        {
-          //the call to get() sets the cloud_ to null;
-          viewer.showCloud (get ());
-        }
-      }
+    return temp_cloud;
+  }
+
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
+
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      interface.stop ();
+    interface.start();
+
+    while (!viewer.wasStopped()) {
+      if (cloud_) {
+        // the call to get() sets the cloud_ to null;
+        viewer.showCloud(get());
+      }
     }
 
-    pcl::visualization::CloudViewer viewer;
-    pcl::VoxelGrid<PointType> grid_;
-    pcl::SACSegmentation<PointType> seg_;
-    pcl::ProjectInliers<PointType> proj_;
-    pcl::ConvexHull<PointType> chull_;
+    interface.stop();
+  }
+
+  pcl::visualization::CloudViewer viewer;
+  pcl::VoxelGrid<PointType> grid_;
+  pcl::SACSegmentation<PointType> seg_;
+  pcl::ProjectInliers<PointType> proj_;
+  pcl::ConvexHull<PointType> chull_;
 
-    std::string device_id_;
-    std::mutex mtx_;
-    CloudConstPtr cloud_;
+  std::string device_id_;
+  std::mutex mtx_;
+  CloudConstPtr cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n"
-            << "where options are:\n         -thresh X        :: set the planar segmentation threshold (default: 0.5)\n";
+            << "where options are:\n         -thresh X        :: set the planar "
+               "segmentation threshold (default: 0.5)\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (wotks only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
     std::cout << "No devices connected." << std::endl;
 }
 
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
-  if (argc < 2)
-  {
-    usage (argv);
+  if (argc < 2) {
+    usage(argv);
     return 1;
   }
 
-  std::string arg (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  std::string arg(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
   double threshold = 0.05;
-  pcl::console::parse_argument (argc, argv, "-thresh", threshold);
+  pcl::console::parse_argument(argc, argv, "-thresh", threshold);
 
-  pcl::OpenNIGrabber grabber (arg);
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    OpenNIPlanarSegmentation<pcl::PointXYZRGBA> v (arg, threshold);
-    v.run ();
+  pcl::OpenNIGrabber grabber(arg);
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    OpenNIPlanarSegmentation<pcl::PointXYZRGBA> v(arg, threshold);
+    v.run();
   }
-  else
-  {
-    OpenNIPlanarSegmentation<pcl::PointXYZ> v (arg, threshold);
-    v.run ();
+  else {
+    OpenNIPlanarSegmentation<pcl::PointXYZ> v(arg, threshold);
+    v.run();
   }
 
-  return (0);
+  return 0;
 }
index c1b48b291a167115186eb082b53af07b9e0975c7..7256510f5112584e5927fd51ed774b77a692b602 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/console/parse.h>
+#include <pcl/filters/extract_indices.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/io/openni_grabber.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
 #include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/filters/voxel_grid.h>
-#include <pcl/filters/extract_indices.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 
-
 template <typename PointType>
-class OpenNIPlanarSegmentation
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIPlanarSegmentation (const std::string& device_id = "", double threshold = 0.01)
-      : viewer ("PCL OpenNI Planar Segmentation Viewer"),
-        device_id_ (device_id)
-    {
-      grid_.setFilterFieldName ("z");
-      grid_.setFilterLimits (0.0f, 3.0f);
-      grid_.setLeafSize (0.01f, 0.01f, 0.01f);
-
-      seg_.setOptimizeCoefficients (true);
-      seg_.setModelType (pcl::SACMODEL_PLANE);
-      seg_.setMethodType (pcl::SAC_RANSAC);
-      seg_.setMaxIterations (1000);
-      seg_.setDistanceThreshold (threshold);
-
-      extract_.setNegative (false);
-    }
+class OpenNIPlanarSegmentation {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIPlanarSegmentation(const std::string& device_id = "", double threshold = 0.01)
+  : viewer("PCL OpenNI Planar Segmentation Viewer"), device_id_(device_id)
+  {
+    grid_.setFilterFieldName("z");
+    grid_.setFilterLimits(0.0f, 3.0f);
+    grid_.setLeafSize(0.01f, 0.01f, 0.01f);
 
-    void 
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      set (cloud);
-    }
+    seg_.setOptimizeCoefficients(true);
+    seg_.setModelType(pcl::SACMODEL_PLANE);
+    seg_.setMethodType(pcl::SAC_RANSAC);
+    seg_.setMaxIterations(1000);
+    seg_.setDistanceThreshold(threshold);
 
-    void
-    set (const CloudConstPtr& cloud)
-    {
-      //lock while we set our cloud;
-      std::lock_guard<std::mutex> lock (mtx_);
-      cloud_  = cloud;
-    }
+    extract_.setNegative(false);
+  }
 
-    CloudPtr
-    get ()
-    {
-      //lock while we swap our cloud and reset it.
-      std::lock_guard<std::mutex> lock (mtx_);
-      CloudPtr temp_cloud (new Cloud);
-      CloudPtr temp_cloud2 (new Cloud);
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    set(cloud);
+  }
 
-      grid_.setInputCloud (cloud_);
-      grid_.filter (*temp_cloud);
+  void
+  set(const CloudConstPtr& cloud)
+  {
+    // lock while we set our cloud;
+    std::lock_guard<std::mutex> lock(mtx_);
+    cloud_ = cloud;
+  }
 
-      pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
-      pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
+  CloudPtr
+  get()
+  {
+    // lock while we swap our cloud and reset it.
+    std::lock_guard<std::mutex> lock(mtx_);
+    CloudPtr temp_cloud(new Cloud);
+    CloudPtr temp_cloud2(new Cloud);
 
-      seg_.setInputCloud (temp_cloud);
-      seg_.segment (*inliers, *coefficients);
+    grid_.setInputCloud(cloud_);
+    grid_.filter(*temp_cloud);
 
-      extract_.setInputCloud (temp_cloud);
-      extract_.setIndices (inliers);
-      extract_.filter (*temp_cloud2);
+    pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
+    pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
 
-      return (temp_cloud2);
-    }
+    seg_.setInputCloud(temp_cloud);
+    seg_.segment(*inliers, *coefficients);
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
-
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
-      
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        if (cloud_)
-        {
-          //the call to get() sets the cloud_ to null;
-          viewer.showCloud (get ());
-        }
-      }
+    extract_.setInputCloud(temp_cloud);
+    extract_.setIndices(inliers);
+    extract_.filter(*temp_cloud2);
+
+    return temp_cloud2;
+  }
+
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
+
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      interface.stop ();
+    interface.start();
+
+    while (!viewer.wasStopped()) {
+      if (cloud_) {
+        // the call to get() sets the cloud_ to null;
+        viewer.showCloud(get());
+      }
     }
 
-    pcl::visualization::CloudViewer viewer;
-    pcl::VoxelGrid<PointType> grid_;
-    pcl::SACSegmentation<PointType> seg_;
-    pcl::ExtractIndices<PointType> extract_;
+    interface.stop();
+  }
+
+  pcl::visualization::CloudViewer viewer;
+  pcl::VoxelGrid<PointType> grid_;
+  pcl::SACSegmentation<PointType> seg_;
+  pcl::ExtractIndices<PointType> extract_;
 
-    std::string device_id_;
-    std::mutex mtx_;
-    CloudConstPtr cloud_;
+  std::string device_id_;
+  std::mutex mtx_;
+  CloudConstPtr cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n"
-            << "where options are:\n         -thresh X        :: set the planar segmentation threshold (default: 0.5)\n";
+            << "where options are:\n         -thresh X        :: set the planar "
+               "segmentation threshold (default: 0.5)\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
     std::cout << "No devices connected." << std::endl;
 }
 
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
-  if (argc < 2)
-  {
-    usage (argv);
+  if (argc < 2) {
+    usage(argv);
     return 1;
   }
 
-  std::string arg (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  std::string arg(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
   double threshold = 0.05;
-  pcl::console::parse_argument (argc, argv, "-thresh", threshold);
+  pcl::console::parse_argument(argc, argv, "-thresh", threshold);
 
-  pcl::OpenNIGrabber grabber (arg);
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    OpenNIPlanarSegmentation<pcl::PointXYZRGBA> v (arg, threshold);
-    v.run ();
+  pcl::OpenNIGrabber grabber(arg);
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    OpenNIPlanarSegmentation<pcl::PointXYZRGBA> v(arg, threshold);
+    v.run();
   }
-  else
-  {
-    OpenNIPlanarSegmentation<pcl::PointXYZ> v (arg, threshold);
-    v.run ();
+  else {
+    OpenNIPlanarSegmentation<pcl::PointXYZ> v(arg, threshold);
+    v.run();
   }
 
-  return (0);
+  return 0;
 }
index b9d2d783c24dceacd43f008fc5a66147f0a6fdf4..5d7b4ed35aa6cf6409e2bb3cf860ce610f32d935 100644 (file)
  * Author: Julius Kammerl (julius@kammerl.de)
  */
 
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+
+#include <boost/asio.hpp>
 
-#include <iostream>
-#include <vector>
 #include <cstdio>
-#include <sstream>
 #include <cstdlib>
 #include <iostream>
+#include <sstream>
 #include <string>
 #include <thread>
-
-#include <boost/asio.hpp>
+#include <vector>
 
 using boost::asio::ip::tcp;
 
@@ -61,172 +59,161 @@ using namespace pcl::io;
 using namespace std;
 using namespace std::chrono_literals;
 
-class SimpleOpenNIViewer
-{
-  public:
-    SimpleOpenNIViewer () :
-      viewer_ ("Input Point Cloud - Shift-to-depth conversion viewer"),
-      grabber_(nullptr)
-    {
-    }
+class SimpleOpenNIViewer {
+public:
+  SimpleOpenNIViewer()
+  : viewer_("Input Point Cloud - Shift-to-depth conversion viewer")
+  , grabber_("",
+             pcl::OpenNIGrabber::OpenNI_Default_Mode,
+             pcl::OpenNIGrabber::OpenNI_Default_Mode)
+  {}
 
-    ~SimpleOpenNIViewer ()
-    {
-      if (grabber_)
-        delete grabber_;
-    }
-
-    void
-    image_callback (const openni_wrapper::Image::Ptr &image,
-                    const openni_wrapper::DepthImage::Ptr &depth_image, float)
-    {
-
-      std::vector<std::uint16_t> raw_shift_data;
-      std::vector<std::uint16_t> raw_depth_data;
-
-      std::vector<std::uint8_t> rgb_data;
-
-      std::uint32_t width=depth_image->getWidth ();
-      std::uint32_t height=depth_image->getHeight ();
-
-      // copy raw shift data from depth_image
-      raw_shift_data.resize(width*height);
-      depth_image->fillDepthImageRaw (width, height, &raw_shift_data[0], static_cast<unsigned int> (width * sizeof (std::uint16_t)));
+  void
+  image_callback(const openni_wrapper::Image::Ptr& image,
+                 const openni_wrapper::DepthImage::Ptr& depth_image,
+                 float)
+  {
 
-      // convert raw shift data to raw depth data
-      raw_depth_data.resize(width*height);
-      grabber_->convertShiftToDepth(&raw_shift_data[0], &raw_depth_data[0], raw_shift_data.size());
+    std::vector<std::uint16_t> raw_shift_data;
+    std::vector<std::uint16_t> raw_depth_data;
+
+    std::vector<std::uint8_t> rgb_data;
+
+    std::uint32_t width = depth_image->getWidth();
+    std::uint32_t height = depth_image->getHeight();
+
+    // copy raw shift data from depth_image
+    raw_shift_data.resize(width * height);
+    depth_image->fillDepthImageRaw(
+        width,
+        height,
+        &raw_shift_data[0],
+        static_cast<unsigned int>(width * sizeof(std::uint16_t)));
+
+    // convert raw shift data to raw depth data
+    raw_depth_data.resize(width * height);
+    grabber_.convertShiftToDepth(
+        &raw_shift_data[0], &raw_depth_data[0], raw_shift_data.size());
+
+    // check for color data
+    if (image->getEncoding() != openni_wrapper::Image::RGB) {
+      // copy raw rgb data from image
+      rgb_data.resize(width * height * 3);
+      image->fillRGB(width,
+                     height,
+                     &rgb_data[0],
+                     static_cast<unsigned int>(width * sizeof(std::uint8_t) * 3));
+    }
 
-      // check for color data
-      if (image->getEncoding() != openni_wrapper::Image::RGB)
-      {
-        // copy raw rgb data from image
-        rgb_data.resize(width*height*3);
-        image->fillRGB(width, height, &rgb_data[0], static_cast<unsigned int> (width * sizeof (std::uint8_t) * 3));
-      }
+    // empty pointcloud
+    pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud =
+        pcl::PointCloud<pcl::PointXYZRGB>::Ptr(new pcl::PointCloud<pcl::PointXYZRGB>());
 
-      // empty pointcloud
-      pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = pcl::PointCloud<pcl::PointXYZRGB>::Ptr(new pcl::PointCloud<pcl::PointXYZRGB>());
+    // convert raw depth and rgb data to pointcloud
+    convert(
+        raw_depth_data, rgb_data, width, height, depth_image->getFocalLength(), *cloud);
 
-      // convert raw depth and rgb data to pointcloud
-      convert (raw_depth_data,
-               rgb_data,
-               width,
-               height,
-               depth_image->getFocalLength(),
-               *cloud);
+    // display pointcloud
+    viewer_.showCloud(cloud);
+  }
 
-      // display pointcloud
-      viewer_.showCloud (cloud);
+  void
+  run()
+  {
+    // initialize OpenNIDevice to shift-value mode
+    int depthformat = openni_wrapper::OpenNIDevice::OpenNI_shift_values;
+
+    // Set the depth output format
+    grabber_.getDevice()->setDepthOutputFormat(
+        static_cast<openni_wrapper::OpenNIDevice::DepthMode>(depthformat));
+
+    // define image callback
+    std::function<void(const openni_wrapper::Image::Ptr&,
+                       const openni_wrapper::DepthImage::Ptr&,
+                       float)>
+        image_cb = [this](const openni_wrapper::Image::Ptr& img,
+                          const openni_wrapper::DepthImage::Ptr& depth,
+                          float f) { image_callback(img, depth, f); };
+    grabber_.registerCallback(image_cb);
+
+    // start grabber thread
+    grabber_.start();
+    while (true) {
+      std::this_thread::sleep_for(1s);
     }
-
-    void
-    run ()
-    {
-      // initialize OpenNIDevice to shift-value mode
-      pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
-      int depthformat = openni_wrapper::OpenNIDevice::OpenNI_shift_values;
-
-      grabber_ = new pcl::OpenNIGrabber("", pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);
-
-      // Set the depth output format
-      grabber_->getDevice ()->setDepthOutputFormat (static_cast<openni_wrapper::OpenNIDevice::DepthMode> (depthformat));
-
-      // define image callback
-      std::function<void
-      (const openni_wrapper::Image::Ptr&, const openni_wrapper::DepthImage::Ptr&, float)> image_cb =
-          [this] (const openni_wrapper::Image::Ptr& img, const openni_wrapper::DepthImage::Ptr& depth, float f)
-          {
-            image_callback (img, depth, f);
-          };
-      boost::signals2::connection image_connection = grabber_->registerCallback (image_cb);
-
-      // start grabber thread
-      grabber_->start ();
-      while (true)
-      {
-        std::this_thread::sleep_for(1s);
-      }
-      grabber_->stop ();
-
+    grabber_.stop();
   }
 
 protected:
-
   /* helper method to convert depth&rgb data to pointcloud*/
   void
-  convert (std::vector<std::uint16_t>& depthData_arg,
-           std::vector<std::uint8_t>& rgbData_arg,
-           std::size_t width_arg,
-           std::size_t height_arg,
-           float focalLength_arg,
-           pcl::PointCloud<PointXYZRGB>& cloud_arg) const
+  convert(std::vector<std::uint16_t>& depthData_arg,
+          std::vector<std::uint8_t>& rgbData_arg,
+          std::size_t width_arg,
+          std::size_t height_arg,
+          float focalLength_arg,
+          pcl::PointCloud<PointXYZRGB>& cloud_arg) const
   {
     std::size_t cloud_size = width_arg * height_arg;
 
     // Reset point cloud
-    cloud_arg.points.clear ();
-    cloud_arg.points.reserve (cloud_size);
+    cloud_arg.points.clear();
+    cloud_arg.points.reserve(cloud_size);
 
     // Define point cloud parameters
-    cloud_arg.width = static_cast<std::uint32_t> (width_arg);
-    cloud_arg.height = static_cast<std::uint32_t> (height_arg);
+    cloud_arg.width = static_cast<std::uint32_t>(width_arg);
+    cloud_arg.height = static_cast<std::uint32_t>(height_arg);
     cloud_arg.is_dense = false;
 
     // Calculate center of disparity image
-    int centerX = static_cast<int> (width_arg / 2);
-    int centerY = static_cast<int> (height_arg / 2);
+    int centerX = static_cast<int>(width_arg / 2);
+    int centerY = static_cast<int>(height_arg / 2);
 
     const float fl_const = 1.0f / focalLength_arg;
-    static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
+    static const float bad_point = std::numeric_limits<float>::quiet_NaN();
 
     std::size_t i = 0;
     for (int y = -centerY; y < +centerY; ++y)
-      for (int x = -centerX; x < +centerX; ++x)
-      {
+      for (int x = -centerX; x < +centerX; ++x) {
         PointXYZRGB newPoint;
 
         const std::uint16_t& pixel_depth = depthData_arg[i];
 
-        if (pixel_depth)
-        {
-          float depth = pixel_depth/1000.0f; // raw mm -> m
+        if (pixel_depth) {
+          float depth = pixel_depth / 1000.0f; // raw mm -> m
 
           // Define point location
           newPoint.z = depth;
-          newPoint.x = static_cast<float> (x) * depth * fl_const;
-          newPoint.y = static_cast<float> (y) * depth * fl_const;
+          newPoint.x = static_cast<float>(x) * depth * fl_const;
+          newPoint.y = static_cast<float>(y) * depth * fl_const;
 
           // Define point color
           newPoint.r = rgbData_arg[i * 3 + 0];
           newPoint.g = rgbData_arg[i * 3 + 1];
           newPoint.b = rgbData_arg[i * 3 + 2];
         }
-        else
-        {
+        else {
           // Define bad point
           newPoint.x = newPoint.y = newPoint.z = bad_point;
           newPoint.rgba = 0;
         }
 
         // Add point to cloud
-        cloud_arg.points.push_back (newPoint);
+        cloud_arg.points.push_back(newPoint);
         // Increment point iterator
         ++i;
       }
   }
 
   pcl::visualization::CloudViewer viewer_;
-  pcl::OpenNIGrabber* grabber_;
-
+  pcl::OpenNIGrabber grabber_;
 };
 
 int
-main (int, char **)
+main(int, char**)
 {
   SimpleOpenNIViewer v;
-  v.run ();
+  v.run();
 
-  return (0);
+  return 0;
 }
-
index 3323f3a6d50668c4165ff4e7e46b3bfe945b8b56..9f75ec41d4fae2b570a65684be3d280a5f3f9440 100644 (file)
  *
  */
 
-#include <pcl/tracking/tracking.h>
-#include <pcl/tracking/particle_filter.h>
-#include <pcl/tracking/kld_adaptive_particle_filter_omp.h>
-#include <pcl/tracking/particle_filter_omp.h>
-#include <pcl/tracking/coherence.h>
-#include <pcl/tracking/distance_coherence.h>
-#include <pcl/tracking/hsv_color_coherence.h>
-#include <pcl/tracking/normal_coherence.h>
-#include <pcl/tracking/approx_nearest_pair_point_cloud_coherence.h>
-#include <pcl/tracking/nearest_pair_point_cloud_coherence.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
 #include <pcl/common/centroid.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/io/pcd_io.h>
+#include <pcl/common/time.h>
+#include <pcl/common/transforms.h>
+#include <pcl/console/parse.h>
+#include <pcl/features/integral_image_normal.h>
+#include <pcl/features/normal_3d.h>
+#include <pcl/features/normal_3d_omp.h>
+#include <pcl/filters/approximate_voxel_grid.h>
+#include <pcl/filters/extract_indices.h>
 #include <pcl/filters/passthrough.h>
 #include <pcl/filters/project_inliers.h>
 #include <pcl/filters/voxel_grid.h>
-#include <pcl/filters/approximate_voxel_grid.h>
-#include <pcl/filters/extract_indices.h>
-#include <pcl/features/normal_3d.h>
-#include <pcl/features/normal_3d_omp.h>
-#include <pcl/features/integral_image_normal.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
-#include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/segmentation/extract_polygonal_prism_data.h>
+#include <pcl/search/pcl_search.h>
 #include <pcl/segmentation/extract_clusters.h>
+#include <pcl/segmentation/extract_polygonal_prism_data.h>
+#include <pcl/segmentation/sac_segmentation.h>
 #include <pcl/surface/convex_hull.h>
-#include <pcl/search/pcl_search.h>
-#include <pcl/common/transforms.h>
+#include <pcl/tracking/approx_nearest_pair_point_cloud_coherence.h>
+#include <pcl/tracking/coherence.h>
+#include <pcl/tracking/distance_coherence.h>
+#include <pcl/tracking/hsv_color_coherence.h>
+#include <pcl/tracking/kld_adaptive_particle_filter_omp.h>
+#include <pcl/tracking/nearest_pair_point_cloud_coherence.h>
+#include <pcl/tracking/normal_coherence.h>
+#include <pcl/tracking/particle_filter.h>
+#include <pcl/tracking/particle_filter_omp.h>
+#include <pcl/tracking/tracking.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <boost/format.hpp>
 
 #include <mutex>
 #include <thread>
 
-#define FPS_CALC_BEGIN                          \
-    static double duration = 0;                 \
-    double start_time = pcl::getTime ();        \
-
-#define FPS_CALC_END(_WHAT_)                    \
-  {                                             \
-    double end_time = pcl::getTime ();          \
-    static unsigned count = 0;                  \
-    if (++count == 10)                          \
-    {                                           \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(duration) << " Hz" <<  std::endl; \
-      count = 0;                                                        \
-      duration = 0.0;                                                   \
-    }                                           \
-    else                                        \
-    {                                           \
-      duration += end_time - start_time;        \
-    }                                           \
+#define FPS_CALC_BEGIN                                                                 \
+  static double duration = 0;                                                          \
+  double start_time = pcl::getTime();
+
+// clang-format off
+#define FPS_CALC_END(_WHAT_)                                                           \
+  {                                                                                    \
+    double end_time = pcl::getTime();                                                  \
+    static unsigned count = 0;                                                         \
+    if (++count == 10) {                                                               \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(duration) << " Hz" << std::endl;             \
+      count = 0;                                                                       \
+      duration = 0.0;                                                                  \
+    }                                                                                  \
+    else {                                                                             \
+      duration += end_time - start_time;                                               \
+    }                                                                                  \
   }
+// clang-format on
 
 using namespace pcl::tracking;
 using namespace std::chrono_literals;
 
 template <typename PointType>
-class OpenNISegmentTracking
-{
+class OpenNISegmentTracking {
 public:
-  //using RefPointType = pcl::PointXYZRGBANormal;
   using RefPointType = pcl::PointXYZRGBA;
-  //using RefPointType = pcl::PointXYZ;
   using ParticleT = ParticleXYZRPY;
-  
+
   using Cloud = pcl::PointCloud<PointType>;
   using RefCloud = pcl::PointCloud<RefPointType>;
   using RefCloudPtr = RefCloud::Ptr;
   using RefCloudConstPtr = RefCloud::ConstPtr;
   using CloudPtr = typename Cloud::Ptr;
   using CloudConstPtr = typename Cloud::ConstPtr;
-  //using ParticleFilter = KLDAdaptiveParticleFilterTracker<RefPointType, ParticleT>;
-  //using ParticleFilter = KLDAdaptiveParticleFilterOMPTracker<RefPointType, ParticleT>;
-  //using ParticleFilter = ParticleFilterOMPTracker<RefPointType, ParticleT>;
   using ParticleFilter = ParticleFilterTracker<RefPointType, ParticleT>;
   using CoherencePtr = ParticleFilter::CoherencePtr;
   using KdTree = pcl::search::KdTree<PointType>;
   using KdTreePtr = typename KdTree::Ptr;
-  OpenNISegmentTracking (const std::string& device_id, int thread_nr, double downsampling_grid_size,
-                         bool use_convex_hull,
-                         bool visualize_non_downsample, bool visualize_particles,
-                         bool use_fixed)
-  : viewer_ ("PCL OpenNI Tracking Viewer")
-  , device_id_ (device_id)
-  , new_cloud_ (false)
-  , ne_ (thread_nr)
-  , counter_ (0)
-  , use_convex_hull_ (use_convex_hull)
-  , visualize_non_downsample_ (visualize_non_downsample)
-  , visualize_particles_ (visualize_particles)
-  , downsampling_grid_size_ (downsampling_grid_size)
+  OpenNISegmentTracking(const std::string& device_id,
+                        int thread_nr,
+                        double downsampling_grid_size,
+                        bool use_convex_hull,
+                        bool visualize_non_downsample,
+                        bool visualize_particles,
+                        bool use_fixed)
+  : viewer_("PCL OpenNI Tracking Viewer")
+  , device_id_(device_id)
+  , new_cloud_(false)
+  , ne_(thread_nr)
+  , counter_(0)
+  , use_convex_hull_(use_convex_hull)
+  , visualize_non_downsample_(visualize_non_downsample)
+  , visualize_particles_(visualize_particles)
+  , downsampling_grid_size_(downsampling_grid_size)
   {
-    KdTreePtr tree (new KdTree (false));
-    ne_.setSearchMethod (tree);
-    ne_.setRadiusSearch (0.03);
-    
-    std::vector<double> default_step_covariance = std::vector<double> (6, 0.015 * 0.015);
+    KdTreePtr tree(new KdTree(false));
+    ne_.setSearchMethod(tree);
+    ne_.setRadiusSearch(0.03);
+
+    std::vector<double> default_step_covariance = std::vector<double>(6, 0.015 * 0.015);
     default_step_covariance[3] *= 40.0;
     default_step_covariance[4] *= 40.0;
     default_step_covariance[5] *= 40.0;
-    
-    std::vector<double> initial_noise_covariance = std::vector<double> (6, 0.00001);
-    std::vector<double> default_initial_mean = std::vector<double> (6, 0.0);
-    if (use_fixed)
-    {
-      ParticleFilterOMPTracker<RefPointType, ParticleT>::Ptr tracker
-        (new ParticleFilterOMPTracker<RefPointType, ParticleT> (thread_nr));
+
+    std::vector<double> initial_noise_covariance = std::vector<double>(6, 0.00001);
+    std::vector<double> default_initial_mean = std::vector<double>(6, 0.0);
+    if (use_fixed) {
+      ParticleFilterOMPTracker<RefPointType, ParticleT>::Ptr tracker(
+          new ParticleFilterOMPTracker<RefPointType, ParticleT>(thread_nr));
       tracker_ = tracker;
     }
-    else
-    {
-      KLDAdaptiveParticleFilterOMPTracker<RefPointType, ParticleT>::Ptr tracker
-        (new KLDAdaptiveParticleFilterOMPTracker<RefPointType, ParticleT> (thread_nr));
-      tracker->setMaximumParticleNum (500);
-      tracker->setDelta (0.99);
-      tracker->setEpsilon (0.2);
+    else {
+      KLDAdaptiveParticleFilterOMPTracker<RefPointType, ParticleT>::Ptr tracker(
+          new KLDAdaptiveParticleFilterOMPTracker<RefPointType, ParticleT>(thread_nr));
+      tracker->setMaximumParticleNum(500);
+      tracker->setDelta(0.99);
+      tracker->setEpsilon(0.2);
       ParticleT bin_size;
       bin_size.x = 0.1f;
       bin_size.y = 0.1f;
@@ -166,488 +162,466 @@ public:
       bin_size.roll = 0.1f;
       bin_size.pitch = 0.1f;
       bin_size.yaw = 0.1f;
-      tracker->setBinSize (bin_size);
+      tracker->setBinSize(bin_size);
       tracker_ = tracker;
     }
-    
-    tracker_->setTrans (Eigen::Affine3f::Identity ());
-    tracker_->setStepNoiseCovariance (default_step_covariance);
-    tracker_->setInitialNoiseCovariance (initial_noise_covariance);
-    tracker_->setInitialNoiseMean (default_initial_mean);
-    tracker_->setIterationNum (1);
-    
-    tracker_->setParticleNum (400);
+
+    tracker_->setTrans(Eigen::Affine3f::Identity());
+    tracker_->setStepNoiseCovariance(default_step_covariance);
+    tracker_->setInitialNoiseCovariance(initial_noise_covariance);
+    tracker_->setInitialNoiseMean(default_initial_mean);
+    tracker_->setIterationNum(1);
+
+    tracker_->setParticleNum(400);
     tracker_->setResampleLikelihoodThr(0.00);
-    tracker_->setUseNormal (false);
+    tracker_->setUseNormal(false);
     // setup coherences
-    ApproxNearestPairPointCloudCoherence<RefPointType>::Ptr coherence = ApproxNearestPairPointCloudCoherence<RefPointType>::Ptr
-      (new ApproxNearestPairPointCloudCoherence<RefPointType> ());
-    // NearestPairPointCloudCoherence<RefPointType>::Ptr coherence = NearestPairPointCloudCoherence<RefPointType>::Ptr
-    //   (new NearestPairPointCloudCoherence<RefPointType> ());
-    
-    DistanceCoherence<RefPointType>::Ptr distance_coherence (new DistanceCoherence<RefPointType>);
-    coherence->addPointCoherence (distance_coherence);
-    
-    HSVColorCoherence<RefPointType>::Ptr color_coherence (new HSVColorCoherence<RefPointType>);
-    color_coherence->setWeight (0.1);
-    coherence->addPointCoherence (color_coherence);
-    
-    pcl::search::Octree<RefPointType>::Ptr search (new pcl::search::Octree<RefPointType> (0.01));
-    coherence->setSearchMethod (search);
-    coherence->setMaximumDistance (0.01);
-    tracker_->setCloudCoherence (coherence);
+    ApproxNearestPairPointCloudCoherence<RefPointType>::Ptr coherence =
+        ApproxNearestPairPointCloudCoherence<RefPointType>::Ptr(
+            new ApproxNearestPairPointCloudCoherence<RefPointType>());
+
+    DistanceCoherence<RefPointType>::Ptr distance_coherence(
+        new DistanceCoherence<RefPointType>);
+    coherence->addPointCoherence(distance_coherence);
+
+    HSVColorCoherence<RefPointType>::Ptr color_coherence(
+        new HSVColorCoherence<RefPointType>);
+    color_coherence->setWeight(0.1);
+    coherence->addPointCoherence(color_coherence);
+
+    pcl::search::Octree<RefPointType>::Ptr search(
+        new pcl::search::Octree<RefPointType>(0.01));
+    coherence->setSearchMethod(search);
+    coherence->setMaximumDistance(0.01);
+    tracker_->setCloudCoherence(coherence);
   }
 
   bool
-  drawParticles (pcl::visualization::PCLVisualizer& viz)
+  drawParticles(pcl::visualization::PCLVisualizer& viz)
   {
-    ParticleFilter::PointCloudStatePtr particles = tracker_->getParticles ();
-    if (particles)
-    {
-      if (visualize_particles_)
-      {
-        pcl::PointCloud<pcl::PointXYZ>::Ptr particle_cloud (new pcl::PointCloud<pcl::PointXYZ> ());
-        for (const auto &point : particles->points)
-        {
-          particle_cloud->points.emplace_back (point.x, point.y, point.z);
+    ParticleFilter::PointCloudStatePtr particles = tracker_->getParticles();
+    if (particles) {
+      if (visualize_particles_) {
+        pcl::PointCloud<pcl::PointXYZ>::Ptr particle_cloud(
+            new pcl::PointCloud<pcl::PointXYZ>());
+        for (const auto& point : particles->points) {
+          particle_cloud->points.emplace_back(point.x, point.y, point.z);
         }
-        
+
         {
-          pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> blue_color (particle_cloud, 250, 99, 71);
-          if (!viz.updatePointCloud (particle_cloud, blue_color, "particle cloud"))
-            viz.addPointCloud (particle_cloud, blue_color, "particle cloud");
+          pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> blue_color(
+              particle_cloud, 250, 99, 71);
+          if (!viz.updatePointCloud(particle_cloud, blue_color, "particle cloud"))
+            viz.addPointCloud(particle_cloud, blue_color, "particle cloud");
         }
       }
       return true;
     }
-    PCL_WARN ("no particles\n");
+    PCL_WARN("no particles\n");
     return false;
   }
-  
+
   void
-  drawResult (pcl::visualization::PCLVisualizer& viz)
+  drawResult(pcl::visualization::PCLVisualizer& viz)
   {
-    ParticleXYZRPY result = tracker_->getResult ();
-    Eigen::Affine3f transformation = tracker_->toEigenMatrix (result);
+    ParticleXYZRPY result = tracker_->getResult();
+    Eigen::Affine3f transformation = tracker_->toEigenMatrix(result);
     // move a little bit for better visualization
-    transformation.translation () += Eigen::Vector3f (0.0f, 0.0f, -0.005f);
-    RefCloudPtr result_cloud (new RefCloud ());
+    transformation.translation() += Eigen::Vector3f(0.0f, 0.0f, -0.005f);
+    RefCloudPtr result_cloud(new RefCloud());
 
     if (!visualize_non_downsample_)
-      pcl::transformPointCloud<RefPointType> (*(tracker_->getReferenceCloud ()), *result_cloud, transformation);
+      pcl::transformPointCloud<RefPointType>(
+          *(tracker_->getReferenceCloud()), *result_cloud, transformation);
     else
-      pcl::transformPointCloud<RefPointType> (*reference_, *result_cloud, transformation);
+      pcl::transformPointCloud<RefPointType>(
+          *reference_, *result_cloud, transformation);
 
     {
-      pcl::visualization::PointCloudColorHandlerCustom<RefPointType> red_color (result_cloud, 0, 0, 255);
-      if (!viz.updatePointCloud (result_cloud, red_color, "resultcloud"))
-        viz.addPointCloud (result_cloud, red_color, "resultcloud");
+      pcl::visualization::PointCloudColorHandlerCustom<RefPointType> red_color(
+          result_cloud, 0, 0, 255);
+      if (!viz.updatePointCloud(result_cloud, red_color, "resultcloud"))
+        viz.addPointCloud(result_cloud, red_color, "resultcloud");
     }
-    
   }
-  
+
   void
-  viz_cb (pcl::visualization::PCLVisualizer& viz)
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
   {
-    std::lock_guard<std::mutex> lock (mtx_);
-    
-    if (!cloud_pass_)
-    {
+    std::lock_guard<std::mutex> lock(mtx_);
+
+    if (!cloud_pass_) {
       std::this_thread::sleep_for(1s);
       return;
     }
-    
-    if (new_cloud_ && cloud_pass_downsampled_)
-    {
+
+    if (new_cloud_ && cloud_pass_downsampled_) {
       CloudPtr cloud_pass;
       if (!visualize_non_downsample_)
         cloud_pass = cloud_pass_downsampled_;
       else
         cloud_pass = cloud_pass_;
-      
-      if (!viz.updatePointCloud (cloud_pass, "cloudpass"))
-        {
-          viz.addPointCloud (cloud_pass, "cloudpass");
-          viz.resetCameraViewpoint ("cloudpass");
-        }
+
+      if (!viz.updatePointCloud(cloud_pass, "cloudpass")) {
+        viz.addPointCloud(cloud_pass, "cloudpass");
+        viz.resetCameraViewpoint("cloudpass");
+      }
     }
 
-    if (new_cloud_ && reference_)
-    {
-      bool ret = drawParticles (viz);
-      if (ret)
-      {
-        drawResult (viz);
-        
+    if (new_cloud_ && reference_) {
+      bool ret = drawParticles(viz);
+      if (ret) {
+        drawResult(viz);
+
+        // clang-format off
         // draw some texts
-        viz.removeShape ("N");
-        viz.addText ((boost::format ("number of Reference PointClouds: %d") % tracker_->getReferenceCloud ()->points.size ()).str (),
-                     10, 20, 20, 1.0, 1.0, 1.0, "N");
-        
-        viz.removeShape ("M");
-        viz.addText ((boost::format ("number of Measured PointClouds:  %d") % cloud_pass_downsampled_->points.size ()).str (),
-                     10, 40, 20, 1.0, 1.0, 1.0, "M");
-        
-        viz.removeShape ("tracking");
-        viz.addText ((boost::format ("tracking:        %f fps") % (1.0 / tracking_time_)).str (),
-                     10, 60, 20, 1.0, 1.0, 1.0, "tracking");
-        
-        viz.removeShape ("downsampling");
-        viz.addText ((boost::format ("downsampling:    %f fps") % (1.0 / downsampling_time_)).str (),
-                     10, 80, 20, 1.0, 1.0, 1.0, "downsampling");
-        
-        viz.removeShape ("computation");
-        viz.addText ((boost::format ("computation:     %f fps") % (1.0 / computation_time_)).str (),
-                     10, 100, 20, 1.0, 1.0, 1.0, "computation");
-
-        viz.removeShape ("particles");
-        viz.addText ((boost::format ("particles:     %d") % tracker_->getParticles ()->points.size ()).str (),
-                     10, 120, 20, 1.0, 1.0, 1.0, "particles");
-        
+        viz.removeShape("N");
+        viz.addText((boost::format("number of Reference PointClouds: %d") %
+                     tracker_->getReferenceCloud()->points.size()).str(),
+                    10, 20, 20, 1.0, 1.0, 1.0, "N");
+
+        viz.removeShape("M");
+        viz.addText((boost::format("number of Measured PointClouds:  %d") %
+                     cloud_pass_downsampled_->points.size()).str(),
+                    10, 40, 20, 1.0, 1.0, 1.0, "M");
+
+        viz.removeShape("tracking");
+        viz.addText((boost::format("tracking:        %f fps") % (1.0 / tracking_time_)).str(),
+                    10, 60, 20, 1.0, 1.0, 1.0, "tracking");
+
+        viz.removeShape("downsampling");
+        viz.addText((boost::format("downsampling:    %f fps") % (1.0 / downsampling_time_)).str(),
+                    10, 80, 20, 1.0, 1.0, 1.0, "downsampling");
+
+        viz.removeShape("computation");
+        viz.addText((boost::format("computation:     %f fps") % (1.0 / computation_time_)).str(),
+                    10, 100, 20, 1.0, 1.0, 1.0, "computation");
+
+        viz.removeShape("particles");
+        viz.addText((boost::format("particles:     %d") %
+                     tracker_->getParticles()->points.size()).str(),
+                    10, 120, 20, 1.0, 1.0, 1.0, "particles");
+        // clang-format on
       }
     }
     new_cloud_ = false;
   }
 
-  void filterPassThrough (const CloudConstPtr &cloud, Cloud &result)
+  void
+  filterPassThrough(const CloudConstPtr& cloud, Cloud& result)
   {
     FPS_CALC_BEGIN;
     pcl::PassThrough<PointType> pass;
-    pass.setFilterFieldName ("z");
-    pass.setFilterLimits (0.0, 10.0);
-    //pass.setFilterLimits (0.0, 1.5);
-    //pass.setFilterLimits (0.0, 0.6);
-    pass.setKeepOrganized (false);
-    pass.setInputCloud (cloud);
-    pass.filter (result);
+    pass.setFilterFieldName("z");
+    pass.setFilterLimits(0.0, 10.0);
+    pass.setKeepOrganized(false);
+    pass.setInputCloud(cloud);
+    pass.filter(result);
     FPS_CALC_END("filterPassThrough");
   }
 
-  void euclideanSegment (const CloudConstPtr &cloud,
-                         std::vector<pcl::PointIndices> &cluster_indices)
+  void
+  euclideanSegment(const CloudConstPtr& cloud,
+                   std::vector<pcl::PointIndices>& cluster_indices)
   {
     FPS_CALC_BEGIN;
     pcl::EuclideanClusterExtraction<PointType> ec;
-    KdTreePtr tree (new KdTree ());
-    
-    ec.setClusterTolerance (0.05); // 2cm
-    ec.setMinClusterSize (50);
-    ec.setMaxClusterSize (25000);
-    //ec.setMaxClusterSize (400);
-    ec.setSearchMethod (tree);
-    ec.setInputCloud (cloud);
-    ec.extract (cluster_indices);
+    KdTreePtr tree(new KdTree());
+
+    ec.setClusterTolerance(0.05); // 2cm
+    ec.setMinClusterSize(50);
+    ec.setMaxClusterSize(25000);
+    ec.setSearchMethod(tree);
+    ec.setInputCloud(cloud);
+    ec.extract(cluster_indices);
     FPS_CALC_END("euclideanSegmentation");
   }
-  
-  void gridSample (const CloudConstPtr &cloud, Cloud &result, double leaf_size = 0.01)
+
+  void
+  gridSample(const CloudConstPtr& cloud, Cloud& result, double leaf_size = 0.01)
   {
     FPS_CALC_BEGIN;
-    double start = pcl::getTime ();
+    double start = pcl::getTime();
     pcl::VoxelGrid<PointType> grid;
-    //pcl::ApproximateVoxelGrid<PointType> grid;
-    grid.setLeafSize (float (leaf_size), float (leaf_size), float (leaf_size));
-    grid.setInputCloud (cloud);
-    grid.filter (result);
-    //result = *cloud;
-    double end = pcl::getTime ();
+    grid.setLeafSize(float(leaf_size), float(leaf_size), float(leaf_size));
+    grid.setInputCloud(cloud);
+    grid.filter(result);
+    double end = pcl::getTime();
     downsampling_time_ = end - start;
     FPS_CALC_END("gridSample");
   }
-  
-  void gridSampleApprox (const CloudConstPtr &cloud, Cloud &result, double leaf_size = 0.01)
+
+  void
+  gridSampleApprox(const CloudConstPtr& cloud, Cloud& result, double leaf_size = 0.01)
   {
     FPS_CALC_BEGIN;
-    double start = pcl::getTime ();
-    //pcl::VoxelGrid<PointType> grid;
+    double start = pcl::getTime();
     pcl::ApproximateVoxelGrid<PointType> grid;
-    grid.setLeafSize (static_cast<float> (leaf_size), static_cast<float> (leaf_size), static_cast<float> (leaf_size));
-    grid.setInputCloud (cloud);
-    grid.filter (result);
-    //result = *cloud;
-    double end = pcl::getTime ();
+    grid.setLeafSize(static_cast<float>(leaf_size),
+                     static_cast<float>(leaf_size),
+                     static_cast<float>(leaf_size));
+    grid.setInputCloud(cloud);
+    grid.filter(result);
+    double end = pcl::getTime();
     downsampling_time_ = end - start;
     FPS_CALC_END("gridSample");
   }
-  
-  void planeSegmentation (const CloudConstPtr &cloud,
-                          pcl::ModelCoefficients &coefficients,
-                          pcl::PointIndices &inliers)
+
+  void
+  planeSegmentation(const CloudConstPtr& cloud,
+                    pcl::ModelCoefficients& coefficients,
+                    pcl::PointIndices& inliers)
   {
     FPS_CALC_BEGIN;
     pcl::SACSegmentation<PointType> seg;
-    seg.setOptimizeCoefficients (true);
-    seg.setModelType (pcl::SACMODEL_PLANE);
-    seg.setMethodType (pcl::SAC_RANSAC);
-    seg.setMaxIterations (1000);
-    seg.setDistanceThreshold (0.03);
-    seg.setInputCloud (cloud);
-    seg.segment (inliers, coefficients);
+    seg.setOptimizeCoefficients(true);
+    seg.setModelType(pcl::SACMODEL_PLANE);
+    seg.setMethodType(pcl::SAC_RANSAC);
+    seg.setMaxIterations(1000);
+    seg.setDistanceThreshold(0.03);
+    seg.setInputCloud(cloud);
+    seg.segment(inliers, coefficients);
     FPS_CALC_END("planeSegmentation");
   }
 
-  void planeProjection (const CloudConstPtr &cloud,
-                        Cloud &result,
-                        const pcl::ModelCoefficients::ConstPtr &coefficients)
+  void
+  planeProjection(const CloudConstPtr& cloud,
+                  Cloud& result,
+                  const pcl::ModelCoefficients::ConstPtr& coefficients)
   {
     FPS_CALC_BEGIN;
     pcl::ProjectInliers<PointType> proj;
-    proj.setModelType (pcl::SACMODEL_PLANE);
-    proj.setInputCloud (cloud);
-    proj.setModelCoefficients (coefficients);
-    proj.filter (result);
+    proj.setModelType(pcl::SACMODEL_PLANE);
+    proj.setInputCloud(cloud);
+    proj.setModelCoefficients(coefficients);
+    proj.filter(result);
     FPS_CALC_END("planeProjection");
   }
 
-  void convexHull (const CloudConstPtr &cloud,
-                   Cloud &,
-                   std::vector<pcl::Vertices> &hull_vertices)
+  void
+  convexHull(const CloudConstPtr& cloud,
+             Cloud&,
+             std::vector<pcl::Vertices>& hull_vertices)
   {
     FPS_CALC_BEGIN;
     pcl::ConvexHull<PointType> chull;
-    chull.setInputCloud (cloud);
-    chull.reconstruct (*cloud_hull_, hull_vertices);
+    chull.setInputCloud(cloud);
+    chull.reconstruct(*cloud_hull_, hull_vertices);
     FPS_CALC_END("convexHull");
   }
 
-  void normalEstimation (const CloudConstPtr &cloud,
-                         pcl::PointCloud<pcl::Normal> &result)
+  void
+  normalEstimation(const CloudConstPtr& cloud, pcl::PointCloud<pcl::Normal>& result)
   {
     FPS_CALC_BEGIN;
-    ne_.setInputCloud (cloud);
-    ne_.compute (result);
+    ne_.setInputCloud(cloud);
+    ne_.compute(result);
     FPS_CALC_END("normalEstimation");
   }
-  
-  void tracking (const RefCloudConstPtr &cloud)
+
+  void
+  tracking(const RefCloudConstPtr& cloud)
   {
-    double start = pcl::getTime ();
+    double start = pcl::getTime();
     FPS_CALC_BEGIN;
-    tracker_->setInputCloud (cloud);
-    tracker_->compute ();
-    double end = pcl::getTime ();
+    tracker_->setInputCloud(cloud);
+    tracker_->compute();
+    double end = pcl::getTime();
     FPS_CALC_END("tracking");
     tracking_time_ = end - start;
   }
 
-  void addNormalToCloud (const CloudConstPtr &cloud,
-                         const pcl::PointCloud<pcl::Normal>::ConstPtr &,
-                         RefCloud &result)
+  void
+  addNormalToCloud(const CloudConstPtr& cloud,
+                   const pcl::PointCloud<pcl::Normal>::ConstPtr&,
+                   RefCloud& result)
   {
     result.width = cloud->width;
     result.height = cloud->height;
     result.is_dense = cloud->is_dense;
-    for (std::size_t i = 0; i < cloud->points.size (); i++)
-    {
+    for (std::size_t i = 0; i < cloud->points.size(); i++) {
       RefPointType point;
       point.x = cloud->points[i].x;
       point.y = cloud->points[i].y;
       point.z = cloud->points[i].z;
       point.rgba = cloud->points[i].rgba;
-      // point.normal[0] = normals->points[i].normal[0];
-      // point.normal[1] = normals->points[i].normal[1];
-      // point.normal[2] = normals->points[i].normal[2];
-      result.points.push_back (point);
+      result.points.push_back(point);
     }
   }
 
-  void extractNonPlanePoints (const CloudConstPtr &cloud,
-                              const CloudConstPtr &cloud_hull,
-                              Cloud &result)
+  void
+  extractNonPlanePoints(const CloudConstPtr& cloud,
+                        const CloudConstPtr& cloud_hull,
+                        Cloud& result)
   {
     pcl::ExtractPolygonalPrismData<PointType> polygon_extract;
-    pcl::PointIndices::Ptr inliers_polygon (new pcl::PointIndices ());
-    polygon_extract.setHeightLimits (0.01, 10.0);
-    polygon_extract.setInputPlanarHull (cloud_hull);
-    polygon_extract.setInputCloud (cloud);
-    polygon_extract.segment (*inliers_polygon);
+    pcl::PointIndices::Ptr inliers_polygon(new pcl::PointIndices());
+    polygon_extract.setHeightLimits(0.01, 10.0);
+    polygon_extract.setInputPlanarHull(cloud_hull);
+    polygon_extract.setInputCloud(cloud);
+    polygon_extract.segment(*inliers_polygon);
     {
       pcl::ExtractIndices<PointType> extract_positive;
-      extract_positive.setNegative (false);
-      extract_positive.setInputCloud (cloud);
-      extract_positive.setIndices (inliers_polygon);
-      extract_positive.filter (result);
+      extract_positive.setNegative(false);
+      extract_positive.setInputCloud(cloud);
+      extract_positive.setIndices(inliers_polygon);
+      extract_positive.filter(result);
     }
   }
 
-  void removeZeroPoints (const CloudConstPtr &cloud,
-                         Cloud &result)
+  void
+  removeZeroPoints(const CloudConstPtr& cloud, Cloud& result)
   {
-    for (std::size_t i = 0; i < cloud->points.size (); i++)
-    {
+    for (std::size_t i = 0; i < cloud->points.size(); i++) {
       PointType point = cloud->points[i];
-      if (!(std::abs(point.x) < 0.01 &&
-            std::abs(point.y) < 0.01 &&
+      if (!(std::abs(point.x) < 0.01 && std::abs(point.y) < 0.01 &&
             std::abs(point.z) < 0.01) &&
-          !std::isnan(point.x) &&
-          !std::isnan(point.y) &&
-          !std::isnan(point.z))
+          !std::isnan(point.x) && !std::isnan(point.y) && !std::isnan(point.z))
         result.points.push_back(point);
     }
 
-    result.width = static_cast<std::uint32_t> (result.points.size ());
+    result.width = static_cast<std::uint32_t>(result.points.size());
     result.height = 1;
     result.is_dense = true;
   }
-  
-  void extractSegmentCluster (const CloudConstPtr &cloud,
-                              const std::vector<pcl::PointIndices> &cluster_indices,
-                              const int segment_index,
-                              Cloud &result)
+
+  void
+  extractSegmentCluster(const CloudConstPtr& cloud,
+                        const std::vector<pcl::PointIndices>& cluster_indices,
+                        const int segment_index,
+                        Cloud& result)
   {
     pcl::PointIndices segmented_indices = cluster_indices[segment_index];
-    for (const int &index : segmented_indices.indices)
-    {
+    for (const int& index : segmented_indices.indices) {
       PointType point = cloud->points[index];
-      result.points.push_back (point);
+      result.points.push_back(point);
     }
-    result.width = std::uint32_t (result.points.size ());
+    result.width = std::uint32_t(result.points.size());
     result.height = 1;
     result.is_dense = true;
   }
-  
+
   void
-  cloud_cb (const CloudConstPtr &cloud)
+  cloud_cb(const CloudConstPtr& cloud)
   {
-    std::lock_guard<std::mutex> lock (mtx_);
-    double start = pcl::getTime ();
+    std::lock_guard<std::mutex> lock(mtx_);
+    double start = pcl::getTime();
     FPS_CALC_BEGIN;
-    cloud_pass_.reset (new Cloud);
-    cloud_pass_downsampled_.reset (new Cloud);
-    pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
-    pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
-    filterPassThrough (cloud, *cloud_pass_);
-    if (counter_ < 10)
-    {
-      gridSample (cloud_pass_, *cloud_pass_downsampled_, downsampling_grid_size_);
+    cloud_pass_.reset(new Cloud);
+    cloud_pass_downsampled_.reset(new Cloud);
+    pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
+    pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
+    filterPassThrough(cloud, *cloud_pass_);
+    if (counter_ < 10) {
+      gridSample(cloud_pass_, *cloud_pass_downsampled_, downsampling_grid_size_);
     }
-    else if (counter_ == 10)
-    {
-      //gridSample (cloud_pass_, *cloud_pass_downsampled_, 0.01);
+    else if (counter_ == 10) {
       cloud_pass_downsampled_ = cloud_pass_;
       CloudPtr target_cloud;
-      if (use_convex_hull_)
-      {
-        planeSegmentation (cloud_pass_downsampled_, *coefficients, *inliers);
-        if (inliers->indices.size () > 3)
-        {
-          CloudPtr cloud_projected (new Cloud);
-          cloud_hull_.reset (new Cloud);
-          nonplane_cloud_.reset (new Cloud);
-          
-          planeProjection (cloud_pass_downsampled_, *cloud_projected, coefficients);
-          convexHull (cloud_projected, *cloud_hull_, hull_vertices_);
-          
-          extractNonPlanePoints (cloud_pass_downsampled_, cloud_hull_, *nonplane_cloud_);
+      if (use_convex_hull_) {
+        planeSegmentation(cloud_pass_downsampled_, *coefficients, *inliers);
+        if (inliers->indices.size() > 3) {
+          CloudPtr cloud_projected(new Cloud);
+          cloud_hull_.reset(new Cloud);
+          nonplane_cloud_.reset(new Cloud);
+
+          planeProjection(cloud_pass_downsampled_, *cloud_projected, coefficients);
+          convexHull(cloud_projected, *cloud_hull_, hull_vertices_);
+
+          extractNonPlanePoints(cloud_pass_downsampled_, cloud_hull_, *nonplane_cloud_);
           target_cloud = nonplane_cloud_;
         }
-        else
-        {
-          PCL_WARN ("cannot segment plane\n");
+        else {
+          PCL_WARN("cannot segment plane\n");
         }
       }
-      else
-      {
-        PCL_WARN ("without plane segmentation\n");
+      else {
+        PCL_WARN("without plane segmentation\n");
         target_cloud = cloud_pass_downsampled_;
       }
-      
-      if (target_cloud != nullptr)
-      {
-        PCL_INFO ("segmentation, please wait...\n");
+
+      if (target_cloud != nullptr) {
+        PCL_INFO("segmentation, please wait...\n");
         std::vector<pcl::PointIndices> cluster_indices;
-        euclideanSegment (target_cloud, cluster_indices);
-        if (!cluster_indices.empty ())
-        {
+        euclideanSegment(target_cloud, cluster_indices);
+        if (!cluster_indices.empty()) {
           // select the cluster to track
-          CloudPtr temp_cloud (new Cloud);
-          extractSegmentCluster (target_cloud, cluster_indices, 0, *temp_cloud);
+          CloudPtr temp_cloud(new Cloud);
+          extractSegmentCluster(target_cloud, cluster_indices, 0, *temp_cloud);
           Eigen::Vector4f c;
-          pcl::compute3DCentroid<RefPointType> (*temp_cloud, c);
+          pcl::compute3DCentroid<RefPointType>(*temp_cloud, c);
           int segment_index = 0;
           double segment_distance = c[0] * c[0] + c[1] * c[1];
-          for (std::size_t i = 1; i < cluster_indices.size (); i++)
-          {
-            temp_cloud.reset (new Cloud);
-            extractSegmentCluster (target_cloud, cluster_indices, int (i), *temp_cloud);
-            pcl::compute3DCentroid<RefPointType> (*temp_cloud, c);
+          for (std::size_t i = 1; i < cluster_indices.size(); i++) {
+            temp_cloud.reset(new Cloud);
+            extractSegmentCluster(target_cloud, cluster_indices, int(i), *temp_cloud);
+            pcl::compute3DCentroid<RefPointType>(*temp_cloud, c);
             double distance = c[0] * c[0] + c[1] * c[1];
-            if (distance < segment_distance)
-            {
-              segment_index = int (i);
+            if (distance < segment_distance) {
+              segment_index = int(i);
               segment_distance = distance;
             }
           }
-          
-          segmented_cloud_.reset (new Cloud);
-          extractSegmentCluster (target_cloud, cluster_indices, segment_index, *segmented_cloud_);
-          //pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
-          //normalEstimation (segmented_cloud_, *normals);
-          RefCloudPtr ref_cloud (new RefCloud);
-          //addNormalToCloud (segmented_cloud_, normals, *ref_cloud);
+
+          segmented_cloud_.reset(new Cloud);
+          extractSegmentCluster(
+              target_cloud, cluster_indices, segment_index, *segmented_cloud_);
+          RefCloudPtr ref_cloud(new RefCloud);
           ref_cloud = segmented_cloud_;
-          RefCloudPtr nonzero_ref (new RefCloud);
-          removeZeroPoints (ref_cloud, *nonzero_ref);
-          
-          PCL_INFO ("calculating cog\n");
-          
-          RefCloudPtr transed_ref (new RefCloud);
-          pcl::compute3DCentroid<RefPointType> (*nonzero_ref, c);
-          Eigen::Affine3f trans = Eigen::Affine3f::Identity ();
-          trans.translation ().matrix () = Eigen::Vector3f (c[0], c[1], c[2]);
-          //pcl::transformPointCloudWithNormals<RefPointType> (*ref_cloud, *transed_ref, trans.inverse());
-          pcl::transformPointCloud<RefPointType> (*nonzero_ref, *transed_ref, trans.inverse());
-          CloudPtr transed_ref_downsampled (new Cloud);
-          gridSample (transed_ref, *transed_ref_downsampled, downsampling_grid_size_);
-          tracker_->setReferenceCloud (transed_ref_downsampled);
-          tracker_->setTrans (trans);
+          RefCloudPtr nonzero_ref(new RefCloud);
+          removeZeroPoints(ref_cloud, *nonzero_ref);
+
+          PCL_INFO("calculating cog\n");
+
+          RefCloudPtr transed_ref(new RefCloud);
+          pcl::compute3DCentroid<RefPointType>(*nonzero_ref, c);
+          Eigen::Affine3f trans = Eigen::Affine3f::Identity();
+          trans.translation().matrix() = Eigen::Vector3f(c[0], c[1], c[2]);
+          pcl::transformPointCloud<RefPointType>(
+              *nonzero_ref, *transed_ref, trans.inverse());
+          CloudPtr transed_ref_downsampled(new Cloud);
+          gridSample(transed_ref, *transed_ref_downsampled, downsampling_grid_size_);
+          tracker_->setReferenceCloud(transed_ref_downsampled);
+          tracker_->setTrans(trans);
           reference_ = transed_ref;
-          tracker_->setMinIndices (int (ref_cloud->points.size ()) / 2);
+          tracker_->setMinIndices(int(ref_cloud->points.size()) / 2);
         }
-        else
-        {
-          PCL_WARN ("euclidean segmentation failed\n");
+        else {
+          PCL_WARN("euclidean segmentation failed\n");
         }
       }
     }
-    else
-    {
-      //normals_.reset (new pcl::PointCloud<pcl::Normal>);
-      //normalEstimation (cloud_pass_downsampled_, *normals_);
-      //RefCloudPtr tracking_cloud (new RefCloud ());
-      //addNormalToCloud (cloud_pass_downsampled_, normals_, *tracking_cloud);
-      //tracking_cloud = cloud_pass_downsampled_;
-      
-      //*cloud_pass_downsampled_ = *cloud_pass_;
-      //cloud_pass_downsampled_ = cloud_pass_;
-      gridSampleApprox (cloud_pass_, *cloud_pass_downsampled_, downsampling_grid_size_);
-      tracking (cloud_pass_downsampled_);
+    else {
+      gridSampleApprox(cloud_pass_, *cloud_pass_downsampled_, downsampling_grid_size_);
+      tracking(cloud_pass_downsampled_);
     }
-    
+
     new_cloud_ = true;
-    double end = pcl::getTime ();
+    double end = pcl::getTime();
     computation_time_ = end - start;
     FPS_CALC_END("computation");
     counter_++;
   }
-      
+
   void
-  run ()
+  run()
   {
-    pcl::OpenNIGrabber interface {device_id_};
-    std::function<void (const CloudConstPtr&)> f =
-      [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
-    interface.registerCallback (f);
-
-    viewer_.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
-    
-    interface.start ();
-      
-    while (!viewer_.wasStopped ())
+    pcl::OpenNIGrabber interface{device_id_};
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb(cloud);
+    };
+    interface.registerCallback(f);
+
+    viewer_.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
+
+    interface.start();
+
+    while (!viewer_.wasStopped())
       std::this_thread::sleep_for(1s);
-    interface.stop ();
+    interface.stop();
   }
-  
+
   pcl::visualization::CloudViewer viewer_;
   pcl::PointCloud<pcl::Normal>::Ptr normals_;
   CloudPtr cloud_pass_;
@@ -658,7 +632,7 @@ public:
   CloudPtr segmented_cloud_;
   CloudPtr reference_;
   std::vector<pcl::Vertices> hull_vertices_;
-  
+
   std::string device_id_;
   std::mutex mtx_;
   bool new_cloud_;
@@ -672,26 +646,23 @@ public:
   double computation_time_;
   double downsampling_time_;
   double downsampling_grid_size_;
-  };
+};
 
 void
-usage (char** argv)
+usage(char** argv)
 {
+  // clang-format off
   std::cout << "usage: " << argv[0] << " <device_id> [-C] [-g]\n\n";
-  std::cout << "  -C:  initialize the pointcloud to track without plane segmentation"
-            << std::endl;
-  std::cout << "  -D: visualizing with non-downsampled pointclouds."
-            << std::endl;
-  std::cout << "  -P: not visualizing particle cloud."
-            << std::endl;
-  std::cout << "  -fixed: use the fixed number of the particles."
-            << std::endl;
-  std::cout << "  -d <value>: specify the grid size of downsampling (defaults to 0.01)."
-            << std::endl;
+  std::cout << "  -C:  initialize the pointcloud to track without plane segmentation\n";
+  std::cout << "  -D: visualizing with non-downsampled pointclouds.\n";
+  std::cout << "  -P: not visualizing particle cloud.\n";
+  std::cout << "  -fixed: use the fixed number of the particles.\n";
+  std::cout << "  -d <value>: specify the grid size of downsampling (defaults to 0.01)." << std::endl;
+  // clang-format on
 }
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
   bool use_convex_hull = true;
   bool visualize_non_downsample = false;
@@ -699,34 +670,35 @@ main (int argc, char** argv)
   bool use_fixed = false;
 
   double downsampling_grid_size = 0.01;
-  
-  if (pcl::console::find_argument (argc, argv, "-C") > 0)
+
+  if (pcl::console::find_argument(argc, argv, "-C") > 0)
     use_convex_hull = false;
-  if (pcl::console::find_argument (argc, argv, "-D") > 0)
+  if (pcl::console::find_argument(argc, argv, "-D") > 0)
     visualize_non_downsample = true;
-  if (pcl::console::find_argument (argc, argv, "-P") > 0)
+  if (pcl::console::find_argument(argc, argv, "-P") > 0)
     visualize_particles = false;
-  if (pcl::console::find_argument (argc, argv, "-fixed") > 0)
+  if (pcl::console::find_argument(argc, argv, "-fixed") > 0)
     use_fixed = true;
-  pcl::console::parse_argument (argc, argv, "-d", downsampling_grid_size);
-  if (argc < 2)
-  {
-    usage (argv);
-    exit (1);
+  pcl::console::parse_argument(argc, argv, "-d", downsampling_grid_size);
+  if (argc < 2) {
+    usage(argv);
+    exit(1);
   }
-  
-  std::string device_id = std::string (argv[1]);
 
-  if (device_id == "--help" || device_id == "-h")
-  {
-    usage (argv);
-    exit (1);
+  std::string device_id = std::string(argv[1]);
+
+  if (device_id == "--help" || device_id == "-h") {
+    usage(argv);
+    exit(1);
   }
-  
+
   // open kinect
-  OpenNISegmentTracking<pcl::PointXYZRGBA> v (device_id, 8, downsampling_grid_size,
-                                              use_convex_hull,
-                                              visualize_non_downsample, visualize_particles,
-                                              use_fixed);
-  v.run ();
+  OpenNISegmentTracking<pcl::PointXYZRGBA> v(device_id,
+                                             8,
+                                             downsampling_grid_size,
+                                             use_convex_hull,
+                                             visualize_non_downsample,
+                                             visualize_particles,
+                                             use_fixed);
+  v.run();
 }
index 8250b88fb9e08d3518566cdc92ddbae2f871dc92..52a56fbc368b6425c98257eebdcc9cab9698edde 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
+#include <pcl/filters/uniform_sampling.h>
+#include <pcl/io/openni_camera/openni_driver.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
-#include <pcl/filters/uniform_sampling.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 #include <thread>
 
 using namespace std::chrono_literals;
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
-
-
-class OpenNIUniformSampling
-{
-  public:
-    using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
-    using CloudPtr = Cloud::Ptr;
-    using CloudConstPtr = Cloud::ConstPtr;
-
-    OpenNIUniformSampling (const std::string& device_id = "", 
-                       float leaf_size = 0.05)
-    : viewer ("PCL OpenNI PassThrough Viewer")
-    , device_id_(device_id)
-    {
-      pass_.setRadiusSearch (leaf_size);
-    }
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
+
+class OpenNIUniformSampling {
+public:
+  using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
+  using CloudPtr = Cloud::Ptr;
+  using CloudConstPtr = Cloud::ConstPtr;
+
+  OpenNIUniformSampling(const std::string& device_id = "", float leaf_size = 0.05)
+  : viewer("PCL OpenNI PassThrough Viewer"), device_id_(device_id)
+  {
+    pass_.setRadiusSearch(leaf_size);
+  }
 
-    void 
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      FPS_CALC ("computation");
-
-      cloud_.reset (new Cloud);
-      keypoints_.reset (new pcl::PointCloud<pcl::PointXYZ>);
-      // Computation goes here
-      pass_.setInputCloud (cloud);
-      pcl::PointCloud<pcl::PointXYZRGBA> sampled;
-      pass_.filter (sampled);
-      *cloud_  = *cloud;
-
-      pcl::copyPointCloud (sampled, *keypoints_);
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    FPS_CALC("computation");
+
+    cloud_.reset(new Cloud);
+    keypoints_.reset(new pcl::PointCloud<pcl::PointXYZ>);
+    // Computation goes here
+    pass_.setInputCloud(cloud);
+    pcl::PointCloud<pcl::PointXYZRGBA> sampled;
+    pass_.filter(sampled);
+    *cloud_ = *cloud;
+
+    pcl::copyPointCloud(sampled, *keypoints_);
+  }
+
+  void
+  viz_cb(pcl::visualization::PCLVisualizer& viz)
+  {
+    std::lock_guard<std::mutex> lock(mtx_);
+    if (!keypoints_ && !cloud_) {
+      std::this_thread::sleep_for(1s);
+      return;
     }
 
-    void
-    viz_cb (pcl::visualization::PCLVisualizer& viz)
-    {
-      std::lock_guard<std::mutex> lock (mtx_);
-      if (!keypoints_ && !cloud_)
-      {
-        std::this_thread::sleep_for(1s);
-        return;
-      }
-
-      FPS_CALC ("visualization");
-      viz.removePointCloud ("raw");
-      pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA> color_handler (cloud_);
-      viz.addPointCloud<pcl::PointXYZRGBA> (cloud_, color_handler, "raw");
-
-      if (!viz.updatePointCloud<pcl::PointXYZ> (keypoints_, "keypoints"))
-      {
-        viz.addPointCloud<pcl::PointXYZ> (keypoints_, "keypoints");
-        viz.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5.0, "keypoints");
-        viz.resetCameraViewpoint ("keypoints");
-      }
+    FPS_CALC("visualization");
+    viz.removePointCloud("raw");
+    pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA> color_handler(
+        cloud_);
+    viz.addPointCloud<pcl::PointXYZRGBA>(cloud_, color_handler, "raw");
+
+    if (!viz.updatePointCloud<pcl::PointXYZ>(keypoints_, "keypoints")) {
+      viz.addPointCloud<pcl::PointXYZ>(keypoints_, "keypoints");
+      viz.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5.0, "keypoints");
+      viz.resetCameraViewpoint("keypoints");
     }
+  }
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
 
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
-      viewer.runOnVisualizationThread ([this] (pcl::visualization::PCLVisualizer& viz) { viz_cb (viz); }, "viz_cb");
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
+    viewer.runOnVisualizationThread(
+        [this](pcl::visualization::PCLVisualizer& viz) { viz_cb(viz); }, "viz_cb");
 
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        std::this_thread::sleep_for(1s);
-      }
+    interface.start();
 
-      interface.stop ();
+    while (!viewer.wasStopped()) {
+      std::this_thread::sleep_for(1s);
     }
 
-    pcl::UniformSampling<pcl::PointXYZRGBA> pass_;
-    pcl::visualization::CloudViewer viewer;
-    std::string device_id_;
-    std::mutex mtx_;
-    CloudPtr cloud_;
-    pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints_;
+    interface.stop();
+  }
+
+  pcl::UniformSampling<pcl::PointXYZRGBA> pass_;
+  pcl::visualization::CloudViewer viewer;
+  std::string device_id_;
+  std::mutex mtx_;
+  CloudPtr cloud_;
+  pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n"
             << "where options are:\n"
-            << "                             -leaf X  :: set the UniformSampling leaf size (default: 0.01)\n";
+            << "                             -leaf X  :: set the UniformSampling leaf "
+               "size (default: 0.01)\n";
 
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
     std::cout << "No devices connected." << std::endl;
 }
 
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
-  if (argc < 2)
-  {
-    usage (argv);
+  if (argc < 2) {
+    usage(argv);
     return 1;
   }
 
-  std::string arg (argv[1]);
-  
-  if (arg == "--help" || arg == "-h")
-  {
-    usage (argv);
+  std::string arg(argv[1]);
+
+  if (arg == "--help" || arg == "-h") {
+    usage(argv);
     return 1;
   }
 
   float leaf_res = 0.05f;
-  pcl::console::parse_argument (argc, argv, "-leaf", leaf_res);
-  PCL_INFO ("Using %f as a leaf size for UniformSampling.\n", leaf_res);
+  pcl::console::parse_argument(argc, argv, "-leaf", leaf_res);
+  PCL_INFO("Using %f as a leaf size for UniformSampling.\n", leaf_res);
 
-  pcl::OpenNIGrabber grabber (arg);
-  OpenNIUniformSampling v (arg, leaf_res);
-  v.run ();
+  pcl::OpenNIGrabber grabber(arg);
+  OpenNIUniformSampling v(arg, leaf_res);
+  v.run();
 
-  return (0);
+  return 0;
 }
index 089b7aeea2de6f8823596af5530357820c710e50..e1c3f947976e200e127e2f0cbb3cadb1317deedc 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *     
+ *
  */
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/common/time.h>
+#include <pcl/console/parse.h>
 #include <pcl/filters/approximate_voxel_grid.h>
 #include <pcl/filters/voxel_grid.h>
-#include <pcl/console/parse.h>
-#include <pcl/common/time.h>
+#include <pcl/io/openni_camera/openni_driver.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 
 #include <mutex>
 
+// clang-format off
+#define FPS_CALC(_WHAT_)                                                               \
+  do {                                                                                 \
+    static unsigned count = 0;                                                         \
+    static double last = pcl::getTime();                                               \
+    double now = pcl::getTime();                                                       \
+    ++count;                                                                           \
+    if (now - last >= 1.0) {                                                           \
+      std::cout << "Average framerate(" << _WHAT_ << "): "                             \
+                << double(count) / double(now - last) << " Hz" << std::endl;           \
+      count = 0;                                                                       \
+      last = now;                                                                      \
+    }                                                                                  \
+  } while (false)
+// clang-format on
 
-#define FPS_CALC(_WHAT_) \
-do \
-{ \
-    static unsigned count = 0;\
-    static double last = pcl::getTime ();\
-    double now = pcl::getTime (); \
-    ++count; \
-    if (now - last >= 1.0) \
-    { \
-      std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
-      count = 0; \
-      last = now; \
-    } \
-}while(false)
+template <typename PointType>
+class OpenNIVoxelGrid {
+public:
+  using Cloud = pcl::PointCloud<PointType>;
+  using CloudPtr = typename Cloud::Ptr;
+  using CloudConstPtr = typename Cloud::ConstPtr;
+
+  OpenNIVoxelGrid(const std::string& device_id = "",
+                  const std::string& = "z",
+                  float = 0,
+                  float = 5.0,
+                  float leaf_size_x = 0.01,
+                  float leaf_size_y = 0.01,
+                  float leaf_size_z = 0.01)
+  : viewer("PCL OpenNI VoxelGrid Viewer"), device_id_(device_id)
+  {
+    grid_.setLeafSize(leaf_size_x, leaf_size_y, leaf_size_z);
+    // grid_.setFilterFieldName (field_name);
+    // grid_.setFilterLimits (min_v, max_v);
+  }
 
+  void
+  cloud_cb_(const CloudConstPtr& cloud)
+  {
+    set(cloud);
+  }
 
-template <typename PointType>
-class OpenNIVoxelGrid
-{
-  public:
-    using Cloud = pcl::PointCloud<PointType>;
-    using CloudPtr = typename Cloud::Ptr;
-    using CloudConstPtr = typename Cloud::ConstPtr;
-
-    OpenNIVoxelGrid (const std::string& device_id = "", 
-                     const std::string& = "z", float = 0, float = 5.0,
-                     float leaf_size_x = 0.01, float leaf_size_y = 0.01, float leaf_size_z = 0.01)
-    : viewer ("PCL OpenNI VoxelGrid Viewer")
-    , device_id_(device_id)
-    {
-      grid_.setLeafSize (leaf_size_x, leaf_size_y, leaf_size_z);
-      //grid_.setFilterFieldName (field_name);
-      //grid_.setFilterLimits (min_v, max_v);
-    }
-    
-    void 
-    cloud_cb_ (const CloudConstPtr& cloud)
-    {
-      set (cloud);
-    }
+  void
+  set(const CloudConstPtr& cloud)
+  {
+    // lock while we set our cloud;
+    std::lock_guard<std::mutex> lock(mtx_);
+    cloud_ = cloud;
+  }
 
-    void
-    set (const CloudConstPtr& cloud)
-    {
-      //lock while we set our cloud;
-      std::lock_guard<std::mutex> lock (mtx_);
-      cloud_  = cloud;
-    }
+  CloudPtr
+  get()
+  {
+    // lock while we swap our cloud and reset it.
+    std::lock_guard<std::mutex> lock(mtx_);
+    CloudPtr temp_cloud(new Cloud);
 
-    CloudPtr
-    get ()
-    {
-      //lock while we swap our cloud and reset it.
-      std::lock_guard<std::mutex> lock (mtx_);
-      CloudPtr temp_cloud (new Cloud);
-     
-      grid_.setInputCloud (cloud_);
-      grid_.filter (*temp_cloud);
-
-      return (temp_cloud);
-    }
+    grid_.setInputCloud(cloud_);
+    grid_.filter(*temp_cloud);
 
-    void
-    run ()
-    {
-      pcl::OpenNIGrabber interface {device_id_};
-
-      std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb_ (cloud); };
-      boost::signals2::connection c = interface.registerCallback (f);
-      
-      interface.start ();
-      
-      while (!viewer.wasStopped ())
-      {
-        if (cloud_)
-        {
-          FPS_CALC ("drawing");
-          //the call to get() sets the cloud_ to null;
-          viewer.showCloud (get ());
-        }
-      }
+    return temp_cloud;
+  }
+
+  void
+  run()
+  {
+    pcl::OpenNIGrabber interface{device_id_};
+
+    std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+      cloud_cb_(cloud);
+    };
+    boost::signals2::connection c = interface.registerCallback(f);
 
-      interface.stop ();
+    interface.start();
+
+    while (!viewer.wasStopped()) {
+      if (cloud_) {
+        FPS_CALC("drawing");
+        // the call to get() sets the cloud_ to null;
+        viewer.showCloud(get());
+      }
     }
 
-    pcl::VoxelGrid<PointType> grid_;
-    pcl::visualization::CloudViewer viewer;
-    std::string device_id_;
-    std::mutex mtx_;
-    CloudConstPtr cloud_;
+    interface.stop();
+  }
+
+  pcl::VoxelGrid<PointType> grid_;
+  pcl::visualization::CloudViewer viewer;
+  std::string device_id_;
+  std::mutex mtx_;
+  CloudConstPtr cloud_;
 };
 
 void
-usage (char ** argv)
+usage(char** argv)
 {
   std::cout << "usage: " << argv[0] << " <device_id> <options>\n\n"
-            << "where options are:\n         -minmax min-max  :: set the ApproximateVoxelGrid min-max cutting values (default: 0-5.0)\n"
-            <<                     "         -field  X        :: use field/dimension 'X' to filter data on (default: 'z')\n"
-
-            << "                             -leaf x, y, z    :: set the ApproximateVoxelGrid leaf size (default: 0.01)\n";
-
-  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  if (driver.getNumberDevices () > 0)
-  {
-    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
-    {
+            << "where options are:\n         -minmax min-max  :: set the "
+               "ApproximateVoxelGrid min-max cutting values (default: 0-5.0)\n"
+            << "         -field  X        :: use field/dimension 'X' to filter data on "
+               "(default: 'z')\n"
+
+            << "                             -leaf x, y, z    :: set the "
+               "ApproximateVoxelGrid leaf size (default: 0.01)\n";
+
+  openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance();
+  if (driver.getNumberDevices() > 0) {
+    for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) {
+      // clang-format off
       std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
               << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl;
       std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl
            << "                 bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl
            << "                 <serial-number> (only in Linux and for devices which provide serial numbers)"  << std::endl;
+      // clang-format on
     }
   }
   else
     std::cout << "No devices connected." << std::endl;
 }
 
-int 
-main (int argc, char ** argv)
+int
+main(int argc, char** argv)
 {
-  if (pcl::console::find_argument (argc, argv, "-h") != -1)
-    usage (argv);
+  if (pcl::console::find_argument(argc, argv, "-h") != -1)
+    usage(argv);
 
   float min_v = 0.0f, max_v = 5.0f;
-  pcl::console::parse_2x_arguments (argc, argv, "-minmax", min_v, max_v);
-  std::string field_name ("z");
-  pcl::console::parse_argument (argc, argv, "-field", field_name);
-  PCL_INFO ("Filtering data on %s between %f -> %f.\n", field_name.c_str (), min_v, max_v);
+  pcl::console::parse_2x_arguments(argc, argv, "-minmax", min_v, max_v);
+  std::string field_name("z");
+  pcl::console::parse_argument(argc, argv, "-field", field_name);
+  PCL_INFO(
+      "Filtering data on %s between %f -> %f.\n", field_name.c_str(), min_v, max_v);
   float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f;
-  pcl::console::parse_3x_arguments (argc, argv, "-leaf", leaf_x, leaf_y, leaf_z);
-  PCL_INFO ("Using %f, %f, %f as a leaf size for VoxelGrid.\n", leaf_x, leaf_y, leaf_z);
-
-  pcl::OpenNIGrabber grabber ("");
-  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba> ())
-  {
-    OpenNIVoxelGrid<pcl::PointXYZRGBA> v ("", field_name, min_v, max_v, leaf_x, leaf_y, leaf_z);
-    v.run ();
+  pcl::console::parse_3x_arguments(argc, argv, "-leaf", leaf_x, leaf_y, leaf_z);
+  PCL_INFO("Using %f, %f, %f as a leaf size for VoxelGrid.\n", leaf_x, leaf_y, leaf_z);
+
+  pcl::OpenNIGrabber grabber("");
+  if (grabber.providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgba>()) {
+    OpenNIVoxelGrid<pcl::PointXYZRGBA> v(
+        "", field_name, min_v, max_v, leaf_x, leaf_y, leaf_z);
+    v.run();
   }
-  else
-  {
-    OpenNIVoxelGrid<pcl::PointXYZ> v ("", field_name, min_v, max_v, leaf_x, leaf_y, leaf_z);
-    v.run ();
+  else {
+    OpenNIVoxelGrid<pcl::PointXYZ> v(
+        "", field_name, min_v, max_v, leaf_x, leaf_y, leaf_z);
+    v.run();
   }
 
-  return (0);
+  return 0;
 }
index 3d62f52187357b027a1db32f5a40a0256088737f..8dccb9b137221ae221d6e79f22dd9c5bfc747ff9 100644 (file)
-#include <pcl/common/angles.h>
 #include <pcl/apps/organized_segmentation_demo.h>
-//QT4
+#include <pcl/common/angles.h>
+#include <pcl/segmentation/extract_polygonal_prism_data.h>
+#include <pcl/surface/convex_hull.h>
+#include <pcl/memory.h> // for pcl::dynamic_pointer_cast
+
+#include <boost/signals2/connection.hpp> // for boost::signals2::connection
+
 #include <QApplication>
-#include <QMutexLocker>
 #include <QEvent>
+#include <QMutexLocker>
 #include <QObject>
 
-#include <pcl/segmentation/extract_polygonal_prism_data.h>
-#include <pcl/surface/convex_hull.h>
-
 #include <vtkRenderWindow.h>
 
+// #include <boost/filesystem.hpp>  // for boost::filesystem::directory_iterator
+#include <boost/signals2/connection.hpp> // for boost::signals2::connection
+
 void
-displayPlanarRegions (std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > &regions,
-                      const pcl::visualization::PCLVisualizer::Ptr& viewer)
+displayPlanarRegions(
+    std::vector<pcl::PlanarRegion<PointT>,
+                Eigen::aligned_allocator<pcl::PlanarRegion<PointT>>>& regions,
+    const pcl::visualization::PCLVisualizer::Ptr& viewer)
 {
   char name[1024];
-  unsigned char red [6] = {255,   0,   0, 255, 255,   0};
-  unsigned char grn [6] = {  0, 255,   0, 255,   0, 255};
-  unsigned char blu [6] = {  0,   0, 255,   0, 255, 255};
-
-  pcl::PointCloud<PointT>::Ptr contour (new pcl::PointCloud<PointT>);
-
-  for (std::size_t i = 0; i < regions.size (); i++)
-  {
-    Eigen::Vector3f centroid = regions[i].getCentroid ();
-    Eigen::Vector4f model = regions[i].getCoefficients ();
-    pcl::PointXYZ pt1 = pcl::PointXYZ (centroid[0], centroid[1], centroid[2]);
-    pcl::PointXYZ pt2 = pcl::PointXYZ (centroid[0] + (0.5f * model[0]),
-                                       centroid[1] + (0.5f * model[1]),
-                                       centroid[2] + (0.5f * model[2]));
-    sprintf (name, "normal_%d", unsigned (i));
-    viewer->addArrow (pt2, pt1, 1.0, 0, 0, false, name);
-
-    contour->points = regions[i].getContour ();
-    sprintf (name, "plane_%02d", int (i));
-    pcl::visualization::PointCloudColorHandlerCustom <PointT> color (contour, red[i%6], grn[i%6], blu[i%6]);
-    if(!viewer->updatePointCloud(contour, color, name))
-      viewer->addPointCloud (contour, color, name);
-    viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, name);
+  unsigned char red[6] = {255, 0, 0, 255, 255, 0};
+  unsigned char grn[6] = {0, 255, 0, 255, 0, 255};
+  unsigned char blu[6] = {0, 0, 255, 0, 255, 255};
+
+  pcl::PointCloud<PointT>::Ptr contour(new pcl::PointCloud<PointT>);
+
+  for (std::size_t i = 0; i < regions.size(); i++) {
+    Eigen::Vector3f centroid = regions[i].getCentroid();
+    Eigen::Vector4f model = regions[i].getCoefficients();
+    pcl::PointXYZ pt1 = pcl::PointXYZ(centroid[0], centroid[1], centroid[2]);
+    pcl::PointXYZ pt2 = pcl::PointXYZ(centroid[0] + (0.5f * model[0]),
+                                      centroid[1] + (0.5f * model[1]),
+                                      centroid[2] + (0.5f * model[2]));
+    sprintf(name, "normal_%d", unsigned(i));
+    viewer->addArrow(pt2, pt1, 1.0, 0, 0, false, name);
+
+    contour->points = regions[i].getContour();
+    sprintf(name, "plane_%02d", int(i));
+    pcl::visualization::PointCloudColorHandlerCustom<PointT> color(
+        contour, red[i % 6], grn[i % 6], blu[i % 6]);
+    if (!viewer->updatePointCloud(contour, color, name))
+      viewer->addPointCloud(contour, color, name);
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, name);
   }
 }
 
 void
-displayEuclideanClusters (const pcl::PointCloud<PointT>::CloudVectorType &clusters,
-                          const pcl::visualization::PCLVisualizer::Ptr& viewer)
+displayEuclideanClusters(const pcl::PointCloud<PointT>::CloudVectorType& clusters,
+                         const pcl::visualization::PCLVisualizer::Ptr& viewer)
 {
   char name[1024];
-  unsigned char red [6] = {255,   0,   0, 255, 255,   0};
-  unsigned char grn [6] = {  0, 255,   0, 255,   0, 255};
-  unsigned char blu [6] = {  0,   0, 255,   0, 255, 255};
-
-  for (std::size_t i = 0; i < clusters.size (); i++)
-  {
-    sprintf (name, "cluster_%d" , int (i));
-    pcl::PointCloud<PointT>::ConstPtr cluster_cloud (new pcl::PointCloud<PointT> (clusters[i]));
-    pcl::visualization::PointCloudColorHandlerCustom<PointT> color0(cluster_cloud,red[i%6],grn[i%6],blu[i%6]);
-    if (!viewer->updatePointCloud (cluster_cloud,color0,name))
-      viewer->addPointCloud (cluster_cloud,color0,name);
-    viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, name);
-    viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.3, name);
+  unsigned char red[6] = {255, 0, 0, 255, 255, 0};
+  unsigned char grn[6] = {0, 255, 0, 255, 0, 255};
+  unsigned char blu[6] = {0, 0, 255, 0, 255, 255};
+
+  for (std::size_t i = 0; i < clusters.size(); i++) {
+    sprintf(name, "cluster_%d", int(i));
+    pcl::PointCloud<PointT>::ConstPtr cluster_cloud(
+        new pcl::PointCloud<PointT>(clusters[i]));
+    pcl::visualization::PointCloudColorHandlerCustom<PointT> color0(
+        cluster_cloud, red[i % 6], grn[i % 6], blu[i % 6]);
+    if (!viewer->updatePointCloud(cluster_cloud, color0, name))
+      viewer->addPointCloud(cluster_cloud, color0, name);
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, name);
+    viewer->setPointCloudRenderingProperties(
+        pcl::visualization::PCL_VISUALIZER_OPACITY, 0.3, name);
   }
 }
 
 void
-displayCurvature (pcl::PointCloud<PointT>& cloud, pcl::PointCloud<pcl::Normal>& normals, const pcl::visualization::PCLVisualizer::Ptr& viewer)
+displayCurvature(pcl::PointCloud<PointT>& cloud,
+                 pcl::PointCloud<pcl::Normal>& normals,
+                 const pcl::visualization::PCLVisualizer::Ptr& viewer)
 {
   pcl::PointCloud<pcl::PointXYZRGBA> curvature_cloud = cloud;
-  for (std::size_t i  = 0; i < cloud.points.size (); i++)
-  {
-    if (normals.points[i].curvature < 0.04)
-    {
+  for (std::size_t i = 0; i < cloud.points.size(); i++) {
+    if (normals.points[i].curvature < 0.04) {
       curvature_cloud.points[i].r = 0;
       curvature_cloud.points[i].g = 255;
       curvature_cloud.points[i].b = 0;
     }
-    else
-    {
+    else {
       curvature_cloud.points[i].r = 255;
       curvature_cloud.points[i].g = 0;
       curvature_cloud.points[i].b = 0;
     }
   }
 
-  if (!viewer->updatePointCloud (curvature_cloud.makeShared (), "curvature"))
-    viewer->addPointCloud (curvature_cloud.makeShared (), "curvature");
+  if (!viewer->updatePointCloud(curvature_cloud.makeShared(), "curvature"))
+    viewer->addPointCloud(curvature_cloud.makeShared(), "curvature");
 }
 
 void
-displayDistanceMap (pcl::PointCloud<PointT>& cloud, float* distance_map, const pcl::visualization::PCLVisualizer::Ptr& viewer)
+displayDistanceMap(pcl::PointCloud<PointT>& cloud,
+                   float* distance_map,
+                   const pcl::visualization::PCLVisualizer::Ptr& viewer)
 {
   pcl::PointCloud<pcl::PointXYZRGBA> distance_map_cloud = cloud;
-  for (std::size_t i  = 0; i < cloud.points.size (); i++)
-  {
-    if (distance_map[i] < 5.0)
-    {
+  for (std::size_t i = 0; i < cloud.points.size(); i++) {
+    if (distance_map[i] < 5.0) {
       distance_map_cloud.points[i].r = 255;
       distance_map_cloud.points[i].g = 0;
       distance_map_cloud.points[i].b = 0;
     }
-    else
-    {
+    else {
       distance_map_cloud.points[i].r = 0;
       distance_map_cloud.points[i].g = 255;
       distance_map_cloud.points[i].b = 0;
     }
   }
 
-  if (!viewer->updatePointCloud (distance_map_cloud.makeShared (), "distance_map"))
-    viewer->addPointCloud (distance_map_cloud.makeShared (), "distance_map");
+  if (!viewer->updatePointCloud(distance_map_cloud.makeShared(), "distance_map"))
+    viewer->addPointCloud(distance_map_cloud.makeShared(), "distance_map");
 }
 
 void
-removePreviousDataFromScreen (std::size_t prev_models_size, std::size_t prev_clusters_size, const pcl::visualization::PCLVisualizer::Ptr& viewer)
+removePreviousDataFromScreen(std::size_t prev_models_size,
+                             std::size_t prev_clusters_size,
+                             const pcl::visualization::PCLVisualizer::Ptr& viewer)
 {
   char name[1024];
-  for (std::size_t i = 0; i < prev_models_size; i++)
-  {
-    sprintf (name, "normal_%d", unsigned (i));
-    viewer->removeShape (name);
+  for (std::size_t i = 0; i < prev_models_size; i++) {
+    sprintf(name, "normal_%d", unsigned(i));
+    viewer->removeShape(name);
 
-    sprintf (name, "plane_%02d", int (i));
-    viewer->removePointCloud (name);
+    sprintf(name, "plane_%02d", int(i));
+    viewer->removePointCloud(name);
   }
 
-  for (std::size_t i = 0; i < prev_clusters_size; i++)
-  {
-    sprintf (name, "cluster_%d", int (i));
-    viewer->removePointCloud (name);
+  for (std::size_t i = 0; i < prev_clusters_size; i++) {
+    sprintf(name, "cluster_%d", int(i));
+    viewer->removePointCloud(name);
   }
 }
 
 bool
-compareClusterToRegion (pcl::PlanarRegion<PointT>& region, pcl::PointCloud<PointT>& cluster)
+compareClusterToRegion(pcl::PlanarRegion<PointT>& region,
+                       pcl::PointCloud<PointT>& cluster)
 {
-  Eigen::Vector4f model = region.getCoefficients ();
+  Eigen::Vector4f model = region.getCoefficients();
   pcl::PointCloud<PointT> poly;
-  poly.points = region.getContour ();
+  poly.points = region.getContour();
 
-  for (const auto &point : cluster.points)
-  {
-    double ptp_dist = std::abs (model[0] * point.x +
-                            model[1] * point.y +
-                            model[2] * point.z +
-                            model[3]);
-    bool in_poly = pcl::isPointIn2DPolygon<PointT> (point, poly);
+  for (const auto& point : cluster.points) {
+    double ptp_dist = std::abs(model[0] * point.x + model[1] * point.y +
+                               model[2] * point.z + model[3]);
+    bool in_poly = pcl::isPointIn2DPolygon<PointT>(point, poly);
     if (in_poly && ptp_dist < 0.02)
       return true;
   }
@@ -152,81 +159,113 @@ compareClusterToRegion (pcl::PlanarRegion<PointT>& region, pcl::PointCloud<Point
 }
 
 bool
-comparePointToRegion (PointT& pt, pcl::ModelCoefficients& model, pcl::PointCloud<PointT>& poly)
+comparePointToRegion(PointT& pt,
+                     pcl::ModelCoefficients& model,
+                     pcl::PointCloud<PointT>& poly)
 {
-  //bool dist_ok;
-
-  double ptp_dist = std::abs (model.values[0] * pt.x +
-                          model.values[1] * pt.y +
-                          model.values[2] * pt.z +
-                          model.values[3]);
+  double ptp_dist = std::abs(model.values[0] * pt.x + model.values[1] * pt.y +
+                             model.values[2] * pt.z + model.values[3]);
   if (ptp_dist >= 0.1)
-    return (false);
-//  else
-//    dist_ok = true;
+    return false;
 
-  //project the point onto the plane
-  Eigen::Vector3f mc (model.values[0], model.values[1], model.values[2]);
+  // project the point onto the plane
+  Eigen::Vector3f mc(model.values[0], model.values[1], model.values[2]);
   Eigen::Vector3f pt_vec;
   pt_vec[0] = pt.x;
   pt_vec[1] = pt.y;
   pt_vec[2] = pt.z;
-  Eigen::Vector3f projected (pt_vec - mc * float (ptp_dist));
+  Eigen::Vector3f projected(pt_vec - mc * float(ptp_dist));
   PointT projected_pt;
   projected_pt.x = projected[0];
   projected_pt.y = projected[1];
   projected_pt.z = projected[2];
 
-  PCL_INFO ("pt: %lf %lf %lf\n", projected_pt.x, projected_pt.y, projected_pt.z);
+  PCL_INFO("pt: %lf %lf %lf\n", projected_pt.x, projected_pt.y, projected_pt.z);
 
-  if (pcl::isPointIn2DPolygon (projected_pt, poly))
-  {
-    PCL_INFO ("inside!\n");
+  if (pcl::isPointIn2DPolygon(projected_pt, poly)) {
+    PCL_INFO("inside!\n");
     return true;
   }
-  PCL_INFO ("not inside!\n");
+  PCL_INFO("not inside!\n");
   return false;
-
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-OrganizedSegmentationDemo::OrganizedSegmentationDemo (pcl::Grabber& grabber) : grabber_ (grabber)
+OrganizedSegmentationDemo::OrganizedSegmentationDemo(pcl::Grabber& grabber)
+: grabber_(grabber)
 {
-  //Create a timer
-  vis_timer_ = new QTimer (this);
-  vis_timer_->start (5);//5ms
+  // Create a timer
+  vis_timer_ = new QTimer(this);
+  vis_timer_->start(5); // 5ms
 
-  connect (vis_timer_, SIGNAL (timeout ()), this, SLOT (timeoutSlot()));
+  connect(vis_timer_, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
 
   ui_ = new Ui::MainWindow;
-  ui_->setupUi (this);
-
-  this->setWindowTitle ("PCL Organized Connected Component Segmentation Demo");
-  vis_.reset (new pcl::visualization::PCLVisualizer ("", false));
-  ui_->qvtk_widget->SetRenderWindow (vis_->getRenderWindow ());
-  vis_->setupInteractor (ui_->qvtk_widget->GetInteractor (), ui_->qvtk_widget->GetRenderWindow ());
-  vis_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
-  ui_->qvtk_widget->update ();
+  ui_->setupUi(this);
+
+  this->setWindowTitle("PCL Organized Connected Component Segmentation Demo");
+  vis_.reset(new pcl::visualization::PCLVisualizer("", false));
+  ui_->qvtk_widget->SetRenderWindow(vis_->getRenderWindow());
+  vis_->setupInteractor(ui_->qvtk_widget->GetInteractor(),
+                        ui_->qvtk_widget->GetRenderWindow());
+  vis_->getInteractorStyle()->setKeyboardModifier(
+      pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
+  ui_->qvtk_widget->update();
 
-  std::function<void (const CloudConstPtr&)> f = [this] (const CloudConstPtr& cloud) { cloud_cb (cloud); };
+  std::function<void(const CloudConstPtr&)> f = [this](const CloudConstPtr& cloud) {
+    cloud_cb(cloud);
+  };
   boost::signals2::connection c = grabber_.registerCallback(f);
 
-  connect (ui_->captureButton, SIGNAL(clicked()), this, SLOT(toggleCapturePressed()));
-
-  connect (ui_->euclideanComparatorButton, SIGNAL (clicked ()), this, SLOT (useEuclideanComparatorPressed ()));
-  connect (ui_->planeComparatorButton, SIGNAL (clicked ()), this, SLOT (usePlaneComparatorPressed ()));
-  connect (ui_->rgbComparatorButton, SIGNAL (clicked ()), this, SLOT (useRGBComparatorPressed ()));
-  connect (ui_->edgeAwareComparatorButton, SIGNAL (clicked ()), this, SLOT (useEdgeAwareComparatorPressed ()));
-
-  connect (ui_->displayCurvatureButton, SIGNAL (clicked ()), this, SLOT (displayCurvaturePressed ()));
-  connect (ui_->displayDistanceMapButton, SIGNAL (clicked ()), this, SLOT (displayDistanceMapPressed ()));
-  connect (ui_->displayNormalsButton, SIGNAL (clicked ()), this, SLOT (displayNormalsPressed ()));
-
-  connect (ui_->disableRefinementButton, SIGNAL (clicked ()), this, SLOT (disableRefinementPressed ()));
-  connect (ui_->planarRefinementButton, SIGNAL (clicked ()), this, SLOT (usePlanarRefinementPressed ()));
-
-  connect (ui_->disableClusteringButton, SIGNAL (clicked ()), this, SLOT (disableClusteringPressed ()));
-  connect (ui_->euclideanClusteringButton, SIGNAL (clicked ()), this, SLOT (useEuclideanClusteringPressed ()));
+  connect(ui_->captureButton, SIGNAL(clicked()), this, SLOT(toggleCapturePressed()));
+
+  connect(ui_->euclideanComparatorButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(useEuclideanComparatorPressed()));
+  connect(ui_->planeComparatorButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(usePlaneComparatorPressed()));
+  connect(ui_->rgbComparatorButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(useRGBComparatorPressed()));
+  connect(ui_->edgeAwareComparatorButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(useEdgeAwareComparatorPressed()));
+
+  connect(ui_->displayCurvatureButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(displayCurvaturePressed()));
+  connect(ui_->displayDistanceMapButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(displayDistanceMapPressed()));
+  connect(ui_->displayNormalsButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(displayNormalsPressed()));
+
+  connect(ui_->disableRefinementButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(disableRefinementPressed()));
+  connect(ui_->planarRefinementButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(usePlanarRefinementPressed()));
+
+  connect(ui_->disableClusteringButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(disableClusteringPressed()));
+  connect(ui_->euclideanClusteringButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(useEuclideanClusteringPressed()));
 
   capture_ = false;
   previous_data_size_ = 0;
@@ -240,103 +279,116 @@ OrganizedSegmentationDemo::OrganizedSegmentationDemo (pcl::Grabber& grabber) : g
   use_planar_refinement_ = true;
   use_clustering_ = false;
 
-
   // Set up Normal Estimation
-  //ne.setNormalEstimationMethod (ne.SIMPLE_3D_GRADIENT);
-  ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-  ne.setMaxDepthChangeFactor (0.02f); // set as default, well performing for tabletop objects as imaged by a primesense sensor
-  ne.setNormalSmoothingSize (20.0f);
-
-  plane_comparator_.reset (new pcl::PlaneCoefficientComparator<PointT, pcl::Normal> ());
-  euclidean_comparator_.reset (new pcl::EuclideanPlaneCoefficientComparator<PointT, pcl::Normal> ());
-  rgb_comparator_.reset (new pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal> ());
-  edge_aware_comparator_.reset (new pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal> ());
-  euclidean_cluster_comparator_ = pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr (new pcl::EuclideanClusterComparator<PointT, pcl::Label> ());
+  // ne.setNormalEstimationMethod (ne.SIMPLE_3D_GRADIENT);
+  ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+  ne.setMaxDepthChangeFactor(0.02f); // set as default, well performing for tabletop
+                                     // objects as imaged by a primesense sensor
+  ne.setNormalSmoothingSize(20.0f);
+
+  plane_comparator_.reset(new pcl::PlaneCoefficientComparator<PointT, pcl::Normal>());
+  euclidean_comparator_.reset(
+      new pcl::EuclideanPlaneCoefficientComparator<PointT, pcl::Normal>());
+  rgb_comparator_.reset(new pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal>());
+  edge_aware_comparator_.reset(
+      new pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal>());
+  euclidean_cluster_comparator_ =
+      pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr(
+          new pcl::EuclideanClusterComparator<PointT, pcl::Label>());
 
   // Set up Organized Multi Plane Segmentation
-  mps.setMinInliers (10000u);
-  mps.setAngularThreshold (pcl::deg2rad (3.0)); // 3 degrees, set as default, well performing for tabletop objects as imaged by a primesense sensor
-  mps.setDistanceThreshold (0.02); // 2cm, set as default, well performing for tabletop objects as imaged by a primesense sensor
-
-
-  PCL_INFO ("starting grabber\n");
-  grabber_.start ();
+  mps.setMinInliers(10000u);
+  mps.setAngularThreshold(
+      pcl::deg2rad(3.0)); // 3 degrees, set as default, well performing for tabletop
+                          // objects as imaged by a primesense sensor
+  mps.setDistanceThreshold(0.02); // 2cm, set as default, well performing for tabletop
+                                  // objects as imaged by a primesense sensor
+
+  PCL_INFO("starting grabber\n");
+  grabber_.start();
 }
 
 void
-OrganizedSegmentationDemo::cloud_cb (const CloudConstPtr& cloud)
+OrganizedSegmentationDemo::cloud_cb(const CloudConstPtr& cloud)
 {
   if (!capture_)
     return;
-  QMutexLocker locker (&mtx_);
-  FPS_CALC ("computation");
+  QMutexLocker locker(&mtx_);
+  FPS_CALC("computation");
 
   // Estimate Normals
-  pcl::PointCloud<pcl::Normal>::Ptr normal_cloud (new pcl::PointCloud<pcl::Normal>);
-  ne.setInputCloud (cloud);
-  ne.compute (*normal_cloud);
-  float* distance_map = ne.getDistanceMap ();
-  pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal>::Ptr eapc = boost::dynamic_pointer_cast<pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal> >(edge_aware_comparator_);
-  eapc->setDistanceMap (distance_map);
-  eapc->setDistanceThreshold (0.01f, false);
+  pcl::PointCloud<pcl::Normal>::Ptr normal_cloud(new pcl::PointCloud<pcl::Normal>);
+  ne.setInputCloud(cloud);
+  ne.compute(*normal_cloud);
+  float* distance_map = ne.getDistanceMap();
+  pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal>::Ptr eapc =
+      pcl::dynamic_pointer_cast<pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal>>(
+          edge_aware_comparator_);
+  eapc->setDistanceMap(distance_map);
+  eapc->setDistanceThreshold(0.01f, false);
 
   // Segment Planes
-  double mps_start = pcl::getTime ();
-  std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > regions;
+  double mps_start = pcl::getTime();
+  std::vector<pcl::PlanarRegion<PointT>,
+              Eigen::aligned_allocator<pcl::PlanarRegion<PointT>>>
+      regions;
   std::vector<pcl::ModelCoefficients> model_coefficients;
   std::vector<pcl::PointIndices> inlier_indices;
-  pcl::PointCloud<pcl::Label>::Ptr labels (new pcl::PointCloud<pcl::Label>);
+  pcl::PointCloud<pcl::Label>::Ptr labels(new pcl::PointCloud<pcl::Label>);
   std::vector<pcl::PointIndices> label_indices;
   std::vector<pcl::PointIndices> boundary_indices;
-  mps.setInputNormals (normal_cloud);
-  mps.setInputCloud (cloud);
-  if (use_planar_refinement_)
-  {
-    mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);
+  mps.setInputNormals(normal_cloud);
+  mps.setInputCloud(cloud);
+  if (use_planar_refinement_) {
+    mps.segmentAndRefine(regions,
+                         model_coefficients,
+                         inlier_indices,
+                         labels,
+                         label_indices,
+                         boundary_indices);
   }
-  else
-  {
-    mps.segment (regions);//, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);
+  else {
+    mps.segment(regions);
   }
-  double mps_end = pcl::getTime ();
+  double mps_end = pcl::getTime();
   std::cout << "MPS+Refine took: " << double(mps_end - mps_start) << std::endl;
 
-  //Segment Objects
+  // Segment Objects
   pcl::PointCloud<PointT>::CloudVectorType clusters;
 
-  if (use_clustering_ && !regions.empty ())
-  {
-    pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSetPtr plane_labels (new pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSet);
-    for (std::size_t i = 0; i < label_indices.size (); ++i)
-      if (label_indices[i].indices.size () > mps.getMinInliers())
-        plane_labels->insert (i);
+  if (use_clustering_ && !regions.empty()) {
+    pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSetPtr
+        plane_labels(
+            new pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSet);
+    for (std::size_t i = 0; i < label_indices.size(); ++i)
+      if (label_indices[i].indices.size() > mps.getMinInliers())
+        plane_labels->insert(i);
 
-    euclidean_cluster_comparator_->setInputCloud (cloud);
-    euclidean_cluster_comparator_->setLabels (labels);
-    euclidean_cluster_comparator_->setExcludeLabels (plane_labels);
-    euclidean_cluster_comparator_->setDistanceThreshold (0.01f, false);
+    euclidean_cluster_comparator_->setInputCloud(cloud);
+    euclidean_cluster_comparator_->setLabels(labels);
+    euclidean_cluster_comparator_->setExcludeLabels(plane_labels);
+    euclidean_cluster_comparator_->setDistanceThreshold(0.01f, false);
 
     pcl::PointCloud<pcl::Label> euclidean_labels;
     std::vector<pcl::PointIndices> euclidean_label_indices;
-    pcl::OrganizedConnectedComponentSegmentation<PointT,pcl::Label> euclidean_segmentation (euclidean_cluster_comparator_);
-    euclidean_segmentation.setInputCloud (cloud);
-    euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices);
-
-    for (const auto &euclidean_label_index : euclidean_label_indices)
-    {
-      if (euclidean_label_index.indices.size () > 1000u)
-      {
+    pcl::OrganizedConnectedComponentSegmentation<PointT, pcl::Label>
+        euclidean_segmentation(euclidean_cluster_comparator_);
+    euclidean_segmentation.setInputCloud(cloud);
+    euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices);
+
+    for (const auto& euclidean_label_index : euclidean_label_indices) {
+      if (euclidean_label_index.indices.size() > 1000u) {
         pcl::PointCloud<PointT> cluster;
-        pcl::copyPointCloud (*cloud, euclidean_label_index.indices,cluster);
-        clusters.push_back (cluster);
+        pcl::copyPointCloud(*cloud, euclidean_label_index.indices, cluster);
+        clusters.push_back(cluster);
       }
     }
 
-    PCL_INFO ("Got %d euclidean clusters!\n", clusters.size ());
+    PCL_INFO("Got %d euclidean clusters!\n", clusters.size());
   }
 
   {
-    QMutexLocker vis_locker (&vis_mtx_);
+    QMutexLocker vis_locker(&vis_mtx_);
     prev_cloud_ = *cloud;
     prev_normals_ = *normal_cloud;
     prev_regions_ = regions;
@@ -347,46 +399,44 @@ OrganizedSegmentationDemo::cloud_cb (const CloudConstPtr& cloud)
 }
 
 void
-OrganizedSegmentationDemo::timeoutSlot ()
+OrganizedSegmentationDemo::timeoutSlot()
 {
   {
-    QMutexLocker vis_locker (&vis_mtx_);
-    if (capture_ && data_modified_)
-    {
-      removePreviousDataFromScreen (previous_data_size_, previous_clusters_size_, vis_);
-      if (!vis_->updatePointCloud (prev_cloud_.makeShared (), "cloud"))
-      {
-        vis_->addPointCloud (prev_cloud_.makeShared (), "cloud");
-        vis_->resetCameraViewpoint ("cloud");
+    QMutexLocker vis_locker(&vis_mtx_);
+    if (capture_ && data_modified_) {
+      removePreviousDataFromScreen(previous_data_size_, previous_clusters_size_, vis_);
+      if (!vis_->updatePointCloud(prev_cloud_.makeShared(), "cloud")) {
+        vis_->addPointCloud(prev_cloud_.makeShared(), "cloud");
+        vis_->resetCameraViewpoint("cloud");
       }
 
-      displayPlanarRegions (prev_regions_, vis_);
+      displayPlanarRegions(prev_regions_, vis_);
 
       if (display_curvature_)
-        displayCurvature (prev_cloud_, prev_normals_, vis_);
+        displayCurvature(prev_cloud_, prev_normals_, vis_);
       else
-        vis_->removePointCloud ("curvature");
+        vis_->removePointCloud("curvature");
 
       if (display_distance_map_)
-        displayDistanceMap (prev_cloud_, prev_distance_map_, vis_);
+        displayDistanceMap(prev_cloud_, prev_distance_map_, vis_);
       else
-        vis_->removePointCloud ("distance_map");
-
-      if (display_normals_)
-      {
-        vis_->removePointCloud ("normals");
-        vis_->addPointCloudNormals<PointT,pcl::Normal>(prev_cloud_.makeShared(), prev_normals_.makeShared (), 10, 0.05f, "normals");
-        vis_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "normals");
+        vis_->removePointCloud("distance_map");
+
+      if (display_normals_) {
+        vis_->removePointCloud("normals");
+        vis_->addPointCloudNormals<PointT, pcl::Normal>(
+            prev_cloud_.makeShared(), prev_normals_.makeShared(), 10, 0.05f, "normals");
+        vis_->setPointCloudRenderingProperties(
+            pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "normals");
       }
-      else
-      {
-        vis_->removePointCloud ("normals");
+      else {
+        vis_->removePointCloud("normals");
       }
 
-      displayEuclideanClusters (prev_clusters_,vis_);
+      displayEuclideanClusters(prev_clusters_, vis_);
 
-      previous_data_size_ = prev_regions_.size ();
-      previous_clusters_size_ = prev_clusters_.size ();
+      previous_data_size_ = prev_regions_.size();
+      previous_clusters_size_ = prev_clusters_.size();
       data_modified_ = false;
     }
   }
@@ -395,76 +445,63 @@ OrganizedSegmentationDemo::timeoutSlot ()
 }
 
 void
-OrganizedSegmentationDemo::useEuclideanComparatorPressed ()
+OrganizedSegmentationDemo::useEuclideanComparatorPressed()
 {
-  QMutexLocker locker (&mtx_);
-  PCL_INFO ("Setting Comparator to Euclidean\n");
-  mps.setComparator (euclidean_comparator_);
+  QMutexLocker locker(&mtx_);
+  PCL_INFO("Setting Comparator to Euclidean\n");
+  mps.setComparator(euclidean_comparator_);
 }
 
 void
-OrganizedSegmentationDemo::useRGBComparatorPressed ()
+OrganizedSegmentationDemo::useRGBComparatorPressed()
 {
-  QMutexLocker locker (&mtx_);
-  PCL_INFO ("Setting Comparator to RGB\n");
-  mps.setComparator (rgb_comparator_);
+  QMutexLocker locker(&mtx_);
+  PCL_INFO("Setting Comparator to RGB\n");
+  mps.setComparator(rgb_comparator_);
 }
 
 void
-OrganizedSegmentationDemo::usePlaneComparatorPressed ()
+OrganizedSegmentationDemo::usePlaneComparatorPressed()
 {
-  QMutexLocker locker (&mtx_);
-  PCL_INFO ("Setting Comparator to Plane\n");
-  mps.setComparator (plane_comparator_);
+  QMutexLocker locker(&mtx_);
+  PCL_INFO("Setting Comparator to Plane\n");
+  mps.setComparator(plane_comparator_);
 }
 
 void
-OrganizedSegmentationDemo::useEdgeAwareComparatorPressed ()
+OrganizedSegmentationDemo::useEdgeAwareComparatorPressed()
 {
-  QMutexLocker locker (&mtx_);
-  PCL_INFO ("Setting Comparator to edge aware\n");
-  mps.setComparator (edge_aware_comparator_);
+  QMutexLocker locker(&mtx_);
+  PCL_INFO("Setting Comparator to edge aware\n");
+  mps.setComparator(edge_aware_comparator_);
 }
 
 void
-OrganizedSegmentationDemo::displayCurvaturePressed ()
+OrganizedSegmentationDemo::displayCurvaturePressed()
 {
   display_curvature_ = !display_curvature_;
 }
 
 void
-OrganizedSegmentationDemo::displayDistanceMapPressed ()
+OrganizedSegmentationDemo::displayDistanceMapPressed()
 {
   display_distance_map_ = !display_distance_map_;
 }
 
 void
-OrganizedSegmentationDemo::displayNormalsPressed ()
+OrganizedSegmentationDemo::displayNormalsPressed()
 {
   display_normals_ = !display_normals_;
 }
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
   QApplication app(argc, argv);
 
-  //PCL_INFO ("Creating PCD Grabber\n");
-  //std::vector<std::string> pcd_files;
-  //boost::filesystem::directory_iterator end_itr;
-  //for (boost::filesystem::directory_iterator itr("/u/atrevor/data/sushi_long_pcds_compressed"); itr != end_itr; ++itr)
-  //{
-  //  pcd_files.push_back (itr->path ().string ());
-  //  std::cout << "added: " << itr->path ().string () << std::endl;
-  //}
-  //sort (pcd_files.begin (),pcd_files.end ());
-
-  //pcl::PCDGrabber<pcl::PointXYZRGB> grabber(pcd_files,5.0,false);
-  //PCL_INFO ("PCD Grabber created\n");
-
-  pcl::OpenNIGrabber grabber ("#1");
+  pcl::OpenNIGrabber grabber("#1");
 
-  OrganizedSegmentationDemo seg_demo (grabber);
+  OrganizedSegmentationDemo seg_demo(grabber);
   seg_demo.show();
-  return (QApplication::exec ());
+  return QApplication::exec();
 }
index f6c59b6112fe84b9575af7d1e1cea43c9e5227ee..6eb0c222c0a827804bbab64a713625064b29d22d 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2011, Willow Garage, Inc.
- *  
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
  *
- * 
+ *
  *
  */
 
-#include <thread>
-
-#include <pcl/console/print.h>
 #include <pcl/console/parse.h>
+#include <pcl/console/print.h>
 #include <pcl/console/time.h>
-#include <pcl/features/organized_edge_detection.h>
 #include <pcl/features/integral_image_normal.h>
+#include <pcl/features/organized_edge_detection.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/visualization/cloud_viewer.h>
 #include <pcl/PCLPointCloud2.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+
+#include <thread>
 
 using namespace pcl;
 using namespace pcl::io;
@@ -56,217 +56,266 @@ using namespace pcl::console;
 using namespace std::chrono_literals;
 
 float default_th_dd = 0.02f;
-int   default_max_search = 50;
+int default_max_search = 50;
 
 using Cloud = pcl::PointCloud<pcl::PointXYZRGBA>;
 using CloudPtr = Cloud::Ptr;
 using CloudConstPtr = Cloud::ConstPtr;
 
-pcl::visualization::PCLVisualizer viewer ("3D Edge Viewer");
+pcl::visualization::PCLVisualizer viewer("3D Edge Viewer");
 
 void
-printHelp (int, char **argv)
+printHelp(int, char** argv)
 {
+  // clang-format off
   print_error ("Syntax is: %s input.pcd output.pcd <options>\n", argv[0]);
   print_info ("  where options are:\n");
   print_info ("                     -th_dd X       = the tolerance in meters for difference in depth values between neighboring points (The value is set for 1 meter and is adapted with respect to depth value linearly. (e.g. 2.0*th_dd in 2 meter depth)) (default: "); 
   print_value ("%f", default_th_dd); print_info (")\n");
   print_info ("                     -max_search X  = the max search distance for deciding occluding and occluded edges (default: "); 
   print_value ("%d", default_max_search); print_info (")\n");
+  // clang-format on
 }
 
 bool
-loadCloud (const std::string &filename, pcl::PCLPointCloud2 &cloud)
+loadCloud(const std::string& filename, pcl::PCLPointCloud2& cloud)
 {
   TicToc tt;
-  print_highlight ("Loading "); print_value ("%s ", filename.c_str ());
-
-  tt.tic ();
-  if (loadPCDFile (filename, cloud) < 0)
-    return (false);
-  print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", cloud.width * cloud.height); print_info (" points]\n");
-  print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (cloud).c_str ());
-
-  return (true);
+  print_highlight("Loading ");
+  print_value("%s ", filename.c_str());
+
+  tt.tic();
+  if (loadPCDFile(filename, cloud) < 0)
+    return false;
+  print_info("[done, ");
+  print_value("%g", tt.toc());
+  print_info(" ms : ");
+  print_value("%d", cloud.width * cloud.height);
+  print_info(" points]\n");
+  print_info("Available dimensions: ");
+  print_value("%s\n", pcl::getFieldsList(cloud).c_str());
+
+  return true;
 }
 
 void
-saveCloud (const std::string &filename, const pcl::PCLPointCloud2 &output)
+saveCloud(const std::string& filename, const pcl::PCLPointCloud2& output)
 {
   TicToc tt;
-  tt.tic ();
-
-  print_highlight ("Saving "); print_value ("%s ", filename.c_str ());
-  
-  pcl::io::savePCDFile (filename, output, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), true); // Save as binary
-  
-  print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", output.width * output.height); print_info (" points]\n");
+  tt.tic();
+
+  print_highlight("Saving ");
+  print_value("%s ", filename.c_str());
+
+  pcl::io::savePCDFile(filename,
+                       output,
+                       Eigen::Vector4f::Zero(),
+                       Eigen::Quaternionf::Identity(),
+                       true); // Save as binary
+
+  print_info("[done, ");
+  print_value("%g", tt.toc());
+  print_info(" ms : ");
+  print_value("%d", output.width * output.height);
+  print_info(" points]\n");
 }
 
-void 
-keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
+void
+keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
 {
-  if (event.keyUp())
-  {
+  if (event.keyUp()) {
     double opacity;
-    switch (event.getKeyCode())
-    {
-      case '1':
-        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "nan boundary edges");
-        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "nan boundary edges");
-        break;
-      case '2':
-        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluding edges");
-        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "occluding edges");
-        break;
-      case '3':
-        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluded edges");
-        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "occluded edges");
-        break;
-      case '4':
-        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "high curvature edges");
-        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "high curvature edges");
-        break;
-      case '5':
-        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "rgb edges");
-        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "rgb edges");
-        break;
+    switch (event.getKeyCode()) {
+    case '1':
+      viewer.getPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "nan boundary edges");
+      viewer.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY,
+          1.0 - opacity,
+          "nan boundary edges");
+      break;
+    case '2':
+      viewer.getPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluding edges");
+      viewer.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0 - opacity, "occluding edges");
+      break;
+    case '3':
+      viewer.getPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluded edges");
+      viewer.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0 - opacity, "occluded edges");
+      break;
+    case '4':
+      viewer.getPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "high curvature edges");
+      viewer.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY,
+          1.0 - opacity,
+          "high curvature edges");
+      break;
+    case '5':
+      viewer.getPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "rgb edges");
+      viewer.setPointCloudRenderingProperties(
+          pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0 - opacity, "rgb edges");
+      break;
     }
   }
 }
 
 void
-compute (const pcl::PCLPointCloud2::ConstPtr &input, pcl::PCLPointCloud2 &output,
-         float th_dd, int max_search)
+compute(const pcl::PCLPointCloud2::ConstPtr& input,
+        pcl::PCLPointCloud2& output,
+        float th_dd,
+        int max_search)
 {
-  CloudPtr cloud (new Cloud);
-  fromPCLPointCloud2 (*input, *cloud);
+  CloudPtr cloud(new Cloud);
+  fromPCLPointCloud2(*input, *cloud);
 
-  pcl::PointCloud<pcl::Normal>::Ptr normal (new pcl::PointCloud<pcl::Normal>);
+  pcl::PointCloud<pcl::Normal>::Ptr normal(new pcl::PointCloud<pcl::Normal>);
   pcl::IntegralImageNormalEstimation<PointXYZRGBA, pcl::Normal> ne;
-  ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-  ne.setNormalSmoothingSize (10.0f);
-  ne.setBorderPolicy (ne.BORDER_POLICY_MIRROR);
-  ne.setInputCloud (cloud);
-  ne.compute (*normal);
+  ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+  ne.setNormalSmoothingSize(10.0f);
+  ne.setBorderPolicy(ne.BORDER_POLICY_MIRROR);
+  ne.setInputCloud(cloud);
+  ne.compute(*normal);
 
   TicToc tt;
-  tt.tic ();
+  tt.tic();
 
-  //OrganizedEdgeBase<PointXYZRGBA, Label> oed;
-  //OrganizedEdgeFromRGB<PointXYZRGBA, Label> oed;
-  //OrganizedEdgeFromNormals<PointXYZRGBA, Normal, Label> oed;
+  // OrganizedEdgeBase<PointXYZRGBA, Label> oed;
+  // OrganizedEdgeFromRGB<PointXYZRGBA, Label> oed;
+  // OrganizedEdgeFromNormals<PointXYZRGBA, Normal, Label> oed;
   OrganizedEdgeFromRGBNormals<PointXYZRGBA, Normal, Label> oed;
-  oed.setInputNormals (normal);
-  oed.setInputCloud (cloud);
-  oed.setDepthDisconThreshold (th_dd);
-  oed.setMaxSearchNeighbors (max_search);
-  oed.setEdgeType (oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING | oed.EDGELABEL_OCCLUDED | oed.EDGELABEL_HIGH_CURVATURE | oed.EDGELABEL_RGB_CANNY);
+  oed.setInputNormals(normal);
+  oed.setInputCloud(cloud);
+  oed.setDepthDisconThreshold(th_dd);
+  oed.setMaxSearchNeighbors(max_search);
+  oed.setEdgeType(oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING |
+                  oed.EDGELABEL_OCCLUDED | oed.EDGELABEL_HIGH_CURVATURE |
+                  oed.EDGELABEL_RGB_CANNY);
   PointCloud<Label> labels;
   std::vector<PointIndices> label_indices;
-  oed.compute (labels, label_indices);
-  print_info ("Detecting all edges... [done, "); print_value ("%g", tt.toc ()); print_info (" ms]\n");
+  oed.compute(labels, label_indices);
+  print_info("Detecting all edges... [done, ");
+  print_value("%g", tt.toc());
+  print_info(" ms]\n");
 
   // Make gray point clouds
-  for (auto &point : cloud->points)
-  {
-    std::uint8_t gray = std::uint8_t ((point.r + point.g + point.b) / 3);
+  for (auto& point : cloud->points) {
+    std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3);
     point.r = point.g = point.b = gray;
   }
 
   // Display edges in PCLVisualizer
-  viewer.setSize (640, 480);
-  viewer.addCoordinateSystem (0.2f, "global");
-  viewer.addPointCloud (cloud, "original point cloud");
+  viewer.setSize(640, 480);
+  viewer.addCoordinateSystem(0.2f, "global");
+  viewer.addPointCloud(cloud, "original point cloud");
   viewer.registerKeyboardCallback(&keyboard_callback);
 
-  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr occluding_edges (new pcl::PointCloud<pcl::PointXYZRGBA>), 
-    occluded_edges (new pcl::PointCloud<pcl::PointXYZRGBA>), 
-    nan_boundary_edges (new pcl::PointCloud<pcl::PointXYZRGBA>),
-    high_curvature_edges (new pcl::PointCloud<pcl::PointXYZRGBA>),
-    rgb_edges (new pcl::PointCloud<pcl::PointXYZRGBA>);
+  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr occluding_edges(
+      new pcl::PointCloud<pcl::PointXYZRGBA>),
+      occluded_edges(new pcl::PointCloud<pcl::PointXYZRGBA>),
+      nan_boundary_edges(new pcl::PointCloud<pcl::PointXYZRGBA>),
+      high_curvature_edges(new pcl::PointCloud<pcl::PointXYZRGBA>),
+      rgb_edges(new pcl::PointCloud<pcl::PointXYZRGBA>);
 
-  pcl::copyPointCloud (*cloud, label_indices[0].indices, *nan_boundary_edges);
-  pcl::copyPointCloud (*cloud, label_indices[1].indices, *occluding_edges);
-  pcl::copyPointCloud (*cloud, label_indices[2].indices, *occluded_edges);
-  pcl::copyPointCloud (*cloud, label_indices[3].indices, *high_curvature_edges);
-  pcl::copyPointCloud (*cloud, label_indices[4].indices, *rgb_edges);
+  pcl::copyPointCloud(*cloud, label_indices[0].indices, *nan_boundary_edges);
+  pcl::copyPointCloud(*cloud, label_indices[1].indices, *occluding_edges);
+  pcl::copyPointCloud(*cloud, label_indices[2].indices, *occluded_edges);
+  pcl::copyPointCloud(*cloud, label_indices[3].indices, *high_curvature_edges);
+  pcl::copyPointCloud(*cloud, label_indices[4].indices, *rgb_edges);
 
   const int point_size = 2;
-  viewer.addPointCloud<pcl::PointXYZRGBA> (nan_boundary_edges, "nan boundary edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "nan boundary edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 0.0f, 1.0f, "nan boundary edges");
-
-  viewer.addPointCloud<pcl::PointXYZRGBA> (occluding_edges, "occluding edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluding edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 0.0f, "occluding edges");
-
-  viewer.addPointCloud<pcl::PointXYZRGBA> (occluded_edges, "occluded edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluded edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0f, 0.0f, 0.0f, "occluded edges");
-
-  viewer.addPointCloud<pcl::PointXYZRGBA> (high_curvature_edges, "high curvature edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "high curvature edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0f, 1.0f, 0.0f, "high curvature edges");
-
-  viewer.addPointCloud<pcl::PointXYZRGBA> (rgb_edges, "rgb edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "rgb edges");
-  viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 1.0f, "rgb edges");
-
-  while (!viewer.wasStopped ())
-  {
-    viewer.spinOnce ();
+  viewer.addPointCloud<pcl::PointXYZRGBA>(nan_boundary_edges, "nan boundary edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "nan boundary edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 0.0f, 1.0f, "nan boundary edges");
+
+  viewer.addPointCloud<pcl::PointXYZRGBA>(occluding_edges, "occluding edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluding edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 0.0f, "occluding edges");
+
+  viewer.addPointCloud<pcl::PointXYZRGBA>(occluded_edges, "occluded edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "occluded edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_COLOR, 1.0f, 0.0f, 0.0f, "occluded edges");
+
+  viewer.addPointCloud<pcl::PointXYZRGBA>(high_curvature_edges, "high curvature edges");
+  viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
+                                          point_size,
+                                          "high curvature edges");
+  viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
+                                          1.0f,
+                                          1.0f,
+                                          0.0f,
+                                          "high curvature edges");
+
+  viewer.addPointCloud<pcl::PointXYZRGBA>(rgb_edges, "rgb edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, "rgb edges");
+  viewer.setPointCloudRenderingProperties(
+      pcl::visualization::PCL_VISUALIZER_COLOR, 0.0f, 1.0f, 1.0f, "rgb edges");
+
+  while (!viewer.wasStopped()) {
+    viewer.spinOnce();
     std::this_thread::sleep_for(100us);
   }
 
   // Combine point clouds and edge labels
   pcl::PCLPointCloud2 output_edges;
-  toPCLPointCloud2 (labels, output_edges);
-  concatenateFields (*input, output_edges, output);
+  toPCLPointCloud2(labels, output_edges);
+  concatenateFields(*input, output_edges, output);
 }
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
-  print_info ("Detect 3D edges from organized point cloud data. For more information, use: %s -h\n", argv[0]);
+  print_info("Detect 3D edges from organized point cloud data. For more information, "
+             "use: %s -h\n",
+             argv[0]);
   bool help = false;
-  parse_argument (argc, argv, "-h", help);
-  if (argc < 3 || help)
-  {
-    printHelp (argc, argv);
-    return (-1);
+  parse_argument(argc, argv, "-h", help);
+  if (argc < 3 || help) {
+    printHelp(argc, argv);
+    return -1;
   }
 
   // Parse the command line arguments for .pcd files
   std::vector<int> p_file_indices;
-  p_file_indices = parse_file_extension_argument (argc, argv, ".pcd");
-  if (p_file_indices.size () != 2)
-  {
-    print_error ("Need one input PCD file and one output PCD file to continue.\n");
-    return (-1);
+  p_file_indices = parse_file_extension_argument(argc, argv, ".pcd");
+  if (p_file_indices.size() != 2) {
+    print_error("Need one input PCD file and one output PCD file to continue.\n");
+    return -1;
   }
 
   // Command line parsing
   float th_dd = default_th_dd;
   int max_search = default_max_search;
 
-  parse_argument (argc, argv, "-th_dd", th_dd);
-  parse_argument (argc, argv, "-max_search", max_search);
+  parse_argument(argc, argv, "-th_dd", th_dd);
+  parse_argument(argc, argv, "-max_search", max_search);
 
-  print_info ("th_dd: "); print_value ("%f\n", th_dd); 
-  print_info ("max_search: "); print_value ("%d\n", max_search); 
+  print_info("th_dd: ");
+  print_value("%f\n", th_dd);
+  print_info("max_search: ");
+  print_value("%d\n", max_search);
 
   // Load the first file
-  pcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2);
-  if (!loadCloud (argv[p_file_indices[0]], *cloud)) 
-    return (-1);
+  pcl::PCLPointCloud2::Ptr cloud(new pcl::PCLPointCloud2);
+  if (!loadCloud(argv[p_file_indices[0]], *cloud))
+    return -1;
 
   // Perform the feature estimation
   pcl::PCLPointCloud2 output;
 
-  compute (cloud, output, th_dd, max_search);
+  compute(cloud, output, th_dd, max_search);
 
   // Save into the second file
-  saveCloud (argv[p_file_indices[1]], output);
+  saveCloud(argv[p_file_indices[1]], output);
 }
-
index 750deef963a873919736ec5871b830f635d03685..db478a12650a7b13ce19005ef8fbba4da1fe7dde 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  *
  */
-#include <pcl/io/io.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/common/time.h>
+#include <pcl/console/parse.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/ModelCoefficients.h>
-#include <pcl/segmentation/planar_region.h>
-#include <pcl/segmentation/organized_multi_plane_segmentation.h>
-#include <pcl/segmentation/organized_connected_component_segmentation.h>
 #include <pcl/filters/extract_indices.h>
-#include <pcl/console/parse.h>
 #include <pcl/geometry/polygon_operations.h>
+#include <pcl/io/io.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/segmentation/organized_connected_component_segmentation.h>
+#include <pcl/segmentation/organized_multi_plane_segmentation.h>
+#include <pcl/segmentation/planar_region.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/ModelCoefficients.h>
 
-template<typename PointT>
-class PCDOrganizedMultiPlaneSegmentation
-{
-  private:
-    pcl::visualization::PCLVisualizer viewer;
-    typename pcl::PointCloud<PointT>::ConstPtr cloud;
-    bool refine_;
-    float threshold_;
-    bool depth_dependent_;
-    bool polygon_refinement_;
-  public:
-    PCDOrganizedMultiPlaneSegmentation (typename pcl::PointCloud<PointT>::ConstPtr cloud_, bool refine)
-    : viewer ("Viewer")
-    , cloud (cloud_)
-    , refine_ (refine)
-    , threshold_ (0.02f)
-    , depth_dependent_ (true)
-    , polygon_refinement_ (false)
-    {
-      viewer.setBackgroundColor (0, 0, 0);
-      //viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");
-      //viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.15, "cloud");
-      viewer.addCoordinateSystem (1.0, "global");
-      viewer.initCameraParameters ();
-      viewer.registerKeyboardCallback(&PCDOrganizedMultiPlaneSegmentation::keyboard_callback, *this, nullptr);
-    }
+template <typename PointT>
+class PCDOrganizedMultiPlaneSegmentation {
+private:
+  pcl::visualization::PCLVisualizer viewer;
+  typename pcl::PointCloud<PointT>::ConstPtr cloud;
+  bool refine_;
+  float threshold_;
+  bool depth_dependent_;
+  bool polygon_refinement_;
+
+public:
+  PCDOrganizedMultiPlaneSegmentation(typename pcl::PointCloud<PointT>::ConstPtr cloud_,
+                                     bool refine)
+  : viewer("Viewer")
+  , cloud(cloud_)
+  , refine_(refine)
+  , threshold_(0.02f)
+  , depth_dependent_(true)
+  , polygon_refinement_(false)
+  {
+    viewer.setBackgroundColor(0, 0, 0);
+    viewer.addCoordinateSystem(1.0, "global");
+    viewer.initCameraParameters();
+    viewer.registerKeyboardCallback(
+        &PCDOrganizedMultiPlaneSegmentation::keyboard_callback, *this, nullptr);
+  }
 
-    void keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      // do stuff and visualize here
-      if (event.keyUp ())
-      {
-        switch (event.getKeyCode ())
-        {
-          case 'b':
-          case 'B':
-            if (threshold_ < 0.1f)
-              threshold_ += 0.001f;
-            process ();
-            break;
-          case 'v':
-          case 'V':
-            if (threshold_ > 0.001f)
-              threshold_ -= 0.001f;
-            process ();
-            break;
-            
-          case 'n':
-          case 'N':
-            depth_dependent_ = !depth_dependent_;
-            process ();
-            break;
-            
-          case 'm':
-          case 'M':
-            polygon_refinement_ = !polygon_refinement_;
-            process ();
-            break;
-        }
+  void
+  keyboard_callback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    // do stuff and visualize here
+    if (event.keyUp()) {
+      switch (event.getKeyCode()) {
+      case 'b':
+      case 'B':
+        if (threshold_ < 0.1f)
+          threshold_ += 0.001f;
+        process();
+        break;
+      case 'v':
+      case 'V':
+        if (threshold_ > 0.001f)
+          threshold_ -= 0.001f;
+        process();
+        break;
+
+      case 'n':
+      case 'N':
+        depth_dependent_ = !depth_dependent_;
+        process();
+        break;
+
+      case 'm':
+      case 'M':
+        polygon_refinement_ = !polygon_refinement_;
+        process();
+        break;
       }
     }
-    
-    void
-    process ()
-    {
-      std::cout << "threshold: " << threshold_ << std::endl;
-      std::cout << "depth dependent: " << (depth_dependent_ ? "true\n" : "false\n");
-      unsigned char red [6] = {255,   0,   0, 255, 255,   0};
-      unsigned char grn [6] = {  0, 255,   0, 255,   0, 255};
-      unsigned char blu [6] = {  0,   0, 255,   0, 255, 255};
-
-      pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
-      ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-      ne.setMaxDepthChangeFactor (0.02f);
-      ne.setNormalSmoothingSize (20.0f);
-      
-      typename pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>::Ptr refinement_compare (new pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label> ());
-      refinement_compare->setDistanceThreshold (threshold_, depth_dependent_);
-      
-      pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
-      mps.setMinInliers (5000);
-      mps.setAngularThreshold (0.017453 * 3.0); //3 degrees
-      mps.setDistanceThreshold (0.03); //2cm
-      mps.setRefinementComparator (refinement_compare);
-      
-      std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > regions;
-      typename pcl::PointCloud<PointT>::Ptr contour (new pcl::PointCloud<PointT>);
-      typename pcl::PointCloud<PointT>::Ptr approx_contour (new pcl::PointCloud<PointT>);
-      char name[1024];
-
-      typename pcl::PointCloud<pcl::Normal>::Ptr normal_cloud (new pcl::PointCloud<pcl::Normal>);
-      double normal_start = pcl::getTime ();
-      ne.setInputCloud (cloud);
-      ne.compute (*normal_cloud);
-      double normal_end = pcl::getTime ();
-      std::cout << "Normal Estimation took " << double (normal_end - normal_start) << std::endl;
-
-      double plane_extract_start = pcl::getTime ();
-      mps.setInputNormals (normal_cloud);
-      mps.setInputCloud (cloud);
-      if (refine_)
-        mps.segmentAndRefine (regions);
-      else
-        mps.segment (regions);
-      double plane_extract_end = pcl::getTime ();
-      std::cout << "Plane extraction took " << double (plane_extract_end - plane_extract_start) << " with planar regions found: " << regions.size () << std::endl;
-      std::cout << "Frame took " << double (plane_extract_end - normal_start) << std::endl;
-
-      typename pcl::PointCloud<PointT>::Ptr cluster (new pcl::PointCloud<PointT>);
-
-      viewer.removeAllPointClouds (0);
-      viewer.removeAllShapes (0);
-      pcl::visualization::PointCloudColorHandlerCustom<PointT> single_color (cloud, 0, 255, 0);
-      viewer.addPointCloud<PointT> (cloud, single_color, "cloud");
-      
-      pcl::PlanarPolygon<PointT> approx_polygon;
-      //Draw Visualization
-      for (std::size_t i = 0; i < regions.size (); i++)
-      {
-        Eigen::Vector3f centroid = regions[i].getCentroid ();
-        Eigen::Vector4f model = regions[i].getCoefficients ();
-        pcl::PointXYZ pt1 = pcl::PointXYZ (centroid[0], centroid[1], centroid[2]);
-        pcl::PointXYZ pt2 = pcl::PointXYZ (centroid[0] + (0.5f * model[0]),
-                                           centroid[1] + (0.5f * model[1]),
-                                           centroid[2] + (0.5f * model[2]));
-        sprintf (name, "normal_%d", unsigned (i));
-        viewer.addArrow (pt2, pt1, 1.0, 0, 0, std::string (name));
-
-        contour->points = regions[i].getContour ();        
-        sprintf (name, "plane_%02d", int (i));
-        pcl::visualization::PointCloudColorHandlerCustom <PointT> color (contour, red[i], grn[i], blu[i]);
-        viewer.addPointCloud (contour, color, name);
-
-        pcl::approximatePolygon (regions[i], approx_polygon, threshold_, polygon_refinement_);
-        approx_contour->points = approx_polygon.getContour ();
-        std::cout << "polygon: " << contour->size () << " -> " << approx_contour->size () << std::endl;
-        typename pcl::PointCloud<PointT>::ConstPtr approx_contour_const = approx_contour;
-        
-//        sprintf (name, "approx_plane_%02d", int (i));
-//        viewer.addPolygon<PointT> (approx_contour_const, 0.5 * red[i], 0.5 * grn[i], 0.5 * blu[i], name);
-        for (std::size_t idx = 0; idx < approx_contour->points.size (); ++idx)
-        {
-          sprintf (name, "approx_plane_%02d_%03d", int (i), int(idx));
-          viewer.addLine (approx_contour->points [idx], approx_contour->points [(idx+1)%approx_contour->points.size ()], 0.5 * red[i], 0.5 * grn[i], 0.5 * blu[i], name);
-        }
+  }
+
+  void
+  process()
+  {
+    std::cout << "threshold: " << threshold_ << std::endl;
+    std::cout << "depth dependent: " << (depth_dependent_ ? "true\n" : "false\n");
+    unsigned char red[6] = {255, 0, 0, 255, 255, 0};
+    unsigned char grn[6] = {0, 255, 0, 255, 0, 255};
+    unsigned char blu[6] = {0, 0, 255, 0, 255, 255};
+
+    pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
+    ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+    ne.setMaxDepthChangeFactor(0.02f);
+    ne.setNormalSmoothingSize(20.0f);
+
+    typename pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>::Ptr
+        refinement_compare(
+            new pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>());
+    refinement_compare->setDistanceThreshold(threshold_, depth_dependent_);
+
+    pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
+    mps.setMinInliers(5000);
+    mps.setAngularThreshold(0.017453 * 3.0); // 3 degrees
+    mps.setDistanceThreshold(0.03);          // 2cm
+    mps.setRefinementComparator(refinement_compare);
+
+    std::vector<pcl::PlanarRegion<PointT>,
+                Eigen::aligned_allocator<pcl::PlanarRegion<PointT>>>
+        regions;
+    typename pcl::PointCloud<PointT>::Ptr contour(new pcl::PointCloud<PointT>);
+    typename pcl::PointCloud<PointT>::Ptr approx_contour(new pcl::PointCloud<PointT>);
+    char name[1024];
+
+    typename pcl::PointCloud<pcl::Normal>::Ptr normal_cloud(
+        new pcl::PointCloud<pcl::Normal>);
+    double normal_start = pcl::getTime();
+    ne.setInputCloud(cloud);
+    ne.compute(*normal_cloud);
+    double normal_end = pcl::getTime();
+    std::cout << "Normal Estimation took " << double(normal_end - normal_start)
+              << std::endl;
+
+    double plane_extract_start = pcl::getTime();
+    mps.setInputNormals(normal_cloud);
+    mps.setInputCloud(cloud);
+    if (refine_)
+      mps.segmentAndRefine(regions);
+    else
+      mps.segment(regions);
+    double plane_extract_end = pcl::getTime();
+    std::cout << "Plane extraction took "
+              << double(plane_extract_end - plane_extract_start)
+              << " with planar regions found: " << regions.size() << std::endl;
+    std::cout << "Frame took " << double(plane_extract_end - normal_start) << std::endl;
+
+    typename pcl::PointCloud<PointT>::Ptr cluster(new pcl::PointCloud<PointT>);
+
+    viewer.removeAllPointClouds(0);
+    viewer.removeAllShapes(0);
+    pcl::visualization::PointCloudColorHandlerCustom<PointT> single_color(
+        cloud, 0, 255, 0);
+    viewer.addPointCloud<PointT>(cloud, single_color, "cloud");
+
+    pcl::PlanarPolygon<PointT> approx_polygon;
+    // Draw Visualization
+    for (std::size_t i = 0; i < regions.size(); i++) {
+      Eigen::Vector3f centroid = regions[i].getCentroid();
+      Eigen::Vector4f model = regions[i].getCoefficients();
+      pcl::PointXYZ pt1 = pcl::PointXYZ(centroid[0], centroid[1], centroid[2]);
+      pcl::PointXYZ pt2 = pcl::PointXYZ(centroid[0] + (0.5f * model[0]),
+                                        centroid[1] + (0.5f * model[1]),
+                                        centroid[2] + (0.5f * model[2]));
+      sprintf(name, "normal_%d", unsigned(i));
+      viewer.addArrow(pt2, pt1, 1.0, 0, 0, std::string(name));
+
+      contour->points = regions[i].getContour();
+      sprintf(name, "plane_%02d", int(i));
+      pcl::visualization::PointCloudColorHandlerCustom<PointT> color(
+          contour, red[i], grn[i], blu[i]);
+      viewer.addPointCloud(contour, color, name);
+
+      pcl::approximatePolygon(
+          regions[i], approx_polygon, threshold_, polygon_refinement_);
+      approx_contour->points = approx_polygon.getContour();
+      std::cout << "polygon: " << contour->size() << " -> " << approx_contour->size()
+                << std::endl;
+      typename pcl::PointCloud<PointT>::ConstPtr approx_contour_const = approx_contour;
+
+      for (std::size_t idx = 0; idx < approx_contour->points.size(); ++idx) {
+        sprintf(name, "approx_plane_%02d_%03d", int(i), int(idx));
+        viewer.addLine(
+            approx_contour->points[idx],
+            approx_contour->points[(idx + 1) % approx_contour->points.size()],
+            0.5 * red[i],
+            0.5 * grn[i],
+            0.5 * blu[i],
+            name);
       }
     }
-    
-    void
-    run ()
-    {
-      // initial processing
-      process ();
-    
-      while (!viewer.wasStopped ())
-        viewer.spinOnce (100);
-    }
+  }
+
+  void
+  run()
+  {
+    // initial processing
+    process();
+
+    while (!viewer.wasStopped())
+      viewer.spinOnce(100);
+  }
 };
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
-  bool refine = pcl::console::find_switch (argc, argv, "-refine");
-  
-  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz (new pcl::PointCloud<pcl::PointXYZ>);
-  pcl::io::loadPCDFile (argv[1], *cloud_xyz);
-  PCDOrganizedMultiPlaneSegmentation<pcl::PointXYZ> multi_plane_app (cloud_xyz, refine);
-  multi_plane_app.run ();
+  bool refine = pcl::console::find_switch(argc, argv, "-refine");
+
+  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz(new pcl::PointCloud<pcl::PointXYZ>);
+  pcl::io::loadPCDFile(argv[1], *cloud_xyz);
+  PCDOrganizedMultiPlaneSegmentation<pcl::PointXYZ> multi_plane_app(cloud_xyz, refine);
+  multi_plane_app.run();
   return 0;
 }
index d8564d128a4472b0ba0d8cacbbf9fe986c96028d..a4a4b32a5527bd5080e0ce3c9c54606d52bf07f1 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *
  */
 
-#include <thread>
-
-#include <pcl/common/common.h>
-#include <pcl/console/time.h>
 #include <pcl/common/angles.h>
-#include <pcl/console/print.h>
+#include <pcl/common/common.h>
 #include <pcl/console/parse.h>
-
-#include <pcl/io/pcd_io.h>
-
+#include <pcl/console/print.h>
+#include <pcl/console/time.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/features/normal_3d.h>
-
 #include <pcl/filters/extract_indices.h>
 #include <pcl/filters/project_inliers.h>
-
-#include <pcl/segmentation/organized_multi_plane_segmentation.h>
+#include <pcl/geometry/polygon_operations.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/segmentation/edge_aware_plane_comparator.h>
 #include <pcl/segmentation/euclidean_cluster_comparator.h>
+#include <pcl/segmentation/extract_clusters.h>
+#include <pcl/segmentation/extract_polygonal_prism_data.h>
 #include <pcl/segmentation/organized_connected_component_segmentation.h>
-#include <pcl/segmentation/edge_aware_plane_comparator.h>
+#include <pcl/segmentation/organized_multi_plane_segmentation.h>
 #include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/segmentation/extract_polygonal_prism_data.h>
-#include <pcl/segmentation/extract_clusters.h>
-
 #include <pcl/surface/convex_hull.h>
-
-#include <pcl/geometry/polygon_operations.h>
-
-#include <pcl/visualization/point_cloud_handlers.h>
-#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/image_viewer.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/visualization/point_cloud_handlers.h>
+
+#include <thread>
 
 using namespace pcl;
 using namespace pcl::console;
@@ -76,599 +69,641 @@ using namespace std::chrono_literals;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
-class ObjectSelection
-{
-  public:
-    ObjectSelection ()
-      : plane_comparator_ (new EdgeAwarePlaneComparator<PointT, Normal>)
-      , rgb_data_ ()
-    { 
-      // Set the parameters for planar segmentation
-      plane_comparator_->setDistanceThreshold (0.01f, false);
-    }
+class ObjectSelection {
+public:
+  ObjectSelection()
+  : plane_comparator_(new EdgeAwarePlaneComparator<PointT, Normal>), rgb_data_()
+  {
+    // Set the parameters for planar segmentation
+    plane_comparator_->setDistanceThreshold(0.01f, false);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  virtual ~ObjectSelection() { delete[] rgb_data_; }
 
-    /////////////////////////////////////////////////////////////////////////
-    virtual ~ObjectSelection ()
-    {
-      if (rgb_data_)
-        delete[] rgb_data_;
+  /////////////////////////////////////////////////////////////////////////
+  void
+  estimateNormals(const typename PointCloud<PointT>::ConstPtr& input,
+                  PointCloud<Normal>& normals)
+  {
+    if (input->isOrganized()) {
+      IntegralImageNormalEstimation<PointT, Normal> ne;
+      // Set the parameters for normal estimation
+      ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+      ne.setMaxDepthChangeFactor(0.02f);
+      ne.setNormalSmoothingSize(20.0f);
+      // Estimate normals in the cloud
+      ne.setInputCloud(input);
+      ne.compute(normals);
+
+      // Save the distance map for the plane comparator
+      float* map = ne.getDistanceMap(); // This will be deallocated with the
+                                        // IntegralImageNormalEstimation object...
+      distance_map_.assign(map, map + input->size()); //...so we must copy the data out
+      plane_comparator_->setDistanceMap(distance_map_.data());
+    }
+    else {
+      NormalEstimation<PointT, Normal> ne;
+      ne.setInputCloud(input);
+      ne.setRadiusSearch(0.02f);
+      ne.setSearchMethod(search_);
+      ne.compute(normals);
     }
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    estimateNormals (const typename PointCloud<PointT>::ConstPtr &input, PointCloud<Normal> &normals)
-    {
-      if (input->isOrganized ())
-      {
-        IntegralImageNormalEstimation<PointT, Normal> ne;
-        // Set the parameters for normal estimation
-        ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-        ne.setMaxDepthChangeFactor (0.02f);
-        ne.setNormalSmoothingSize (20.0f);
-        // Estimate normals in the cloud
-        ne.setInputCloud (input);
-        ne.compute (normals);
-
-        // Save the distance map for the plane comparator
-        float *map=ne.getDistanceMap ();// This will be deallocated with the IntegralImageNormalEstimation object...
-        distance_map_.assign(map, map+input->size() ); //...so we must copy the data out
-        plane_comparator_->setDistanceMap(distance_map_.data());
-      }
-      else
-      {
-        NormalEstimation<PointT, Normal> ne;
-        ne.setInputCloud (input);
-        ne.setRadiusSearch (0.02f);
-        ne.setSearchMethod (search_);
-        ne.compute (normals);
-      }
+  /////////////////////////////////////////////////////////////////////////
+  void
+  keyboard_callback(const visualization::KeyboardEvent&, void*)
+  {
+    // if (event.getKeyCode())
+    //  std::cout << "the key \'" << event.getKeyCode() << "\' (" << event.getKeyCode()
+    //  << ") was";
+    // else
+    //  std::cout << "the special key \'" << event.getKeySym() << "\' was";
+    // if (event.keyDown())
+    //  std::cout << " pressed" << std::endl;
+    // else
+    //  std::cout << " released" << std::endl;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  mouse_callback(const visualization::MouseEvent& mouse_event, void*)
+  {
+    if (mouse_event.getType() == visualization::MouseEvent::MouseButtonPress &&
+        mouse_event.getButton() == visualization::MouseEvent::LeftButton) {
+      std::cout << "left button pressed @ " << mouse_event.getX() << " , "
+                << mouse_event.getY() << std::endl;
     }
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void 
-    keyboard_callback (const visualization::KeyboardEvent&, void*)
-    {
-      //if (event.getKeyCode())
-      //  std::cout << "the key \'" << event.getKeyCode() << "\' (" << event.getKeyCode() << ") was";
-      //else
-      //  std::cout << "the special key \'" << event.getKeySym() << "\' was";
-      //if (event.keyDown())
-      //  std::cout << " pressed" << std::endl;
-      //else
-      //  std::cout << " released" << std::endl;
+  /////////////////////////////////////////////////////////////////////////
+  /** \brief
+   * Given a plane, and the set of inlier indices representing it,
+   * segment out the object of intererest supported by it.
+   *
+   * \param[in] picked_idx the index of a point on the object
+   * \param[in] cloud the full point cloud dataset
+   * \param[in] plane_indices a set of indices representing the plane supporting the
+   * object of interest
+   * \param[out] object the segmented resultant object
+   * \param[out] object the segmented resultant object
+   */
+  void
+  segmentObject(int picked_idx,
+                const typename PointCloud<PointT>::ConstPtr& cloud,
+                const PointIndices::Ptr& plane_indices,
+                PointCloud<PointT>& object)
+  {
+    typename PointCloud<PointT>::Ptr plane_hull(new PointCloud<PointT>);
+
+    // Compute the convex hull of the plane
+    ConvexHull<PointT> chull;
+    chull.setDimension(2);
+    chull.setInputCloud(cloud);
+    chull.setIndices(plane_indices);
+    chull.reconstruct(*plane_hull);
+
+    // Remove the plane indices from the data
+    typename PointCloud<PointT>::Ptr plane(new PointCloud<PointT>);
+    ExtractIndices<PointT> extract(true);
+    extract.setInputCloud(cloud);
+    extract.setIndices(plane_indices);
+    extract.setNegative(false);
+    extract.filter(*plane);
+    PointIndices::Ptr indices_but_the_plane(new PointIndices);
+    extract.getRemovedIndices(*indices_but_the_plane);
+
+    // Extract all clusters above the hull
+    PointIndices::Ptr points_above_plane(new PointIndices);
+    ExtractPolygonalPrismData<PointT> exppd;
+    exppd.setInputCloud(cloud);
+    exppd.setIndices(indices_but_the_plane);
+    exppd.setInputPlanarHull(plane_hull);
+    exppd.setViewPoint(cloud->points[picked_idx].x,
+                       cloud->points[picked_idx].y,
+                       cloud->points[picked_idx].z);
+    exppd.setHeightLimits(0.001, 0.5); // up to half a meter
+    exppd.segment(*points_above_plane);
+
+    std::vector<PointIndices> euclidean_label_indices;
+    // Prefer a faster method if the cloud is organized, over EuclidanClusterExtraction
+    if (cloud_->isOrganized()) {
+      // Use an organized clustering segmentation to extract the individual clusters
+      typename EuclideanClusterComparator<PointT, Label>::Ptr
+          euclidean_cluster_comparator(new EuclideanClusterComparator<PointT, Label>);
+      euclidean_cluster_comparator->setInputCloud(cloud);
+      euclidean_cluster_comparator->setDistanceThreshold(0.03f, false);
+      // Set the entire scene to false, and the inliers of the objects located on top of
+      // the plane to true
+      Label l;
+      l.label = 0;
+      PointCloud<Label>::Ptr scene(
+          new PointCloud<Label>(cloud->width, cloud->height, l));
+      // Mask the objects that we want to split into clusters
+      for (const int& index : points_above_plane->indices)
+        scene->points[index].label = 1;
+      euclidean_cluster_comparator->setLabels(scene);
+
+      typename EuclideanClusterComparator<PointT, Label>::ExcludeLabelSetPtr
+          exclude_labels(
+              new typename EuclideanClusterComparator<PointT, Label>::ExcludeLabelSet);
+      exclude_labels->insert(0);
+      euclidean_cluster_comparator->setExcludeLabels(exclude_labels);
+
+      OrganizedConnectedComponentSegmentation<PointT, Label> euclidean_segmentation(
+          euclidean_cluster_comparator);
+      euclidean_segmentation.setInputCloud(cloud);
+
+      PointCloud<Label> euclidean_labels;
+      euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices);
     }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void 
-    mouse_callback (const visualization::MouseEvent& mouse_event, void*)
-    {
-      if (mouse_event.getType() == visualization::MouseEvent::MouseButtonPress && mouse_event.getButton() == visualization::MouseEvent::LeftButton)
-      {
-        std::cout << "left button pressed @ " << mouse_event.getX () << " , " << mouse_event.getY () << std::endl;
-      }
+    else {
+      print_highlight(
+          stderr,
+          "Extracting individual clusters from the points above the reference plane ");
+      TicToc tt;
+      tt.tic();
+
+      EuclideanClusterExtraction<PointT> ec;
+      ec.setClusterTolerance(0.02); // 2cm
+      ec.setMinClusterSize(100);
+      ec.setSearchMethod(search_);
+      ec.setInputCloud(cloud);
+      ec.setIndices(points_above_plane);
+      ec.extract(euclidean_label_indices);
+
+      print_info("[done, ");
+      print_value("%g", tt.toc());
+      print_info(" ms : ");
+      print_value("%lu", euclidean_label_indices.size());
+      print_info(" clusters]\n");
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    /** \brief Given a plane, and the set of inlier indices representing it,
-      * segment out the object of intererest supported by it. 
-      *
-      * \param[in] picked_idx the index of a point on the object
-      * \param[in] cloud the full point cloud dataset
-      * \param[in] plane_indices a set of indices representing the plane supporting the object of interest
-      * \param[out] object the segmented resultant object 
-      */
-    void
-    segmentObject (int picked_idx, 
-                   const typename PointCloud<PointT>::ConstPtr &cloud, 
-                   const PointIndices::Ptr &plane_indices, 
-                   PointCloud<PointT> &object)
-    {
-      typename PointCloud<PointT>::Ptr plane_hull (new PointCloud<PointT>);
-
-      // Compute the convex hull of the plane
-      ConvexHull<PointT> chull;
-      chull.setDimension (2);
-      chull.setInputCloud (cloud);
-      chull.setIndices (plane_indices);
-      chull.reconstruct (*plane_hull);
-
-      // Remove the plane indices from the data
-      typename PointCloud<PointT>::Ptr plane (new PointCloud<PointT>);
-      ExtractIndices<PointT> extract (true);
-      extract.setInputCloud (cloud);
-      extract.setIndices (plane_indices);
-      extract.setNegative (false);
-      extract.filter (*plane);
-      PointIndices::Ptr indices_but_the_plane (new PointIndices);
-      extract.getRemovedIndices (*indices_but_the_plane);
-
-      // Extract all clusters above the hull
-      PointIndices::Ptr points_above_plane (new PointIndices);
-      ExtractPolygonalPrismData<PointT> exppd;
-      exppd.setInputCloud (cloud);
-      exppd.setIndices (indices_but_the_plane);
-      exppd.setInputPlanarHull (plane_hull);
-      exppd.setViewPoint (cloud->points[picked_idx].x, cloud->points[picked_idx].y, cloud->points[picked_idx].z);
-      exppd.setHeightLimits (0.001, 0.5);           // up to half a meter
-      exppd.segment (*points_above_plane);
-
-      std::vector<PointIndices> euclidean_label_indices;
-      // Prefer a faster method if the cloud is organized, over EuclidanClusterExtraction
-      if (cloud_->isOrganized ())
-      {
-        // Use an organized clustering segmentation to extract the individual clusters
-        typename EuclideanClusterComparator<PointT, Label>::Ptr euclidean_cluster_comparator (new EuclideanClusterComparator<PointT, Label>);
-        euclidean_cluster_comparator->setInputCloud (cloud);
-        euclidean_cluster_comparator->setDistanceThreshold (0.03f, false);
-        // Set the entire scene to false, and the inliers of the objects located on top of the plane to true
-        Label l; l.label = 0;
-        PointCloud<Label>::Ptr scene (new PointCloud<Label> (cloud->width, cloud->height, l));
-        // Mask the objects that we want to split into clusters
-        for (const int &index : points_above_plane->indices)
-          scene->points[index].label = 1;
-        euclidean_cluster_comparator->setLabels (scene);
-
-        typename EuclideanClusterComparator<PointT, Label>::ExcludeLabelSetPtr exclude_labels (new typename EuclideanClusterComparator<PointT, Label>::ExcludeLabelSet);
-        exclude_labels->insert (0);
-        euclidean_cluster_comparator->setExcludeLabels (exclude_labels);
-
-        OrganizedConnectedComponentSegmentation<PointT, Label> euclidean_segmentation (euclidean_cluster_comparator);
-        euclidean_segmentation.setInputCloud (cloud);
-
-        PointCloud<Label> euclidean_labels;
-        euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices);
-      }
-      else
-      {
-        print_highlight (stderr, "Extracting individual clusters from the points above the reference plane ");
-        TicToc tt; tt.tic ();
-
-        EuclideanClusterExtraction<PointT> ec;
-        ec.setClusterTolerance (0.02); // 2cm
-        ec.setMinClusterSize (100);
-        ec.setSearchMethod (search_);
-        ec.setInputCloud (cloud);
-        ec.setIndices (points_above_plane);
-        ec.extract (euclidean_label_indices);
-        
-        print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%lu", euclidean_label_indices.size ()); print_info (" clusters]\n");
-      }
-
-      // For each cluster found
-      bool cluster_found = false;
-      for (const auto &euclidean_label_index : euclidean_label_indices)
-      {
-        if (cluster_found)
-          break;
-        // Check if the point that we picked belongs to it
-        for (std::size_t j = 0; j < euclidean_label_index.indices.size (); ++j)
-        {
-          if (picked_idx != euclidean_label_index.indices[j])
-            continue;
-          copyPointCloud (*cloud, euclidean_label_index.indices, object);
-          cluster_found = true;
-          break;
-        }
+    // For each cluster found
+    bool cluster_found = false;
+    for (const auto& euclidean_label_index : euclidean_label_indices) {
+      if (cluster_found)
+        break;
+      // Check if the point that we picked belongs to it
+      for (std::size_t j = 0; j < euclidean_label_index.indices.size(); ++j) {
+        if (picked_idx != euclidean_label_index.indices[j])
+          continue;
+        copyPointCloud(*cloud, euclidean_label_index.indices, object);
+        cluster_found = true;
+        break;
       }
     }
+  }
 
-    /////////////////////////////////////////////////////////////////////////
-    void
-    segment (const PointT &picked_point, 
-             int picked_idx,
-             PlanarRegion<PointT> &region,
-             typename PointCloud<PointT>::Ptr &object)
-    {
-      object.reset ();
-
-      // Segment out all planes
-      std::vector<ModelCoefficients> model_coefficients;
-      std::vector<PointIndices> inlier_indices, boundary_indices;
-      std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT> > > regions;
-
-      // Prefer a faster method if the cloud is organized, over RANSAC
-      if (cloud_->isOrganized ())
-      {
-        print_highlight (stderr, "Estimating normals ");
-        TicToc tt; tt.tic ();
-        // Estimate normals
-        PointCloud<Normal>::Ptr normal_cloud (new PointCloud<Normal>);
-        estimateNormals (cloud_, *normal_cloud);
-        print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%lu", normal_cloud->size ()); print_info (" points]\n");
-
-        OrganizedMultiPlaneSegmentation<PointT, Normal, Label> mps;
-        mps.setMinInliers (1000);
-        mps.setAngularThreshold (deg2rad (3.0)); // 3 degrees
-        mps.setDistanceThreshold (0.03); // 2 cm
-        mps.setMaximumCurvature (0.001); // a small curvature
-        mps.setProjectPoints (true);
-        mps.setComparator (plane_comparator_);
-        mps.setInputNormals (normal_cloud);
-        mps.setInputCloud (cloud_);
-
-        // Use one of the overloaded segmentAndRefine calls to get all the information that we want out
-        PointCloud<Label>::Ptr labels (new PointCloud<Label>);
-        std::vector<PointIndices> label_indices;
-        mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);
-      }
-      else
-      {
-        SACSegmentation<PointT> seg;
-        seg.setOptimizeCoefficients (true);
-        seg.setModelType (SACMODEL_PLANE);
-        seg.setMethodType (SAC_RANSAC);
-        seg.setMaxIterations (10000);
-        seg.setDistanceThreshold (0.005);
-
-        // Copy XYZ and Normals to a new cloud
-        typename PointCloud<PointT>::Ptr cloud_segmented (new PointCloud<PointT> (*cloud_));
-        typename PointCloud<PointT>::Ptr cloud_remaining (new PointCloud<PointT>);
-
-        ModelCoefficients coefficients;
-        ExtractIndices<PointT> extract;
-        PointIndices::Ptr inliers (new PointIndices ());
-
-        // Up until 30% of the original cloud is left
-        int i = 1;
-        while (double (cloud_segmented->size ()) > 0.3 * double (cloud_->size ()))
-        {
-          seg.setInputCloud (cloud_segmented);
-
-          print_highlight (stderr, "Searching for the largest plane (%2.0d) ", i++);
-          TicToc tt; tt.tic ();
-          seg.segment (*inliers, coefficients);
-          print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%lu", inliers->indices.size ()); print_info (" points]\n");
-          // No datasets could be found anymore
-          if (inliers->indices.empty ())
-            break;
-
-          // Save this plane
-          PlanarRegion<PointT> region;
-          region.setCoefficients (coefficients);
-          regions.push_back (region);
-
-          inlier_indices.push_back (*inliers);
-          model_coefficients.push_back (coefficients);
-
-          // Extract the outliers
-          extract.setInputCloud (cloud_segmented);
-          extract.setIndices (inliers);
-          extract.setNegative (true);
-          extract.filter (*cloud_remaining);
-          cloud_segmented.swap (cloud_remaining);
-        }
-      }
-      print_highlight ("Number of planar regions detected: %lu for a cloud of %lu points\n", regions.size (), cloud_->size ());
-
-      double max_dist = std::numeric_limits<double>::max ();
-      // Compute the distances from all the planar regions to the picked point, and select the closest region
-      int idx = -1;
-      for (std::size_t i = 0; i < regions.size (); ++i)
-      {
-        double dist = pointToPlaneDistance (picked_point, regions[i].getCoefficients ()); 
-        if (dist < max_dist)
-        {
-          max_dist = dist;
-          idx = static_cast<int> (i);
-        }
-      }
+  /////////////////////////////////////////////////////////////////////////
+  void
+  segment(const PointT& picked_point,
+          int picked_idx,
+          PlanarRegion<PointT>& region,
+          typename PointCloud<PointT>::Ptr& object)
+  {
+    object.reset();
+
+    // Segment out all planes
+    std::vector<ModelCoefficients> model_coefficients;
+    std::vector<PointIndices> inlier_indices, boundary_indices;
+    std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT>>>
+        regions;
+
+    // Prefer a faster method if the cloud is organized, over RANSAC
+    if (cloud_->isOrganized()) {
+      print_highlight(stderr, "Estimating normals ");
+      TicToc tt;
+      tt.tic();
+      // Estimate normals
+      PointCloud<Normal>::Ptr normal_cloud(new PointCloud<Normal>);
+      estimateNormals(cloud_, *normal_cloud);
+      print_info("[done, ");
+      print_value("%g", tt.toc());
+      print_info(" ms : ");
+      print_value("%lu", normal_cloud->size());
+      print_info(" points]\n");
+
+      OrganizedMultiPlaneSegmentation<PointT, Normal, Label> mps;
+      mps.setMinInliers(1000);
+      mps.setAngularThreshold(deg2rad(3.0)); // 3 degrees
+      mps.setDistanceThreshold(0.03);        // 2 cm
+      mps.setMaximumCurvature(0.001);        // a small curvature
+      mps.setProjectPoints(true);
+      mps.setComparator(plane_comparator_);
+      mps.setInputNormals(normal_cloud);
+      mps.setInputCloud(cloud_);
+
+      // Use one of the overloaded segmentAndRefine calls to get all the information
+      // that we want out
+      PointCloud<Label>::Ptr labels(new PointCloud<Label>);
+      std::vector<PointIndices> label_indices;
+      mps.segmentAndRefine(regions,
+                           model_coefficients,
+                           inlier_indices,
+                           labels,
+                           label_indices,
+                           boundary_indices);
+    }
+    else {
+      SACSegmentation<PointT> seg;
+      seg.setOptimizeCoefficients(true);
+      seg.setModelType(SACMODEL_PLANE);
+      seg.setMethodType(SAC_RANSAC);
+      seg.setMaxIterations(10000);
+      seg.setDistanceThreshold(0.005);
+
+      // Copy XYZ and Normals to a new cloud
+      typename PointCloud<PointT>::Ptr cloud_segmented(new PointCloud<PointT>(*cloud_));
+      typename PointCloud<PointT>::Ptr cloud_remaining(new PointCloud<PointT>);
+
+      ModelCoefficients coefficients;
+      ExtractIndices<PointT> extract;
+      PointIndices::Ptr inliers(new PointIndices());
+
+      // Up until 30% of the original cloud is left
+      int i = 1;
+      while (double(cloud_segmented->size()) > 0.3 * double(cloud_->size())) {
+        seg.setInputCloud(cloud_segmented);
+
+        print_highlight(stderr, "Searching for the largest plane (%2.0d) ", i++);
+        TicToc tt;
+        tt.tic();
+        seg.segment(*inliers, coefficients);
+        print_info("[done, ");
+        print_value("%g", tt.toc());
+        print_info(" ms : ");
+        print_value("%lu", inliers->indices.size());
+        print_info(" points]\n");
+
+        // No datasets could be found anymore
+        if (inliers->indices.empty())
+          break;
 
-      // Get the plane that holds the object of interest
-      if (idx != -1)
-      {
-        plane_indices_.reset (new PointIndices (inlier_indices[idx]));
+        // Save this plane
+        PlanarRegion<PointT> region;
+        region.setCoefficients(coefficients);
+        regions.push_back(region);
 
-        if (cloud_->isOrganized ())
-        {
-          approximatePolygon (regions[idx], region, 0.01f, false, true);
-          print_highlight ("Planar region: %lu points initial, %lu points after refinement.\n", regions[idx].getContour ().size (), region.getContour ().size ());
-        }
-        else
-        {
-          // Save the current region
-          region = regions[idx]; 
-
-          print_highlight (stderr, "Obtaining the boundary points for the region ");
-          TicToc tt; tt.tic ();
-          // Project the inliers to obtain a better hull
-          typename PointCloud<PointT>::Ptr cloud_projected (new PointCloud<PointT>);
-          ModelCoefficients::Ptr coefficients (new ModelCoefficients (model_coefficients[idx]));
-          ProjectInliers<PointT> proj;
-          proj.setModelType (SACMODEL_PLANE);
-          proj.setInputCloud (cloud_);
-          proj.setIndices (plane_indices_);
-          proj.setModelCoefficients (coefficients);
-          proj.filter (*cloud_projected);
-
-          // Compute the boundary points as a ConvexHull
-          ConvexHull<PointT> chull;
-          chull.setDimension (2);
-          chull.setInputCloud (cloud_projected);
-          PointCloud<PointT> plane_hull;
-          chull.reconstruct (plane_hull);
-          region.setContour (plane_hull);
-          print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%lu", plane_hull.size ()); print_info (" points]\n");
-        }
+        inlier_indices.push_back(*inliers);
+        model_coefficients.push_back(coefficients);
 
+        // Extract the outliers
+        extract.setInputCloud(cloud_segmented);
+        extract.setIndices(inliers);
+        extract.setNegative(true);
+        extract.filter(*cloud_remaining);
+        cloud_segmented.swap(cloud_remaining);
       }
-
-      // Segment the object of interest
-      if (plane_indices_ && !plane_indices_->indices.empty ())
-      {
-        plane_.reset (new PointCloud<PointT>);
-        copyPointCloud (*cloud_, plane_indices_->indices, *plane_);
-        object.reset (new PointCloud<PointT>);
-        segmentObject (picked_idx, cloud_, plane_indices_, *object);
+    }
+    print_highlight(
+        "Number of planar regions detected: %lu for a cloud of %lu points\n",
+        regions.size(),
+        cloud_->size());
+
+    double max_dist = std::numeric_limits<double>::max();
+    // Compute the distances from all the planar regions to the picked point, and select
+    // the closest region
+    int idx = -1;
+    for (std::size_t i = 0; i < regions.size(); ++i) {
+      double dist = pointToPlaneDistance(picked_point, regions[i].getCoefficients());
+      if (dist < max_dist) {
+        max_dist = dist;
+        idx = static_cast<int>(i);
       }
     }
 
-    /////////////////////////////////////////////////////////////////////////
-    /** \brief Point picking callback. This gets called when the user selects
-      * a 3D point on screen (in the PCLVisualizer window) using Shift+click.
-      *
-      * \param[in] event the event that triggered the call
-      */
-    void 
-    pp_callback (const visualization::PointPickingEvent& event, void*)
-    {
-      // Check to see if we got a valid point. Early exit.
-      int idx = event.getPointIndex ();
-      if (idx == -1)
-        return;
-
-      std::vector<int> indices (1);
-      std::vector<float> distances (1);
-
-      // Get the point that was picked
-      PointT picked_pt;
-      event.getPoint (picked_pt.x, picked_pt.y, picked_pt.z);
-
-      print_info (stderr, "Picked point with index %d, and coordinates %f, %f, %f.\n", idx, picked_pt.x, picked_pt.y, picked_pt.z);
-
-      // Add a sphere to it in the PCLVisualizer window
-      stringstream ss;
-      ss << "sphere_" << idx;
-      cloud_viewer_->addSphere (picked_pt, 0.01, 1.0, 0.0, 0.0, ss.str ());
-
-      // Because VTK/OpenGL stores data without NaN, we lose the 1-1 correspondence, so we must search for the real point
-      search_->nearestKSearch (picked_pt, 1, indices, distances);
-
-      // Add some marker to the image
-      if (image_viewer_)
-      {
-        // Get the [u, v] in pixel coordinates for the ImageViewer. Remember that 0,0 is bottom left.
-        std::uint32_t width  = search_->getInputCloud ()->width,
-                 height = search_->getInputCloud ()->height;
-        int v = height - indices[0] / width,
-            u = indices[0] % width;
-
-        image_viewer_->addCircle (u, v, 5, 1.0, 0.0, 0.0, "circles", 1.0);
-        image_viewer_->addFilledRectangle (u-5, u+5, v-5, v+5, 0.0, 1.0, 0.0, "boxes", 0.5);
-        image_viewer_->markPoint (u, v, visualization::red_color, visualization::blue_color, 10);
-      }
+    // Get the plane that holds the object of interest
+    if (idx != -1) {
+      plane_indices_.reset(new PointIndices(inlier_indices[idx]));
 
-      // Segment the region that we're interested in, by employing a two step process:
-      //  * first, segment all the planes in the scene, and find the one closest to our picked point
-      //  * then, use euclidean clustering to find the object that we clicked on and return it
-      PlanarRegion<PointT> region;
-      segment (picked_pt, indices[0], region, object_);
-
-      // If no region could be determined, exit
-      if (region.getContour ().empty ())
-      {
-        PCL_ERROR ("No planar region detected. Please select another point or relax the thresholds and continue.\n");
-        return;
+      if (cloud_->isOrganized()) {
+        approximatePolygon(regions[idx], region, 0.01f, false, true);
+        print_highlight(
+            "Planar region: %lu points initial, %lu points after refinement.\n",
+            regions[idx].getContour().size(),
+            region.getContour().size());
       }
-      // Else, draw it on screen
-      cloud_viewer_->addPolygon (region, 0.0, 0.0, 1.0, "region");
-      cloud_viewer_->setShapeRenderingProperties (visualization::PCL_VISUALIZER_LINE_WIDTH, 10, "region");
-
-      // Draw in image space
-      if (image_viewer_)
-      {
-        image_viewer_->addPlanarPolygon (search_->getInputCloud (), region, 0.0, 0.0, 1.0, "refined_region", 1.0);
+      else {
+        // Save the current region
+        region = regions[idx];
+
+        print_highlight(stderr, "Obtaining the boundary points for the region ");
+        TicToc tt;
+        tt.tic();
+        // Project the inliers to obtain a better hull
+        typename PointCloud<PointT>::Ptr cloud_projected(new PointCloud<PointT>);
+        ModelCoefficients::Ptr coefficients(
+            new ModelCoefficients(model_coefficients[idx]));
+        ProjectInliers<PointT> proj;
+        proj.setModelType(SACMODEL_PLANE);
+        proj.setInputCloud(cloud_);
+        proj.setIndices(plane_indices_);
+        proj.setModelCoefficients(coefficients);
+        proj.filter(*cloud_projected);
+
+        // Compute the boundary points as a ConvexHull
+        ConvexHull<PointT> chull;
+        chull.setDimension(2);
+        chull.setInputCloud(cloud_projected);
+        PointCloud<PointT> plane_hull;
+        chull.reconstruct(plane_hull);
+        region.setContour(plane_hull);
+        print_info("[done, ");
+        print_value("%g", tt.toc());
+        print_info(" ms : ");
+        print_value("%lu", plane_hull.size());
+        print_info(" points]\n");
       }
+    }
 
-      // If no object could be determined, exit
-      if (!object_)
-      {
-        PCL_ERROR ("No object detected. Please select another point or relax the thresholds and continue.\n");
-        return;
-      }
-      // Visualize the object in 3D...
-      visualization::PointCloudColorHandlerCustom<PointT> red (object_, 255, 0, 0);
-      if (!cloud_viewer_->updatePointCloud (object_, red, "object"))
-        cloud_viewer_->addPointCloud (object_, red, "object");
-      // ...and 2D
-      if (image_viewer_)
-      {
-        image_viewer_->removeLayer ("object");
-        image_viewer_->addMask (search_->getInputCloud (), *object_, "object");
-      }
+    // Segment the object of interest
+    if (plane_indices_ && !plane_indices_->indices.empty()) {
+      plane_.reset(new PointCloud<PointT>);
+      copyPointCloud(*cloud_, plane_indices_->indices, *plane_);
+      object.reset(new PointCloud<PointT>);
+      segmentObject(picked_idx, cloud_, plane_indices_, *object);
+    }
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  /**
+   * \brief Point picking callback. This gets called when the user selects
+   * a 3D point on screen (in the PCLVisualizer window) using Shift+click.
+   *
+   * \param[in] event the event that triggered the call
+   */
+  void
+  pp_callback(const visualization::PointPickingEvent& event, void*)
+  {
+    // Check to see if we got a valid point. Early exit.
+    int idx = event.getPointIndex();
+    if (idx == -1)
+      return;
+
+    std::vector<int> indices(1);
+    std::vector<float> distances(1);
+
+    // Get the point that was picked
+    PointT picked_pt;
+    event.getPoint(picked_pt.x, picked_pt.y, picked_pt.z);
+
+    print_info(stderr,
+               "Picked point with index %d, and coordinates %f, %f, %f.\n",
+               idx,
+               picked_pt.x,
+               picked_pt.y,
+               picked_pt.z);
+
+    // Add a sphere to it in the PCLVisualizer window
+    stringstream ss;
+    ss << "sphere_" << idx;
+    cloud_viewer_->addSphere(picked_pt, 0.01, 1.0, 0.0, 0.0, ss.str());
+
+    // Because VTK/OpenGL stores data without NaN, we lose the 1-1 correspondence, so we
+    // must search for the real point
+    search_->nearestKSearch(picked_pt, 1, indices, distances);
+
+    // Add some marker to the image
+    if (image_viewer_) {
+      // Get the [u, v] in pixel coordinates for the ImageViewer. Remember that 0,0 is
+      // bottom left.
+      std::uint32_t width = search_->getInputCloud()->width,
+                    height = search_->getInputCloud()->height;
+      int v = height - indices[0] / width, u = indices[0] % width;
+
+      image_viewer_->addCircle(u, v, 5, 1.0, 0.0, 0.0, "circles", 1.0);
+      image_viewer_->addFilledRectangle(
+          u - 5, u + 5, v - 5, v + 5, 0.0, 1.0, 0.0, "boxes", 0.5);
+      image_viewer_->markPoint(
+          u, v, visualization::red_color, visualization::blue_color, 10);
+    }
 
-      // ...and 2D
-      if (image_viewer_)
-        image_viewer_->addRectangle (search_->getInputCloud (), *object_);
+    // Segment the region that we're interested in, by employing a two step process:
+    //  * first, segment all the planes in the scene, and find the one closest to our
+    //  picked point
+    //  * then, use euclidean clustering to find the object that we clicked on and
+    //  return it
+    PlanarRegion<PointT> region;
+    segment(picked_pt, indices[0], region, object_);
+
+    // If no region could be determined, exit
+    if (region.getContour().empty()) {
+      PCL_ERROR("No planar region detected. Please select another point or relax the "
+                "thresholds and continue.\n");
+      return;
     }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    compute ()
-    {
-      // Visualize the data
-      while (!cloud_viewer_->wasStopped ())
-      {
-        /*// Add the plane that we're tracking to the cloud visualizer
-        PointCloud<PointT>::Ptr plane (new Cloud);
-        if (plane_)
-          *plane = *plane_;
-        visualization::PointCloudColorHandlerCustom<PointT> blue (plane, 0, 255, 0);
-        if (!cloud_viewer_->updatePointCloud (plane, blue, "plane"))
-          cloud_viewer_->addPointCloud (plane, "plane");
+    // Else, draw it on screen
+    cloud_viewer_->addPolygon(region, 0.0, 0.0, 1.0, "region");
+    cloud_viewer_->setShapeRenderingProperties(
+        visualization::PCL_VISUALIZER_LINE_WIDTH, 10, "region");
+
+    // Draw in image space
+    if (image_viewer_) {
+      image_viewer_->addPlanarPolygon(
+          search_->getInputCloud(), region, 0.0, 0.0, 1.0, "refined_region", 1.0);
+    }
+
+    // If no object could be determined, exit
+    if (!object_) {
+      PCL_ERROR("No object detected. Please select another point or relax the "
+                "thresholds and continue.\n");
+      return;
+    }
+    // Visualize the object in 3D...
+    visualization::PointCloudColorHandlerCustom<PointT> red(object_, 255, 0, 0);
+    if (!cloud_viewer_->updatePointCloud(object_, red, "object"))
+      cloud_viewer_->addPointCloud(object_, red, "object");
+    // ...and 2D
+    if (image_viewer_) {
+      image_viewer_->removeLayer("object");
+      image_viewer_->addMask(search_->getInputCloud(), *object_, "object");
+    }
+
+    // ...and 2D
+    if (image_viewer_)
+      image_viewer_->addRectangle(search_->getInputCloud(), *object_);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  compute()
+  {
+    // Visualize the data
+    while (!cloud_viewer_->wasStopped()) {
+      /*// Add the plane that we're tracking to the cloud visualizer
+      PointCloud<PointT>::Ptr plane (new Cloud);
+      if (plane_)
+        *plane = *plane_;
+      visualization::PointCloudColorHandlerCustom<PointT> blue (plane, 0, 255, 0);
+      if (!cloud_viewer_->updatePointCloud (plane, blue, "plane"))
+        cloud_viewer_->addPointCloud (plane, "plane");
 */
-        cloud_viewer_->spinOnce ();
-        if (image_viewer_)
-        {
-          image_viewer_->spinOnce ();
-          if (image_viewer_->wasStopped ())
-            break;
-        }
-        std::this_thread::sleep_for(100us);
+      cloud_viewer_->spinOnce();
+      if (image_viewer_) {
+        image_viewer_->spinOnce();
+        if (image_viewer_->wasStopped())
+          break;
       }
+      std::this_thread::sleep_for(100us);
     }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    initGUI ()
-    {
-      cloud_viewer_.reset (new visualization::PCLVisualizer ("PointCloud"));
-
-      if (cloud_->isOrganized ())
-      {
-        // If the dataset is organized, and has RGB data, create an image viewer
-        std::vector<pcl::PCLPointField> fields;
-        int rgba_index = -1;
-        rgba_index = getFieldIndex<PointT> ("rgba", fields);
-       
-        if (rgba_index >= 0)
-        {
-          image_viewer_.reset (new visualization::ImageViewer ("RGB PCLImage"));
-
-          image_viewer_->registerMouseCallback (&ObjectSelection::mouse_callback, *this);
-          image_viewer_->registerKeyboardCallback(&ObjectSelection::keyboard_callback, *this);
-          image_viewer_->setPosition (cloud_->width, 0);
-          image_viewer_->setSize (cloud_->width, cloud_->height);
-
-          int poff = fields[rgba_index].offset;
-          // BGR to RGB
-          rgb_data_ = new unsigned char [cloud_->width * cloud_->height * 3];
-          for (std::uint32_t i = 0; i < cloud_->width * cloud_->height; ++i)
-          {
-            RGB rgb;
-            memcpy (&rgb, reinterpret_cast<unsigned char*> (&cloud_->points[i]) + poff, sizeof (rgb));
-
-            rgb_data_[i * 3 + 0] = rgb.r;
-            rgb_data_[i * 3 + 1] = rgb.g;
-            rgb_data_[i * 3 + 2] = rgb.b;
-          }
-          image_viewer_->showRGBImage (rgb_data_, cloud_->width, cloud_->height);
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  initGUI()
+  {
+    cloud_viewer_.reset(new visualization::PCLVisualizer("PointCloud"));
+
+    if (cloud_->isOrganized()) {
+      // If the dataset is organized, and has RGB data, create an image viewer
+      std::vector<pcl::PCLPointField> fields;
+      int rgba_index = -1;
+      rgba_index = getFieldIndex<PointT>("rgba", fields);
+
+      if (rgba_index >= 0) {
+        image_viewer_.reset(new visualization::ImageViewer("RGB PCLImage"));
+
+        image_viewer_->registerMouseCallback(&ObjectSelection::mouse_callback, *this);
+        image_viewer_->registerKeyboardCallback(&ObjectSelection::keyboard_callback,
+                                                *this);
+        image_viewer_->setPosition(cloud_->width, 0);
+        image_viewer_->setSize(cloud_->width, cloud_->height);
+
+        int poff = fields[rgba_index].offset;
+        // BGR to RGB
+        rgb_data_ = new unsigned char[cloud_->width * cloud_->height * 3];
+        for (std::uint32_t i = 0; i < cloud_->width * cloud_->height; ++i) {
+          RGB rgb;
+          memcpy(&rgb,
+                 reinterpret_cast<unsigned char*>(&cloud_->points[i]) + poff,
+                 sizeof(rgb));
+
+          rgb_data_[i * 3 + 0] = rgb.r;
+          rgb_data_[i * 3 + 1] = rgb.g;
+          rgb_data_[i * 3 + 2] = rgb.b;
         }
-        cloud_viewer_->setSize (cloud_->width, cloud_->height);
+        image_viewer_->showRGBImage(rgb_data_, cloud_->width, cloud_->height);
       }
+      cloud_viewer_->setSize(cloud_->width, cloud_->height);
+    }
 
-      cloud_viewer_->registerMouseCallback (&ObjectSelection::mouse_callback, *this);
-      cloud_viewer_->registerKeyboardCallback(&ObjectSelection::keyboard_callback, *this);
-      cloud_viewer_->registerPointPickingCallback (&ObjectSelection::pp_callback, *this);
-      cloud_viewer_->setPosition (0, 0);
+    cloud_viewer_->registerMouseCallback(&ObjectSelection::mouse_callback, *this);
+    cloud_viewer_->registerKeyboardCallback(&ObjectSelection::keyboard_callback, *this);
+    cloud_viewer_->registerPointPickingCallback(&ObjectSelection::pp_callback, *this);
+    cloud_viewer_->setPosition(0, 0);
+
+    cloud_viewer_->addPointCloud(cloud_, "scene");
+    cloud_viewer_->resetCameraViewpoint("scene");
+    cloud_viewer_->addCoordinateSystem(0.1, 0, 0, 0, "global");
+  }
 
-      cloud_viewer_->addPointCloud (cloud_, "scene");
-      cloud_viewer_->resetCameraViewpoint ("scene");
-      cloud_viewer_->addCoordinateSystem (0.1, 0, 0, 0, "global");
+  /////////////////////////////////////////////////////////////////////////
+  bool
+  load(const std::string& file)
+  {
+    // Load the input file
+    TicToc tt;
+    tt.tic();
+    print_highlight(stderr, "Loading ");
+    print_value(stderr, "%s ", file.c_str());
+    cloud_.reset(new PointCloud<PointT>);
+    if (io::loadPCDFile(file, *cloud_) < 0) {
+      print_error(stderr, "[error]\n");
+      return false;
     }
+    print_info("[done, ");
+    print_value("%g", tt.toc());
+    print_info(" ms : ");
+    print_value("%lu", cloud_->size());
+    print_info(" points]\n");
 
-    /////////////////////////////////////////////////////////////////////////
-    bool
-    load (const std::string &file)
-    {
-      // Load the input file
-      TicToc tt; tt.tic ();
-      print_highlight (stderr, "Loading "); 
-      print_value (stderr, "%s ", file.c_str ());
-      cloud_.reset (new PointCloud<PointT>);
-      if (io::loadPCDFile (file, *cloud_) < 0) 
-      {
-        print_error (stderr, "[error]\n");
-        return (false);
-      }
-      print_info ("[done, "); print_value ("%g", tt.toc ()); 
-      print_info (" ms : "); print_value ("%lu", cloud_->size ()); print_info (" points]\n");
-      
-      if (cloud_->isOrganized ())
-        search_.reset (new search::OrganizedNeighbor<PointT>);
-      else
-        search_.reset (new search::KdTree<PointT>);
+    if (cloud_->isOrganized())
+      search_.reset(new search::OrganizedNeighbor<PointT>);
+    else
+      search_.reset(new search::KdTree<PointT>);
 
-      search_->setInputCloud (cloud_);
+    search_->setInputCloud(cloud_);
 
-      return (true);
-    }
-    
-    /////////////////////////////////////////////////////////////////////////
-    void
-    save (const std::string &object_file, const std::string &plane_file)
-    {
-      PCDWriter w;
-      if (object_ && !object_->empty ())
-      {
-        w.writeBinaryCompressed (object_file, *object_);
-        w.writeBinaryCompressed (plane_file, *plane_);
-        print_highlight ("Object successfully segmented. Saving results in: %s, and %s.\n", object_file.c_str (), plane_file.c_str ());
-      }
+    return true;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  void
+  save(const std::string& object_file, const std::string& plane_file)
+  {
+    PCDWriter w;
+    if (object_ && !object_->empty()) {
+      w.writeBinaryCompressed(object_file, *object_);
+      w.writeBinaryCompressed(plane_file, *plane_);
+      print_highlight("Object successfully segmented. Saving results in: %s, and %s.\n",
+                      object_file.c_str(),
+                      plane_file.c_str());
     }
+  }
+
+  visualization::PCLVisualizer::Ptr cloud_viewer_;
+  visualization::ImageViewer::Ptr image_viewer_;
+
+  typename PointCloud<PointT>::Ptr cloud_;
+  typename search::Search<PointT>::Ptr search_;
 
-    visualization::PCLVisualizer::Ptr cloud_viewer_;
-    visualization::ImageViewer::Ptr image_viewer_;
-    
-    typename PointCloud<PointT>::Ptr cloud_;
-    typename search::Search<PointT>::Ptr search_;
-  private:
-    // Segmentation
-    typename EdgeAwarePlaneComparator<PointT, Normal>::Ptr plane_comparator_;
-    PointIndices::Ptr plane_indices_;
-    unsigned char* rgb_data_;
-    std::vector<float> distance_map_;
-
-    // Results
-    typename PointCloud<PointT>::Ptr plane_;
-    typename PointCloud<PointT>::Ptr object_;
+private:
+  // Segmentation
+  typename EdgeAwarePlaneComparator<PointT, Normal>::Ptr plane_comparator_;
+  PointIndices::Ptr plane_indices_;
+  unsigned char* rgb_data_;
+  std::vector<float> distance_map_;
+
+  // Results
+  typename PointCloud<PointT>::Ptr plane_;
+  typename PointCloud<PointT>::Ptr object_;
 };
 
 /* ---[ */
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
   // Parse the command line arguments for .pcd files
   std::vector<int> p_file_indices;
-  p_file_indices = parse_file_extension_argument (argc, argv, ".pcd");
-  if (p_file_indices.empty ())
-  {
-    print_error ("  Need at least an input PCD file (e.g. scene.pcd) to continue!\n\n");
-    print_info ("Ideally, need an input file, and three output PCD files, e.g., object.pcd, plane.pcd, rest.pcd\n");
-    return (-1);
+  p_file_indices = parse_file_extension_argument(argc, argv, ".pcd");
+  if (p_file_indices.empty()) {
+    print_error("  Need at least an input PCD file (e.g. scene.pcd) to continue!\n\n");
+    print_info("Ideally, need an input file, and three output PCD files, e.g., "
+               "object.pcd, plane.pcd, rest.pcd\n");
+    return -1;
   }
-  
-  string object_file = "object.pcd", plane_file = "plane.pcd", rest_file = "rest.pcd";
-  if (p_file_indices.size () >= 4)
-    rest_file = argv[p_file_indices[3]];
-  if (p_file_indices.size () >= 3)
+
+  std::string object_file = "object.pcd";
+  std::string plane_file = "plane.pcd";
+  if (p_file_indices.size() >= 3)
     plane_file = argv[p_file_indices[2]];
-  if (p_file_indices.size () >= 2)
+  if (p_file_indices.size() >= 2)
     object_file = argv[p_file_indices[1]];
 
-
   PCDReader reader;
   // Test the header
   pcl::PCLPointCloud2 dummy;
-  reader.readHeader (argv[p_file_indices[0]], dummy);
-  if (dummy.height != 1 && getFieldIndex (dummy, "rgba") != -1)
-  {
-    print_highlight ("Enabling 2D image viewer mode.\n");
+  reader.readHeader(argv[p_file_indices[0]], dummy);
+  if (dummy.height != 1 && getFieldIndex(dummy, "rgba") != -1) {
+    print_highlight("Enabling 2D image viewer mode.\n");
     ObjectSelection<PointXYZRGBA> s;
-    if (!s.load (argv[p_file_indices[0]])) return (-1);
-    s.initGUI ();
-    s.compute ();
-    s.save (object_file, plane_file);
+    if (!s.load(argv[p_file_indices[0]]))
+      return -1;
+    s.initGUI();
+    s.compute();
+    s.save(object_file, plane_file);
   }
-  else
-  {
+  else {
     ObjectSelection<PointXYZ> s;
-    if (!s.load (argv[p_file_indices[0]])) return (-1);
-    s.initGUI ();
-    s.compute ();
-    s.save (object_file, plane_file);
+    if (!s.load(argv[p_file_indices[0]]))
+      return -1;
+    s.initGUI();
+    s.compute();
+    s.save(object_file, plane_file);
   }
 
-  return (0);
+  return 0;
 }
 /* ]--- */
index f517e02ce4e5ec5b046f565aabc05130b37e40af..18905b303718ee60225b505b4c90c2c215dd4c1a 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2012, Willow Garage, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *
  */
 
-//PCL
 #include <pcl/apps/pcd_video_player.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/point_types.h>
 
-//STD
-#include <iostream>
-#include <fstream>
-
-//BOOST
-#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/property_tree/ptree.hpp>
-
-//QT4
 #include <QApplication>
-#include <QMutexLocker>
+#include <QButtonGroup>
 #include <QEvent>
-#include <QObject>
 #include <QFileDialog>
 #include <QGroupBox>
+#include <QMutexLocker>
+#include <QObject>
 #include <QRadioButton>
-#include <QButtonGroup>
 
-// VTK
+#include <vtkCamera.h>
 #include <vtkRenderWindow.h>
 #include <vtkRendererCollection.h>
-#include <vtkCamera.h>
+
+#include <fstream>
+#include <iostream>
 
 using namespace pcl;
 using namespace std;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
-PCDVideoPlayer::PCDVideoPlayer ()
+PCDVideoPlayer::PCDVideoPlayer()
 {
   cloud_present_ = false;
   cloud_modified_ = false;
@@ -77,118 +67,125 @@ PCDVideoPlayer::PCDVideoPlayer ()
   speed_counter_ = 0;
   speed_value_ = 5;
 
-  //Create a timer
-  vis_timer_ = new QTimer (this);
-  vis_timer_->start (5);//5ms
+  // Create a timer
+  vis_timer_ = new QTimer(this);
+  vis_timer_->start(5); // 5ms
 
-  connect (vis_timer_, SIGNAL (timeout ()), this, SLOT (timeoutSlot ()));
+  connect(vis_timer_, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
 
   ui_ = new Ui::MainWindow;
-  ui_->setupUi (this);
-  
-  this->setWindowTitle ("PCL PCD Video Player");
+  ui_->setupUi(this);
+
+  this->setWindowTitle("PCL PCD Video Player");
 
   // Setup the cloud pointer
-  cloud_.reset (new pcl::PointCloud<pcl::PointXYZRGBA>);
+  cloud_.reset(new pcl::PointCloud<pcl::PointXYZRGBA>);
 
   // Set up the qvtk window
-  vis_.reset (new pcl::visualization::PCLVisualizer ("", false));
-  ui_->qvtkWidget->SetRenderWindow (vis_->getRenderWindow ());
-  vis_->setupInteractor (ui_->qvtkWidget->GetInteractor (), ui_->qvtkWidget->GetRenderWindow ());
-  vis_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
-  ui_->qvtkWidget->update ();
+  vis_.reset(new pcl::visualization::PCLVisualizer("", false));
+  ui_->qvtkWidget->SetRenderWindow(vis_->getRenderWindow());
+  vis_->setupInteractor(ui_->qvtkWidget->GetInteractor(),
+                        ui_->qvtkWidget->GetRenderWindow());
+  vis_->getInteractorStyle()->setKeyboardModifier(
+      pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
+  ui_->qvtkWidget->update();
 
   // Connect all buttons
-  connect (ui_->playButton, SIGNAL (clicked ()), this, SLOT (playButtonPressed ()));
-  connect (ui_->stopButton, SIGNAL (clicked ()), this, SLOT (stopButtonPressed ()));
-  connect (ui_->backButton, SIGNAL (clicked ()), this, SLOT (backButtonPressed ()));
-  connect (ui_->nextButton, SIGNAL (clicked ()), this, SLOT (nextButtonPressed ()));
-
-  connect (ui_->selectFolderButton, SIGNAL (clicked ()), this, SLOT (selectFolderButtonPressed ()));
-  connect (ui_->selectFilesButton, SIGNAL (clicked ()), this, SLOT (selectFilesButtonPressed ()));
-  
-  connect (ui_->indexSlider, SIGNAL (valueChanged (int)), this, SLOT (indexSliderValueChanged (int)));
+  connect(ui_->playButton, SIGNAL(clicked()), this, SLOT(playButtonPressed()));
+  connect(ui_->stopButton, SIGNAL(clicked()), this, SLOT(stopButtonPressed()));
+  connect(ui_->backButton, SIGNAL(clicked()), this, SLOT(backButtonPressed()));
+  connect(ui_->nextButton, SIGNAL(clicked()), this, SLOT(nextButtonPressed()));
+
+  connect(ui_->selectFolderButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(selectFolderButtonPressed()));
+  connect(ui_->selectFilesButton,
+          SIGNAL(clicked()),
+          this,
+          SLOT(selectFilesButtonPressed()));
+
+  connect(ui_->indexSlider,
+          SIGNAL(valueChanged(int)),
+          this,
+          SLOT(indexSliderValueChanged(int)));
 }
 
-void 
-PCDVideoPlayer::backButtonPressed ()
+void
+PCDVideoPlayer::backButtonPressed()
 {
-  if(current_frame_ == 0) // Already in the beginning
+  if (current_frame_ == 0) // Already in the beginning
   {
-    PCL_DEBUG ("[PCDVideoPlayer::nextButtonPressed] : reached the end\n");
+    PCL_DEBUG("[PCDVideoPlayer::nextButtonPressed] : reached the end\n");
     current_frame_ = nr_of_frames_ - 1; // reset to end
   }
-  else
-  {
+  else {
     current_frame_--;
     cloud_modified_ = true;
-    ui_->indexSlider->setSliderPosition (current_frame_);        // Update the slider position
+    ui_->indexSlider->setSliderPosition(current_frame_); // Update the slider position
   }
 }
 
-void 
-PCDVideoPlayer::nextButtonPressed ()
+void
+PCDVideoPlayer::nextButtonPressed()
 {
   if (current_frame_ == (nr_of_frames_ - 1)) // Reached the end
   {
-    PCL_DEBUG ("[PCDVideoPlayer::nextButtonPressed] : reached the end\n");
+    PCL_DEBUG("[PCDVideoPlayer::nextButtonPressed] : reached the end\n");
     current_frame_ = 0; // reset to beginning
   }
-  else
-  {
+  else {
     current_frame_++;
     cloud_modified_ = true;
-    ui_->indexSlider->setSliderPosition (current_frame_);        // Update the slider position
+    ui_->indexSlider->setSliderPosition(current_frame_); // Update the slider position
   }
 }
 
 void
-PCDVideoPlayer::selectFolderButtonPressed ()
+PCDVideoPlayer::selectFolderButtonPressed()
 {
-  pcd_files_.clear ();     // Clear the std::vector
-  pcd_paths_.clear ();     // Clear the boost filesystem paths
+  pcd_files_.clear(); // Clear the std::vector
+  pcd_paths_.clear(); // Clear the boost filesystem paths
 
-  dir_ = QFileDialog::getExistingDirectory (this,
-                                            tr("Open Directory"),
-                                            "/home",
-                                            QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+  dir_ = QFileDialog::getExistingDirectory(this,
+                                           tr("Open Directory"),
+                                           "/home",
+                                           QFileDialog::ShowDirsOnly |
+                                               QFileDialog::DontResolveSymlinks);
 
   boost::filesystem::directory_iterator end_itr;
 
-  if (boost::filesystem::is_directory (dir_.toStdString ()))
-  {
-    for (boost::filesystem::directory_iterator itr (dir_.toStdString ()); itr != end_itr; ++itr)
-    {
-      std::string ext = itr->path ().extension ().string ();
-      if (ext == ".pcd")
-      {
-        pcd_files_.push_back (itr->path ().string ());
-        pcd_paths_.push_back (itr->path ());
+  if (boost::filesystem::is_directory(dir_.toStdString())) {
+    for (boost::filesystem::directory_iterator itr(dir_.toStdString()); itr != end_itr;
+         ++itr) {
+      std::string ext = itr->path().extension().string();
+      if (ext == ".pcd") {
+        pcd_files_.push_back(itr->path().string());
+        pcd_paths_.push_back(itr->path());
       }
-      else
-      {
+      else {
         // Found non pcd file
-        PCL_DEBUG ("[PCDVideoPlayer::selectFolderButtonPressed] : found a different file\n");
+        PCL_DEBUG(
+            "[PCDVideoPlayer::selectFolderButtonPressed] : found a different file\n");
       }
     }
   }
-  else
-  {
+  else {
     PCL_ERROR("Path is not a directory\n");
     exit(-1);
   }
-  nr_of_frames_ = pcd_files_.size ();
-  PCL_DEBUG ("[PCDVideoPlayer::selectFolderButtonPressed] : found %d files\n", nr_of_frames_ );
+  nr_of_frames_ = pcd_files_.size();
+  PCL_DEBUG("[PCDVideoPlayer::selectFolderButtonPressed] : found %d files\n",
+            nr_of_frames_);
 
-  if (nr_of_frames_ == 0)
-  {
-    PCL_ERROR ("Please select valid pcd folder\n");
+  if (nr_of_frames_ == 0) {
+    PCL_ERROR("Please select valid pcd folder\n");
     cloud_present_ = false;
     return;
   }
   // Reset the Slider
-  ui_->indexSlider->setValue (0);                // set cursor back in the beginning
-  ui_->indexSlider->setRange (0, nr_of_frames_ - 1);  // rescale the slider
+  ui_->indexSlider->setValue(0);                    // set cursor back in the beginning
+  ui_->indexSlider->setRange(0, nr_of_frames_ - 1); // rescale the slider
 
   current_frame_ = 0;
 
@@ -196,93 +193,87 @@ PCDVideoPlayer::selectFolderButtonPressed ()
   cloud_modified_ = true;
 }
 
-void 
-PCDVideoPlayer::selectFilesButtonPressed ()
+void
+PCDVideoPlayer::selectFilesButtonPressed()
 {
-  pcd_files_.clear ();  // Clear the std::vector
-  pcd_paths_.clear ();     // Clear the boost filesystem paths
+  pcd_files_.clear(); // Clear the std::vector
+  pcd_paths_.clear(); // Clear the boost filesystem paths
 
-  QStringList qt_pcd_files = QFileDialog::getOpenFileNames (this,
-                                                            "Select one or more PCD files to open",
-                                                            "/home",
-                                                            "PointClouds (*.pcd)");
-  nr_of_frames_ = qt_pcd_files.size ();
-  PCL_INFO ("[PCDVideoPlayer::selectFilesButtonPressed] : selected %ld files\n", nr_of_frames_);
+  QStringList qt_pcd_files = QFileDialog::getOpenFileNames(
+      this, "Select one or more PCD files to open", "/home", "PointClouds (*.pcd)");
+  nr_of_frames_ = qt_pcd_files.size();
+  PCL_INFO("[PCDVideoPlayer::selectFilesButtonPressed] : selected %ld files\n",
+           nr_of_frames_);
 
-  if (nr_of_frames_ == 0)
-  {
-    PCL_ERROR ("Please select valid pcd files\n");
+  if (nr_of_frames_ == 0) {
+    PCL_ERROR("Please select valid pcd files\n");
     cloud_present_ = false;
     return;
   }
 
-  for(int i = 0; i < qt_pcd_files.size (); i++)
-  {
-    pcd_files_.push_back (qt_pcd_files.at (i).toStdString ());
+  for (int i = 0; i < qt_pcd_files.size(); i++) {
+    pcd_files_.push_back(qt_pcd_files.at(i).toStdString());
   }
 
   current_frame_ = 0;
 
   // Reset the Slider
-  ui_->indexSlider->setValue (0);                // set cursor back in the beginning
-  ui_->indexSlider->setRange (0, nr_of_frames_ - 1);  // rescale the slider
+  ui_->indexSlider->setValue(0);                    // set cursor back in the beginning
+  ui_->indexSlider->setRange(0, nr_of_frames_ - 1); // rescale the slider
 
   cloud_present_ = true;
   cloud_modified_ = true;
 }
 
-void 
-PCDVideoPlayer::timeoutSlot ()
+void
+PCDVideoPlayer::timeoutSlot()
 {
-  if (play_mode_)
-  {
-    if (speed_counter_ == speed_value_)
-    {
-      if (current_frame_ == (nr_of_frames_-1)) // Reached the end
+  if (play_mode_) {
+    if (speed_counter_ == speed_value_) {
+      if (current_frame_ == (nr_of_frames_ - 1)) // Reached the end
       {
         current_frame_ = 0; // reset to beginning
       }
-      else
-      {
+      else {
         current_frame_++;
         cloud_modified_ = true;
-        ui_->indexSlider->setSliderPosition (current_frame_);        // Update the slider position
+        ui_->indexSlider->setSliderPosition(
+            current_frame_); // Update the slider position
       }
     }
-    else
-    {
+    else {
       speed_counter_++;
     }
   }
 
-  if (cloud_present_ && cloud_modified_)
-  {
-    if (pcl::io::loadPCDFile<pcl::PointXYZRGBA> (pcd_files_[current_frame_], *cloud_) == -1) //* load the file
+  if (cloud_present_ && cloud_modified_) {
+    if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>(pcd_files_[current_frame_], *cloud_) ==
+        -1) //* load the file
     {
-      PCL_ERROR ("[PCDVideoPlayer::timeoutSlot] : Couldn't read file %s\n");
+      PCL_ERROR("[PCDVideoPlayer::timeoutSlot] : Couldn't read file %s\n");
     }
 
-    if (!vis_->updatePointCloud(cloud_, "cloud_"))
-    {
-      vis_->addPointCloud (cloud_, "cloud_");
+    if (!vis_->updatePointCloud(cloud_, "cloud_")) {
+      vis_->addPointCloud(cloud_, "cloud_");
       vis_->resetCameraViewpoint("cloud_");
     }
     cloud_modified_ = false;
   }
-  ui_->qvtkWidget->update ();
+  ui_->qvtkWidget->update();
 }
 
 void
-PCDVideoPlayer::indexSliderValueChanged (int value)
+PCDVideoPlayer::indexSliderValueChanged(int value)
 {
-  PCL_DEBUG ("[PCDVideoPlayer::indexSliderValueChanged] : (I) : value %d\n", value);
+  PCL_DEBUG("[PCDVideoPlayer::indexSliderValueChanged] : (I) : value %d\n", value);
   current_frame_ = value;
   cloud_modified_ = true;
 }
 
 void
-print_usage ()
+print_usage()
 {
+  // clang-format off
   PCL_INFO ("PCDVideoPlayer V0.1\n");
   PCL_INFO ("-------------------\n");
   PCL_INFO ("\tThe slider accepts focus on Tab and provides both a mouse wheel and a keyboard interface. The keyboard interface is the following:\n");
@@ -292,16 +283,17 @@ print_usage ()
   PCL_INFO ("\t  PageDown moves down one page.\n");
   PCL_INFO ("\t  Home moves to the start (minimum).\n");
   PCL_INFO ("\t  End moves to the end (maximum).\n");
+  // clang-format on
 }
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
-  QApplication app (argc, argv);
+  QApplication app(argc, argv);
 
   PCDVideoPlayer VideoPlayer;
 
-  VideoPlayer.show ();
+  VideoPlayer.show();
 
-  return (QApplication::exec ());
+  return QApplication::exec();
 }
index 52fdc2252bbb9c52721191f3d99492cc2cd6b8cf..d4ba2dfd436f380a41f86faad5b308ad67ead75a 100644 (file)
-#include <thread>
-
+#include <pcl/features/normal_3d.h>
 #include <pcl/features/ppf.h>
-#include <pcl/io/pcd_io.h>
+#include <pcl/filters/extract_indices.h>
 #include <pcl/filters/voxel_grid.h>
-#include <pcl/features/normal_3d.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/registration/ppf_registration.h>
-
-#include <pcl/visualization/pcl_visualizer.h>
-
-#include <pcl/segmentation/sac_segmentation.h>
-#include <pcl/filters/extract_indices.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
+#include <pcl/segmentation/sac_segmentation.h>
+#include <pcl/visualization/pcl_visualizer.h>
+
+#include <thread>
 
 using namespace pcl;
 using namespace std;
 using namespace std::chrono_literals;
 
-const Eigen::Vector4f subsampling_leaf_size (0.02f, 0.02f, 0.02f, 0.0f);
+const Eigen::Vector4f subsampling_leaf_size(0.02f, 0.02f, 0.02f, 0.0f);
 const float normal_estimation_search_radius = 0.05f;
 
-
 PointCloud<PointNormal>::Ptr
-subsampleAndCalculateNormals (const PointCloud<PointXYZ>::Ptr& cloud)
+subsampleAndCalculateNormals(const PointCloud<PointXYZ>::Ptr& cloud)
 {
-  PointCloud<PointXYZ>::Ptr cloud_subsampled (new PointCloud<PointXYZ> ());
+  PointCloud<PointXYZ>::Ptr cloud_subsampled(new PointCloud<PointXYZ>());
   VoxelGrid<PointXYZ> subsampling_filter;
-  subsampling_filter.setInputCloud (cloud);
-  subsampling_filter.setLeafSize (subsampling_leaf_size);
-  subsampling_filter.filter (*cloud_subsampled);
+  subsampling_filter.setInputCloud(cloud);
+  subsampling_filter.setLeafSize(subsampling_leaf_size);
+  subsampling_filter.filter(*cloud_subsampled);
 
-  PointCloud<Normal>::Ptr cloud_subsampled_normals (new PointCloud<Normal> ());
+  PointCloud<Normal>::Ptr cloud_subsampled_normals(new PointCloud<Normal>());
   NormalEstimation<PointXYZ, Normal> normal_estimation_filter;
-  normal_estimation_filter.setInputCloud (cloud_subsampled);
-  search::KdTree<PointXYZ>::Ptr search_tree (new search::KdTree<PointXYZ>);
-  normal_estimation_filter.setSearchMethod (search_tree);
-  normal_estimation_filter.setRadiusSearch (normal_estimation_search_radius);
-  normal_estimation_filter.compute (*cloud_subsampled_normals);
-
-  PointCloud<PointNormal>::Ptr cloud_subsampled_with_normals (new PointCloud<PointNormal> ());
-  concatenateFields (*cloud_subsampled, *cloud_subsampled_normals, *cloud_subsampled_with_normals);
-
-  PCL_INFO ("Cloud dimensions before / after subsampling: %u / %u\n", cloud->points.size (), cloud_subsampled->points.size ());
+  normal_estimation_filter.setInputCloud(cloud_subsampled);
+  search::KdTree<PointXYZ>::Ptr search_tree(new search::KdTree<PointXYZ>);
+  normal_estimation_filter.setSearchMethod(search_tree);
+  normal_estimation_filter.setRadiusSearch(normal_estimation_search_radius);
+  normal_estimation_filter.compute(*cloud_subsampled_normals);
+
+  PointCloud<PointNormal>::Ptr cloud_subsampled_with_normals(
+      new PointCloud<PointNormal>());
+  concatenateFields(
+      *cloud_subsampled, *cloud_subsampled_normals, *cloud_subsampled_with_normals);
+
+  PCL_INFO("Cloud dimensions before / after subsampling: %u / %u\n",
+           cloud->points.size(),
+           cloud_subsampled->points.size());
   return cloud_subsampled_with_normals;
 }
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
-  if (argc != 3)
-  {
-    PCL_ERROR ("Syntax: ./ppf_object_recognition pcd_model_list pcd_scene\n");
+  if (argc != 3) {
+    PCL_ERROR("Syntax: ./ppf_object_recognition pcd_model_list pcd_scene\n");
     return -1;
   }
 
-
   /// read point clouds from HDD
-  PCL_INFO ("Reading scene ...\n");
-  PointCloud<PointXYZ>::Ptr cloud_scene (new PointCloud<PointXYZ> ());
+  PCL_INFO("Reading scene ...\n");
+  PointCloud<PointXYZ>::Ptr cloud_scene(new PointCloud<PointXYZ>());
   PCDReader reader;
-  reader.read (argv[2], *cloud_scene);
-  PCL_INFO ("Scene read: %s\n", argv[2]);
-
-  PCL_INFO ("Reading models ...\n");
-  std::vector<PointCloud<PointXYZ>::Ptr > cloud_models;
-  ifstream pcd_file_list (argv[1]);
-  while (!pcd_file_list.eof())
-  {
+  reader.read(argv[2], *cloud_scene);
+  PCL_INFO("Scene read: %s\n", argv[2]);
+
+  PCL_INFO("Reading models ...\n");
+  std::vector<PointCloud<PointXYZ>::Ptr> cloud_models;
+  ifstream pcd_file_list(argv[1]);
+  while (!pcd_file_list.eof()) {
     char str[512];
-    pcd_file_list.getline (str, 512);
-    PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ> ());
-    reader.read (str, *cloud);
-    cloud_models.push_back (cloud);
-    PCL_INFO ("Model read: %s\n", str);
+    pcd_file_list.getline(str, 512);
+    PointCloud<PointXYZ>::Ptr cloud(new PointCloud<PointXYZ>());
+    reader.read(str, *cloud);
+    cloud_models.push_back(cloud);
+    PCL_INFO("Model read: %s\n", str);
   }
 
   pcl::SACSegmentation<pcl::PointXYZ> seg;
   pcl::ExtractIndices<pcl::PointXYZ> extract;
-  seg.setOptimizeCoefficients (true);
-  seg.setModelType (pcl::SACMODEL_PLANE);
-  seg.setMethodType (pcl::SAC_RANSAC);
-  seg.setMaxIterations (1000);
-  seg.setDistanceThreshold (0.05);
-  extract.setNegative (true);
-  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
-  pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
-  unsigned nr_points = unsigned (cloud_scene->points.size ());
-  while (cloud_scene->points.size () > 0.3 * nr_points)
-  {
-    seg.setInputCloud (cloud_scene);
-    seg.segment (*inliers, *coefficients);
-    PCL_INFO ("Plane inliers: %u\n", inliers->indices.size ());
-    if (inliers->indices.size () < 50000) break;
-
-    extract.setInputCloud (cloud_scene);
-    extract.setIndices (inliers);
-    extract.filter (*cloud_scene);
+  seg.setOptimizeCoefficients(true);
+  seg.setModelType(pcl::SACMODEL_PLANE);
+  seg.setMethodType(pcl::SAC_RANSAC);
+  seg.setMaxIterations(1000);
+  seg.setDistanceThreshold(0.05);
+  extract.setNegative(true);
+  pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
+  pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
+  unsigned nr_points = unsigned(cloud_scene->points.size());
+  while (cloud_scene->points.size() > 0.3 * nr_points) {
+    seg.setInputCloud(cloud_scene);
+    seg.segment(*inliers, *coefficients);
+    PCL_INFO("Plane inliers: %u\n", inliers->indices.size());
+    if (inliers->indices.size() < 50000)
+      break;
+
+    extract.setInputCloud(cloud_scene);
+    extract.setIndices(inliers);
+    extract.filter(*cloud_scene);
   }
 
-  PointCloud<PointNormal>::Ptr cloud_scene_input = subsampleAndCalculateNormals (cloud_scene);
-  std::vector<PointCloud<PointNormal>::Ptr > cloud_models_with_normals;
+  PointCloud<PointNormal>::Ptr cloud_scene_input =
+      subsampleAndCalculateNormals(cloud_scene);
+  std::vector<PointCloud<PointNormal>::Ptr> cloud_models_with_normals;
 
-  PCL_INFO ("Training models ...\n");
+  PCL_INFO("Training models ...\n");
   std::vector<PPFHashMapSearch::Ptr> hashmap_search_vector;
-  for (const auto &cloud_model : cloud_models)
-  {
-    PointCloud<PointNormal>::Ptr cloud_model_input = subsampleAndCalculateNormals (cloud_model);
-    cloud_models_with_normals.push_back (cloud_model_input);
+  for (const auto& cloud_model : cloud_models) {
+    PointCloud<PointNormal>::Ptr cloud_model_input =
+        subsampleAndCalculateNormals(cloud_model);
+    cloud_models_with_normals.push_back(cloud_model_input);
 
-    PointCloud<PPFSignature>::Ptr cloud_model_ppf (new PointCloud<PPFSignature> ());
+    PointCloud<PPFSignature>::Ptr cloud_model_ppf(new PointCloud<PPFSignature>());
     PPFEstimation<PointNormal, PointNormal, PPFSignature> ppf_estimator;
-    ppf_estimator.setInputCloud (cloud_model_input);
-    ppf_estimator.setInputNormals (cloud_model_input);
-    ppf_estimator.compute (*cloud_model_ppf);
-
-    PPFHashMapSearch::Ptr hashmap_search (new PPFHashMapSearch (12.0f / 180.0f * float (M_PI),
-                                                                 0.05f));
-    hashmap_search->setInputFeatureCloud (cloud_model_ppf);
-    hashmap_search_vector.push_back (hashmap_search);
+    ppf_estimator.setInputCloud(cloud_model_input);
+    ppf_estimator.setInputNormals(cloud_model_input);
+    ppf_estimator.compute(*cloud_model_ppf);
+
+    PPFHashMapSearch::Ptr hashmap_search(
+        new PPFHashMapSearch(12.0f / 180.0f * float(M_PI), 0.05f));
+    hashmap_search->setInputFeatureCloud(cloud_model_ppf);
+    hashmap_search_vector.push_back(hashmap_search);
   }
 
-
-  visualization::PCLVisualizer viewer ("PPF Object Recognition - Results");
-  viewer.setBackgroundColor (0, 0, 0);
-  viewer.addPointCloud (cloud_scene);
-  viewer.spinOnce (10);
-  PCL_INFO ("Registering models to scene ...\n");
-  for (std::size_t model_i = 0; model_i < cloud_models.size (); ++model_i)
-  {
+  visualization::PCLVisualizer viewer("PPF Object Recognition - Results");
+  viewer.setBackgroundColor(0, 0, 0);
+  viewer.addPointCloud(cloud_scene);
+  viewer.spinOnce(10);
+  PCL_INFO("Registering models to scene ...\n");
+  for (std::size_t model_i = 0; model_i < cloud_models.size(); ++model_i) {
 
     PPFRegistration<PointNormal, PointNormal> ppf_registration;
     // set parameters for the PPF registration procedure
-    ppf_registration.setSceneReferencePointSamplingRate (10);
-    ppf_registration.setPositionClusteringThreshold (0.2f);
-    ppf_registration.setRotationClusteringThreshold (30.0f / 180.0f * float (M_PI));
-    ppf_registration.setSearchMethod (hashmap_search_vector[model_i]);
-    ppf_registration.setInputSource (cloud_models_with_normals[model_i]);
-    ppf_registration.setInputTarget (cloud_scene_input);
+    ppf_registration.setSceneReferencePointSamplingRate(10);
+    ppf_registration.setPositionClusteringThreshold(0.2f);
+    ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * float(M_PI));
+    ppf_registration.setSearchMethod(hashmap_search_vector[model_i]);
+    ppf_registration.setInputSource(cloud_models_with_normals[model_i]);
+    ppf_registration.setInputTarget(cloud_scene_input);
 
     PointCloud<PointNormal> cloud_output_subsampled;
-    ppf_registration.align (cloud_output_subsampled);
+    ppf_registration.align(cloud_output_subsampled);
 
-    PointCloud<PointXYZ>::Ptr cloud_output_subsampled_xyz (new PointCloud<PointXYZ> ());
-    for (const auto &point : cloud_output_subsampled.points)
+    PointCloud<PointXYZ>::Ptr cloud_output_subsampled_xyz(new PointCloud<PointXYZ>());
+    for (const autopoint : cloud_output_subsampled.points)
       cloud_output_subsampled_xyz->points.emplace_back(point.x, point.y, point.z);
 
+    Eigen::Matrix4f mat = ppf_registration.getFinalTransformation();
+    Eigen::Affine3f final_transformation(mat);
 
-    Eigen::Matrix4f mat = ppf_registration.getFinalTransformation ();
-    Eigen::Affine3f final_transformation (mat);
-
-
-    //  io::savePCDFileASCII ("output_subsampled_registered.pcd", cloud_output_subsampled);
+    PointCloud<PointXYZ>::Ptr cloud_output(new PointCloud<PointXYZ>());
+    pcl::transformPointCloud(
+        *cloud_models[model_i], *cloud_output, final_transformation);
 
-    PointCloud<PointXYZ>::Ptr cloud_output (new PointCloud<PointXYZ> ());
-    pcl::transformPointCloud (*cloud_models[model_i], *cloud_output, final_transformation);
-
-
-    stringstream ss; ss << "model_" << model_i;
-    visualization::PointCloudColorHandlerRandom<PointXYZ> random_color (cloud_output->makeShared ());
-    viewer.addPointCloud (cloud_output, random_color, ss.str ());
-//    io::savePCDFileASCII (ss.str ().c_str (), *cloud_output);
-    PCL_INFO ("Showing model %s\n", ss.str ().c_str ());
+    stringstream ss;
+    ss << "model_" << model_i;
+    visualization::PointCloudColorHandlerRandom<PointXYZ> random_color(
+        cloud_output->makeShared());
+    viewer.addPointCloud(cloud_output, random_color, ss.str());
+    PCL_INFO("Showing model %s\n", ss.str().c_str());
   }
 
-  PCL_INFO ("All models have been registered!\n");
-
+  PCL_INFO("All models have been registered!\n");
 
-  while (!viewer.wasStopped ())
-  {
-    viewer.spinOnce (100);
+  while (!viewer.wasStopped()) {
+    viewer.spinOnce(100);
     std::this_thread::sleep_for(100ms);
   }
 
index 33c04f9fda33b29621740fcb7f70447dbd825071..4b926e7a5610f98f0dfc10bdc94f3e397016a158 100644 (file)
@@ -1,7 +1,7 @@
-#include <pcl/io/pcd_io.h>
-#include <pcl/filters/voxel_grid.h>
 #include <pcl/features/normal_3d.h>
 #include <pcl/features/ppf.h>
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/registration/pyramid_feature_matching.h>
 
 using namespace pcl;
@@ -9,103 +9,108 @@ using namespace pcl;
 #include <iostream>
 using namespace std;
 
-const Eigen::Vector4f subsampling_leaf_size (0.02f, 0.02f, 0.02f, 0.0f);
+const Eigen::Vector4f subsampling_leaf_size(0.02f, 0.02f, 0.02f, 0.0f);
 const float normal_estimation_search_radius = 0.05f;
 
-//const Eigen::Vector4f subsampling_leaf_size (5, 5, 5, 0.0);
-//const float normal_estimation_search_radius = 11;
-
 void
-subsampleAndCalculateNormals (PointCloud<PointXYZ>::Ptr &cloud,
-                              PointCloud<PointXYZ>::Ptr &cloud_subsampled,
-                              PointCloud<Normal>::Ptr &cloud_subsampled_normals)
+subsampleAndCalculateNormals(PointCloud<PointXYZ>::Ptr& cloud,
+                             PointCloud<PointXYZ>::Ptr& cloud_subsampled,
+                             PointCloud<Normal>::Ptr& cloud_subsampled_normals)
 {
-  cloud_subsampled = PointCloud<PointXYZ>::Ptr (new PointCloud<PointXYZ> ());
+  cloud_subsampled = PointCloud<PointXYZ>::Ptr(new PointCloud<PointXYZ>());
   VoxelGrid<PointXYZ> subsampling_filter;
-  subsampling_filter.setInputCloud (cloud);
-  subsampling_filter.setLeafSize (subsampling_leaf_size);
-  subsampling_filter.filter (*cloud_subsampled);
+  subsampling_filter.setInputCloud(cloud);
+  subsampling_filter.setLeafSize(subsampling_leaf_size);
+  subsampling_filter.filter(*cloud_subsampled);
 
-  cloud_subsampled_normals = PointCloud<Normal>::Ptr (new PointCloud<Normal> ());
+  cloud_subsampled_normals = PointCloud<Normal>::Ptr(new PointCloud<Normal>());
   NormalEstimation<PointXYZ, Normal> normal_estimation_filter;
-  normal_estimation_filter.setInputCloud (cloud_subsampled);
-  search::KdTree<PointXYZ>::Ptr search_tree (new search::KdTree<PointXYZ>);
-  normal_estimation_filter.setSearchMethod (search_tree);
-  normal_estimation_filter.setRadiusSearch (normal_estimation_search_radius);
-  normal_estimation_filter.compute (*cloud_subsampled_normals);
-
-  std::cerr << "Before -> After subsampling: " << cloud->points.size () << " -> " << cloud_subsampled->points.size () << std::endl;
+  normal_estimation_filter.setInputCloud(cloud_subsampled);
+  search::KdTree<PointXYZ>::Ptr search_tree(new search::KdTree<PointXYZ>);
+  normal_estimation_filter.setSearchMethod(search_tree);
+  normal_estimation_filter.setRadiusSearch(normal_estimation_search_radius);
+  normal_estimation_filter.compute(*cloud_subsampled_normals);
+
+  std::cerr << "Before -> After subsampling: " << cloud->points.size() << " -> "
+            << cloud_subsampled->points.size() << std::endl;
 }
 
-
 int
-main (int argc, char **argv)
+main(int argc, char** argv)
 {
-  if (argc != 3)
-  {
-    PCL_ERROR ("Syntax: ./pyramid_surface_matching model_1 model_2\n");
+  if (argc != 3) {
+    PCL_ERROR("Syntax: ./pyramid_surface_matching model_1 model_2\n");
     return -1;
   }
 
-
   /// read point clouds from HDD
-  PCL_INFO ("Reading scene ...\n");
-  PointCloud<PointXYZ>::Ptr cloud_a (new PointCloud<PointXYZ> ()),
-      cloud_b (new PointCloud<PointXYZ> ());
+  PCL_INFO("Reading scene ...\n");
+  PointCloud<PointXYZ>::Ptr cloud_a(new PointCloud<PointXYZ>()),
+      cloud_b(new PointCloud<PointXYZ>());
   PCDReader reader;
-  reader.read (argv[1], *cloud_a);
-  reader.read (argv[2], *cloud_b);
+  reader.read(argv[1], *cloud_a);
+  reader.read(argv[2], *cloud_b);
 
   PointCloud<PointXYZ>::Ptr cloud_a_subsampled, cloud_b_subsampled;
   PointCloud<Normal>::Ptr cloud_a_subsampled_normals, cloud_b_subsampled_normals;
-  subsampleAndCalculateNormals (cloud_a, cloud_a_subsampled, cloud_a_subsampled_normals);
-  subsampleAndCalculateNormals (cloud_b, cloud_b_subsampled, cloud_b_subsampled_normals);
-
-  PCL_INFO ("Finished subsampling the clouds ...\n");
-
-
-  PointCloud<PPFSignature>::Ptr ppf_signature_a (new PointCloud<PPFSignature> ()),
-      ppf_signature_b (new PointCloud<PPFSignature> ());
-  PointCloud<PointNormal>::Ptr cloud_subsampled_with_normals_a (new PointCloud<PointNormal> ()),
-      cloud_subsampled_with_normals_b (new PointCloud<PointNormal> ());
-  concatenateFields (*cloud_a_subsampled, *cloud_a_subsampled_normals, *cloud_subsampled_with_normals_a);
-  concatenateFields (*cloud_b_subsampled, *cloud_b_subsampled_normals, *cloud_subsampled_with_normals_b);
+  subsampleAndCalculateNormals(cloud_a, cloud_a_subsampled, cloud_a_subsampled_normals);
+  subsampleAndCalculateNormals(cloud_b, cloud_b_subsampled, cloud_b_subsampled_normals);
+
+  PCL_INFO("Finished subsampling the clouds ...\n");
+
+  PointCloud<PPFSignature>::Ptr ppf_signature_a(new PointCloud<PPFSignature>()),
+      ppf_signature_b(new PointCloud<PPFSignature>());
+  PointCloud<PointNormal>::Ptr cloud_subsampled_with_normals_a(
+      new PointCloud<PointNormal>()),
+      cloud_subsampled_with_normals_b(new PointCloud<PointNormal>());
+  concatenateFields(*cloud_a_subsampled,
+                    *cloud_a_subsampled_normals,
+                    *cloud_subsampled_with_normals_a);
+  concatenateFields(*cloud_b_subsampled,
+                    *cloud_b_subsampled_normals,
+                    *cloud_subsampled_with_normals_b);
 
   PPFEstimation<PointNormal, PointNormal, PPFSignature> ppf_estimator;
-  ppf_estimator.setInputCloud (cloud_subsampled_with_normals_a);
-  ppf_estimator.setInputNormals (cloud_subsampled_with_normals_a);
-  ppf_estimator.compute (*ppf_signature_a);
-  ppf_estimator.setInputCloud (cloud_subsampled_with_normals_b);
-  ppf_estimator.setInputNormals (cloud_subsampled_with_normals_b);
-  ppf_estimator.compute (*ppf_signature_b);
-
-  PCL_INFO ("Feature cloud sizes: %u , %u\n", ppf_signature_a->points.size (), ppf_signature_b->points.size ());
-
-  PCL_INFO ("Finished calculating the features ...\n");
-  std::vector<pair<float, float> > dim_range_input, dim_range_target;
-  for (std::size_t i = 0; i < 3; ++i) dim_range_input.emplace_back(float (-M_PI), float (M_PI));
+  ppf_estimator.setInputCloud(cloud_subsampled_with_normals_a);
+  ppf_estimator.setInputNormals(cloud_subsampled_with_normals_a);
+  ppf_estimator.compute(*ppf_signature_a);
+  ppf_estimator.setInputCloud(cloud_subsampled_with_normals_b);
+  ppf_estimator.setInputNormals(cloud_subsampled_with_normals_b);
+  ppf_estimator.compute(*ppf_signature_b);
+
+  PCL_INFO("Feature cloud sizes: %u , %u\n",
+           ppf_signature_a->points.size(),
+           ppf_signature_b->points.size());
+
+  PCL_INFO("Finished calculating the features ...\n");
+  std::vector<pair<float, float>> dim_range_input, dim_range_target;
+  for (std::size_t i = 0; i < 3; ++i)
+    dim_range_input.emplace_back(float(-M_PI), float(M_PI));
   dim_range_input.emplace_back(0.0f, 1.0f);
-  for (std::size_t i = 0; i < 3; ++i) dim_range_target.emplace_back(float (-M_PI) * 10.0f, float (M_PI) * 10.0f);
+  for (std::size_t i = 0; i < 3; ++i)
+    dim_range_target.emplace_back(float(-M_PI) * 10.0f, float(M_PI) * 10.0f);
   dim_range_target.emplace_back(0.0f, 50.0f);
 
-
-  PyramidFeatureHistogram<PPFSignature>::Ptr pyramid_a (new PyramidFeatureHistogram<PPFSignature> ());
-  pyramid_a->setInputCloud (ppf_signature_a);
-  pyramid_a->setInputDimensionRange (dim_range_input);
-  pyramid_a->setTargetDimensionRange (dim_range_target);
-  pyramid_a->compute ();
-  PCL_INFO ("Done with the first pyramid\n");
-
-  PyramidFeatureHistogram<PPFSignature>::Ptr pyramid_b (new PyramidFeatureHistogram<PPFSignature> ());
-  pyramid_b->setInputCloud (ppf_signature_b);
-  pyramid_b->setInputDimensionRange (dim_range_input);
-  pyramid_b->setTargetDimensionRange (dim_range_target);
-  pyramid_b->compute ();
-  PCL_INFO ("Done with the second pyramid\n");
-
-  float value = PyramidFeatureHistogram<PPFSignature>::comparePyramidFeatureHistograms (pyramid_a, pyramid_b);
-  PCL_INFO ("Surface comparison value between %s and %s is: %f\n", argv[1], argv[2], value);
-
+  PyramidFeatureHistogram<PPFSignature>::Ptr pyramid_a(
+      new PyramidFeatureHistogram<PPFSignature>());
+  pyramid_a->setInputCloud(ppf_signature_a);
+  pyramid_a->setInputDimensionRange(dim_range_input);
+  pyramid_a->setTargetDimensionRange(dim_range_target);
+  pyramid_a->compute();
+  PCL_INFO("Done with the first pyramid\n");
+
+  PyramidFeatureHistogram<PPFSignature>::Ptr pyramid_b(
+      new PyramidFeatureHistogram<PPFSignature>());
+  pyramid_b->setInputCloud(ppf_signature_b);
+  pyramid_b->setInputDimensionRange(dim_range_input);
+  pyramid_b->setTargetDimensionRange(dim_range_target);
+  pyramid_b->compute();
+  PCL_INFO("Done with the second pyramid\n");
+
+  float value = PyramidFeatureHistogram<PPFSignature>::comparePyramidFeatureHistograms(
+      pyramid_a, pyramid_b);
+  PCL_INFO(
+      "Surface comparison value between %s and %s is: %f\n", argv[1], argv[2], value);
 
   return 0;
 }
index 1b240fcb5a5e0525974993358385f55c94d7b844..e329551b6967677b5357be5b0f95e7fa41816839 100644 (file)
@@ -4,45 +4,47 @@
  *  Created on: Dec 23, 2011
  *      Author: aitor
  */
-#include <array>
 
-#include <pcl/point_types.h>
 #include <pcl/apps/render_views_tesselated_sphere.h>
+#include <pcl/point_types.h>
+
+#include <vtkActor.h>
+#include <vtkCamera.h>
+#include <vtkCellArray.h>
 #include <vtkCellData.h>
-#include <vtkWorldPointPicker.h>
-#include <vtkPropPicker.h>
-#include <vtkPlatonicSolidSource.h>
-#include <vtkLoopSubdivisionFilter.h>
-#include <vtkTriangle.h>
-#include <vtkTransform.h>
 #include <vtkHardwareSelector.h>
-#include <vtkSelectionNode.h>
-#include <vtkSelection.h>
-#include <vtkCellArray.h>
-#include <vtkTransformFilter.h>
-#include <vtkCamera.h>
-#include <vtkActor.h>
+#include <vtkLoopSubdivisionFilter.h>
+#include <vtkPlatonicSolidSource.h>
+#include <vtkPointPicker.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPropPicker.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderer.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkPointPicker.h>
+#include <vtkSelection.h>
+#include <vtkSelectionNode.h>
+#include <vtkTransform.h>
+#include <vtkTransformFilter.h>
+#include <vtkTriangle.h>
+#include <vtkWorldPointPicker.h>
+
+#include <array>
 
 void
-pcl::apps::RenderViewsTesselatedSphere::generateViews() {
-  //center object
+pcl::apps::RenderViewsTesselatedSphere::generateViews()
+{
+  // center object
   double CoM[3];
   vtkIdType npts_com = 0, *ptIds_com = nullptr;
-  vtkSmartPointer<vtkCellArray> cells_com = polydata_->GetPolys ();
+  vtkSmartPointer<vtkCellArray> cells_com = polydata_->GetPolys();
 
   double center[3], p1_com[3], p2_com[3], p3_com[3], totalArea_com = 0;
   double comx = 0, comy = 0, comz = 0;
-  for (cells_com->InitTraversal (); cells_com->GetNextCell (npts_com, ptIds_com);)
-  {
-    polydata_->GetPoint (ptIds_com[0], p1_com);
-    polydata_->GetPoint (ptIds_com[1], p2_com);
-    polydata_->GetPoint (ptIds_com[2], p3_com);
-    vtkTriangle::TriangleCenter (p1_com, p2_com, p3_com, center);
-    double area_com = vtkTriangle::TriangleArea (p1_com, p2_com, p3_com);
+  for (cells_com->InitTraversal(); cells_com->GetNextCell(npts_com, ptIds_com);) {
+    polydata_->GetPoint(ptIds_com[0], p1_com);
+    polydata_->GetPoint(ptIds_com[1], p2_com);
+    polydata_->GetPoint(ptIds_com[2], p3_com);
+    vtkTriangle::TriangleCenter(p1_com, p2_com, p3_com, center);
+    double area_com = vtkTriangle::TriangleArea(p1_com, p2_com, p3_com);
     comx += center[0] * area_com;
     comy += center[1] * area_com;
     comz += center[2] * area_com;
@@ -53,94 +55,96 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() {
   CoM[1] = comy / totalArea_com;
   CoM[2] = comz / totalArea_com;
 
-  vtkSmartPointer<vtkTransform> trans_center = vtkSmartPointer<vtkTransform>::New ();
-  trans_center->Translate (-CoM[0], -CoM[1], -CoM[2]);
-  vtkSmartPointer<vtkMatrix4x4> matrixCenter = trans_center->GetMatrix ();
+  vtkSmartPointer<vtkTransform> trans_center = vtkSmartPointer<vtkTransform>::New();
+  trans_center->Translate(-CoM[0], -CoM[1], -CoM[2]);
+  vtkSmartPointer<vtkMatrix4x4> matrixCenter = trans_center->GetMatrix();
 
-  vtkSmartPointer<vtkTransformFilter> trans_filter_center = vtkSmartPointer<vtkTransformFilter>::New ();
-  trans_filter_center->SetTransform (trans_center);
-  trans_filter_center->SetInputData (polydata_);
-  trans_filter_center->Update ();
+  vtkSmartPointer<vtkTransformFilter> trans_filter_center =
+      vtkSmartPointer<vtkTransformFilter>::New();
+  trans_filter_center->SetTransform(trans_center);
+  trans_filter_center->SetInputData(polydata_);
+  trans_filter_center->Update();
 
-  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New ();
-  mapper->SetInputConnection (trans_filter_center->GetOutputPort ());
-  mapper->Update ();
+  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+  mapper->SetInputConnection(trans_filter_center->GetOutputPort());
+  mapper->Update();
 
-  //scale so it fits in the unit sphere!
+  // scale so it fits in the unit sphere!
   double bb[6];
-  mapper->GetBounds (bb);
-  double ms = (std::max) ((std::fabs) (bb[0] - bb[1]),
-                          (std::max) ((std::fabs) (bb[2] - bb[3]), (std::fabs) (bb[4] - bb[5])));
+  mapper->GetBounds(bb);
+  double ms =
+      std::max((std::fabs)(bb[0] - bb[1]),
+               std::max((std::fabs)(bb[2] - bb[3]), (std::fabs)(bb[4] - bb[5])));
   double max_side = radius_sphere_ / 2.0;
   double scale_factor = max_side / ms;
 
-  vtkSmartPointer<vtkTransform> trans_scale = vtkSmartPointer<vtkTransform>::New ();
-  trans_scale->Scale (scale_factor, scale_factor, scale_factor);
-  vtkSmartPointer<vtkMatrix4x4> matrixScale = trans_scale->GetMatrix ();
+  vtkSmartPointer<vtkTransform> trans_scale = vtkSmartPointer<vtkTransform>::New();
+  trans_scale->Scale(scale_factor, scale_factor, scale_factor);
+  vtkSmartPointer<vtkMatrix4x4> matrixScale = trans_scale->GetMatrix();
 
-  vtkSmartPointer<vtkTransformFilter> trans_filter_scale = vtkSmartPointer<vtkTransformFilter>::New ();
-  trans_filter_scale->SetTransform (trans_scale);
-  trans_filter_scale->SetInputConnection (trans_filter_center->GetOutputPort ());
-  trans_filter_scale->Update ();
+  vtkSmartPointer<vtkTransformFilter> trans_filter_scale =
+      vtkSmartPointer<vtkTransformFilter>::New();
+  trans_filter_scale->SetTransform(trans_scale);
+  trans_filter_scale->SetInputConnection(trans_filter_center->GetOutputPort());
+  trans_filter_scale->Update();
 
-  mapper->SetInputConnection (trans_filter_scale->GetOutputPort ());
-  mapper->Update ();
+  mapper->SetInputConnection(trans_filter_scale->GetOutputPort());
+  mapper->Update();
 
   //////////////////////////////
   // * Compute area of the mesh
   //////////////////////////////
-  vtkSmartPointer<vtkCellArray> cells = mapper->GetInput ()->GetPolys ();
+  vtkSmartPointer<vtkCellArray> cells = mapper->GetInput()->GetPolys();
   vtkIdType npts = 0, *ptIds = nullptr;
 
   double p1[3], p2[3], p3[3], totalArea = 0;
-  for (cells->InitTraversal (); cells->GetNextCell (npts, ptIds);)
-  {
-    polydata_->GetPoint (ptIds[0], p1);
-    polydata_->GetPoint (ptIds[1], p2);
-    polydata_->GetPoint (ptIds[2], p3);
-    totalArea += vtkTriangle::TriangleArea (p1, p2, p3);
+  for (cells->InitTraversal(); cells->GetNextCell(npts, ptIds);) {
+    polydata_->GetPoint(ptIds[0], p1);
+    polydata_->GetPoint(ptIds[1], p2);
+    polydata_->GetPoint(ptIds[2], p3);
+    totalArea += vtkTriangle::TriangleArea(p1, p2, p3);
   }
 
-  //create icosahedron
-  vtkSmartPointer<vtkPlatonicSolidSource> ico = vtkSmartPointer<vtkPlatonicSolidSource>::New ();
-  ico->SetSolidTypeToIcosahedron ();
-  ico->Update ();
-
-  //tessellate cells from icosahedron
-  vtkSmartPointer<vtkLoopSubdivisionFilter> subdivide = vtkSmartPointer<vtkLoopSubdivisionFilter>::New ();
-  subdivide->SetNumberOfSubdivisions (tesselation_level_);
-  subdivide->SetInputConnection (ico->GetOutputPort ());
+  // create icosahedron
+  vtkSmartPointer<vtkPlatonicSolidSource> ico =
+      vtkSmartPointer<vtkPlatonicSolidSource>::New();
+  ico->SetSolidTypeToIcosahedron();
+  ico->Update();
+
+  // tessellate cells from icosahedron
+  vtkSmartPointer<vtkLoopSubdivisionFilter> subdivide =
+      vtkSmartPointer<vtkLoopSubdivisionFilter>::New();
+  subdivide->SetNumberOfSubdivisions(tesselation_level_);
+  subdivide->SetInputConnection(ico->GetOutputPort());
   subdivide->Update();
 
   // Get camera positions
-  vtkPolyData *sphere = subdivide->GetOutput ();
-
-  std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > cam_positions;
-  if (!use_vertices_)
-  {
-    vtkSmartPointer<vtkCellArray> cells_sphere = sphere->GetPolys ();
-    cam_positions.resize (sphere->GetNumberOfPolys ());
-
-    std::size_t i=0;
-    for (cells_sphere->InitTraversal (); cells_sphere->GetNextCell (npts_com, ptIds_com);)
-    {
-      sphere->GetPoint (ptIds_com[0], p1_com);
-      sphere->GetPoint (ptIds_com[1], p2_com);
-      sphere->GetPoint (ptIds_com[2], p3_com);
-      vtkTriangle::TriangleCenter (p1_com, p2_com, p3_com, center);
-      cam_positions[i] = Eigen::Vector3f (float (center[0]), float (center[1]), float (center[2]));
+  vtkPolyData* sphere = subdivide->GetOutput();
+
+  std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>> cam_positions;
+  if (!use_vertices_) {
+    vtkSmartPointer<vtkCellArray> cells_sphere = sphere->GetPolys();
+    cam_positions.resize(sphere->GetNumberOfPolys());
+
+    std::size_t i = 0;
+    for (cells_sphere->InitTraversal();
+         cells_sphere->GetNextCell(npts_com, ptIds_com);) {
+      sphere->GetPoint(ptIds_com[0], p1_com);
+      sphere->GetPoint(ptIds_com[1], p2_com);
+      sphere->GetPoint(ptIds_com[2], p3_com);
+      vtkTriangle::TriangleCenter(p1_com, p2_com, p3_com, center);
+      cam_positions[i] =
+          Eigen::Vector3f(float(center[0]), float(center[1]), float(center[2]));
       i++;
     }
-
   }
-  else
-  {
-    cam_positions.resize (sphere->GetNumberOfPoints ());
-    for (vtkIdType i = 0; i < sphere->GetNumberOfPoints (); i++)
-    {
+  else {
+    cam_positions.resize(sphere->GetNumberOfPoints());
+    for (vtkIdType i = 0; i < sphere->GetNumberOfPoints(); i++) {
       double cam_pos[3];
-      sphere->GetPoint (i, cam_pos);
-      cam_positions[i] = Eigen::Vector3f (float (cam_pos[0]), float (cam_pos[1]), float (cam_pos[2]));
+      sphere->GetPoint(i, cam_pos);
+      cam_positions[i] =
+          Eigen::Vector3f(float(cam_pos[0]), float(cam_pos[1]), float(cam_pos[2]));
     }
   }
 
@@ -164,297 +168,295 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() {
   first_cam_pos[1] = cam_positions[0][1] * radius_sphere_;
   first_cam_pos[2] = cam_positions[0][2] * radius_sphere_;
 
-  //create renderer and window
-  vtkSmartPointer<vtkRenderWindow> render_win = vtkSmartPointer<vtkRenderWindow>::New ();
-  vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New ();
-  render_win->AddRenderer (renderer);
-  render_win->SetSize (resolution_, resolution_);
-  renderer->SetBackground (1.0, 0, 0);
+  // create renderer and window
+  vtkSmartPointer<vtkRenderWindow> render_win = vtkSmartPointer<vtkRenderWindow>::New();
+  vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
+  render_win->AddRenderer(renderer);
+  render_win->SetSize(resolution_, resolution_);
+  renderer->SetBackground(1.0, 0, 0);
 
-  //create picker
-  vtkSmartPointer<vtkWorldPointPicker> worldPicker = vtkSmartPointer<vtkWorldPointPicker>::New ();
+  // create picker
+  vtkSmartPointer<vtkWorldPointPicker> worldPicker =
+      vtkSmartPointer<vtkWorldPointPicker>::New();
 
-  vtkSmartPointer<vtkCamera> cam = vtkSmartPointer<vtkCamera>::New ();
-  cam->SetFocalPoint (0, 0, 0);
+  vtkSmartPointer<vtkCamera> cam = vtkSmartPointer<vtkCamera>::New();
+  cam->SetFocalPoint(0, 0, 0);
 
   Eigen::Vector3f cam_pos_3f = cam_positions[0];
-  Eigen::Vector3f perp = cam_pos_3f.cross (Eigen::Vector3f::UnitY ());
-  cam->SetViewUp (perp[0], perp[1], perp[2]);
+  Eigen::Vector3f perp = cam_pos_3f.cross(Eigen::Vector3f::UnitY());
+  cam->SetViewUp(perp[0], perp[1], perp[2]);
 
-  cam->SetPosition (first_cam_pos.data());
-  cam->SetViewAngle (view_angle_);
-  cam->Modified ();
+  cam->SetPosition(first_cam_pos.data());
+  cam->SetViewAngle(view_angle_);
+  cam->Modified();
 
-  //For each camera position, traposesnsform the object and render view
-  for (const auto &cam_position : cam_positions)
-  {
+  // For each camera position, traposesnsform the object and render view
+  for (const auto& cam_position : cam_positions) {
     cam_pos[0] = cam_position[0];
     cam_pos[1] = cam_position[1];
     cam_pos[2] = cam_position[2];
 
-    //create temporal virtual camera
-    vtkSmartPointer<vtkCamera> cam_tmp = vtkSmartPointer<vtkCamera>::New ();
-    cam_tmp->SetViewAngle (view_angle_);
-
-    Eigen::Vector3f cam_pos_3f (static_cast<float> (cam_pos[0]), static_cast<float> (cam_pos[1]), static_cast<float> (cam_pos[2]));
-    cam_pos_3f = cam_pos_3f.normalized ();
-    Eigen::Vector3f test = Eigen::Vector3f::UnitY ();
-
-    //If the view up is parallel to ray cam_pos - focalPoint then the transformation
-    //is singular and no points are rendered...
-    //make sure it is perpendicular
-    if (std::abs (cam_pos_3f.dot (test)) == 1)
-    {
-      //parallel, create
-      test = cam_pos_3f.cross (Eigen::Vector3f::UnitX ());
+    // create temporal virtual camera
+    vtkSmartPointer<vtkCamera> cam_tmp = vtkSmartPointer<vtkCamera>::New();
+    cam_tmp->SetViewAngle(view_angle_);
+
+    Eigen::Vector3f cam_pos_3f(static_cast<float>(cam_pos[0]),
+                               static_cast<float>(cam_pos[1]),
+                               static_cast<float>(cam_pos[2]));
+    cam_pos_3f = cam_pos_3f.normalized();
+    Eigen::Vector3f test = Eigen::Vector3f::UnitY();
+
+    // If the view up is parallel to ray cam_pos - focalPoint then the transformation
+    // is singular and no points are rendered...
+    // make sure it is perpendicular
+    if (std::abs(cam_pos_3f.dot(test)) == 1) {
+      // parallel, create
+      test = cam_pos_3f.cross(Eigen::Vector3f::UnitX());
     }
 
-    cam_tmp->SetViewUp (test[0], test[1], test[2]);
+    cam_tmp->SetViewUp(test[0], test[1], test[2]);
 
-    for (double &cam_po : cam_pos)
-    {
+    for (double& cam_po : cam_pos) {
       cam_po *= camera_radius;
     }
 
-    cam_tmp->SetPosition (cam_pos.data());
-    cam_tmp->SetFocalPoint (0, 0, 0);
-    cam_tmp->Modified ();
-
-    //rotate model so it looks the same as if we would look from the new position
-    vtkSmartPointer<vtkMatrix4x4> view_trans_inverted = vtkSmartPointer<vtkMatrix4x4>::New ();
-    vtkMatrix4x4::Invert (cam->GetViewTransformMatrix (), view_trans_inverted);
-    vtkSmartPointer<vtkTransform> trans_rot_pose = vtkSmartPointer<vtkTransform>::New ();
-    trans_rot_pose->Identity ();
-    trans_rot_pose->Concatenate (view_trans_inverted);
-    trans_rot_pose->Concatenate (cam_tmp->GetViewTransformMatrix ());
-    vtkSmartPointer<vtkTransformFilter> trans_rot_pose_filter = vtkSmartPointer<vtkTransformFilter>::New ();
-    trans_rot_pose_filter->SetTransform (trans_rot_pose);
-    trans_rot_pose_filter->SetInputConnection (trans_filter_scale->GetOutputPort ());
-
-    //translate model so we can place camera at (0,0,0)
-    vtkSmartPointer<vtkTransform> translation = vtkSmartPointer<vtkTransform>::New ();
-    translation->Translate (first_cam_pos[0] * -1, first_cam_pos[1] * -1, first_cam_pos[2] * -1);
-    vtkSmartPointer<vtkTransformFilter> translation_filter = vtkSmartPointer<vtkTransformFilter>::New ();
-    translation_filter->SetTransform (translation);
-    translation_filter->SetInputConnection (trans_rot_pose_filter->GetOutputPort ());
-
-    //modify camera
-    cam_tmp->SetPosition (0, 0, 0);
-    cam_tmp->SetFocalPoint (first_cam_pos[0] * -1, first_cam_pos[1] * -1, first_cam_pos[2] * -1);
-    cam_tmp->Modified ();
-
-    //notice transformations for final pose
-    vtkSmartPointer<vtkMatrix4x4> matrixRotModel = trans_rot_pose->GetMatrix ();
-    vtkSmartPointer<vtkMatrix4x4> matrixTranslation = translation->GetMatrix ();
-
-    mapper->SetInputConnection (translation_filter->GetOutputPort ());
-    mapper->Update ();
-
-    //render view
-    vtkSmartPointer<vtkActor> actor_view = vtkSmartPointer<vtkActor>::New ();
-    actor_view->SetMapper (mapper);
-    renderer->SetActiveCamera (cam_tmp);
-    renderer->AddActor (actor_view);
-    renderer->Modified ();
-    //renderer->ResetCameraClippingRange ();
-    render_win->Render ();
-
-    //back to real scale transform
-    vtkSmartPointer<vtkTransform> backToRealScale = vtkSmartPointer<vtkTransform>::New ();
-    backToRealScale->PostMultiply ();
-    backToRealScale->Identity ();
-    backToRealScale->Concatenate (matrixScale);
-    backToRealScale->Concatenate (matrixTranslation);
-    backToRealScale->Inverse ();
-    backToRealScale->Modified ();
-    backToRealScale->Concatenate (matrixTranslation);
-    backToRealScale->Modified ();
+    cam_tmp->SetPosition(cam_pos.data());
+    cam_tmp->SetFocalPoint(0, 0, 0);
+    cam_tmp->Modified();
+
+    // rotate model so it looks the same as if we would look from the new position
+    vtkSmartPointer<vtkMatrix4x4> view_trans_inverted =
+        vtkSmartPointer<vtkMatrix4x4>::New();
+    vtkMatrix4x4::Invert(cam->GetViewTransformMatrix(), view_trans_inverted);
+    vtkSmartPointer<vtkTransform> trans_rot_pose = vtkSmartPointer<vtkTransform>::New();
+    trans_rot_pose->Identity();
+    trans_rot_pose->Concatenate(view_trans_inverted);
+    trans_rot_pose->Concatenate(cam_tmp->GetViewTransformMatrix());
+    vtkSmartPointer<vtkTransformFilter> trans_rot_pose_filter =
+        vtkSmartPointer<vtkTransformFilter>::New();
+    trans_rot_pose_filter->SetTransform(trans_rot_pose);
+    trans_rot_pose_filter->SetInputConnection(trans_filter_scale->GetOutputPort());
+
+    // translate model so we can place camera at (0,0,0)
+    vtkSmartPointer<vtkTransform> translation = vtkSmartPointer<vtkTransform>::New();
+    translation->Translate(
+        first_cam_pos[0] * -1, first_cam_pos[1] * -1, first_cam_pos[2] * -1);
+    vtkSmartPointer<vtkTransformFilter> translation_filter =
+        vtkSmartPointer<vtkTransformFilter>::New();
+    translation_filter->SetTransform(translation);
+    translation_filter->SetInputConnection(trans_rot_pose_filter->GetOutputPort());
+
+    // modify camera
+    cam_tmp->SetPosition(0, 0, 0);
+    cam_tmp->SetFocalPoint(
+        first_cam_pos[0] * -1, first_cam_pos[1] * -1, first_cam_pos[2] * -1);
+    cam_tmp->Modified();
+
+    // notice transformations for final pose
+    vtkSmartPointer<vtkMatrix4x4> matrixRotModel = trans_rot_pose->GetMatrix();
+    vtkSmartPointer<vtkMatrix4x4> matrixTranslation = translation->GetMatrix();
+
+    mapper->SetInputConnection(translation_filter->GetOutputPort());
+    mapper->Update();
+
+    // render view
+    vtkSmartPointer<vtkActor> actor_view = vtkSmartPointer<vtkActor>::New();
+    actor_view->SetMapper(mapper);
+    renderer->SetActiveCamera(cam_tmp);
+    renderer->AddActor(actor_view);
+    renderer->Modified();
+    // renderer->ResetCameraClippingRange ();
+    render_win->Render();
+
+    // back to real scale transform
+    vtkSmartPointer<vtkTransform> backToRealScale =
+        vtkSmartPointer<vtkTransform>::New();
+    backToRealScale->PostMultiply();
+    backToRealScale->Identity();
+    backToRealScale->Concatenate(matrixScale);
+    backToRealScale->Concatenate(matrixTranslation);
+    backToRealScale->Inverse();
+    backToRealScale->Modified();
+    backToRealScale->Concatenate(matrixTranslation);
+    backToRealScale->Modified();
 
     Eigen::Matrix4f backToRealScale_eigen;
-    backToRealScale_eigen.setIdentity ();
+    backToRealScale_eigen.setIdentity();
 
     for (int x = 0; x < 4; x++)
       for (int y = 0; y < 4; y++)
-        backToRealScale_eigen (x, y) = float (backToRealScale->GetMatrix ()->GetElement (x, y));
+        backToRealScale_eigen(x, y) =
+            float(backToRealScale->GetMatrix()->GetElement(x, y));
 
-    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
-    cloud->points.resize (resolution_ * resolution_);
+    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
+    cloud->points.resize(resolution_ * resolution_);
 
-    if (gen_organized_)
-    {
+    if (gen_organized_) {
       cloud->width = resolution_;
       cloud->height = resolution_;
       cloud->is_dense = false;
 
       double coords[3];
-      float * depth = new float[resolution_ * resolution_];
-      render_win->GetZbufferData (0, 0, resolution_ - 1, resolution_ - 1, &(depth[0]));
+      float* depth = new float[resolution_ * resolution_];
+      render_win->GetZbufferData(0, 0, resolution_ - 1, resolution_ - 1, &(depth[0]));
 
-      for (int x = 0; x < resolution_; x++)
-      {
-        for (int y = 0; y < resolution_; y++)
-        {
+      for (int x = 0; x < resolution_; x++) {
+        for (int y = 0; y < resolution_; y++) {
           float value = depth[y * resolution_ + x];
-          if (value == 1.0)
-          {
-            cloud->at (y, x).x = cloud->at (y, x).y = cloud->at (y, x).z = std::numeric_limits<float>::quiet_NaN ();
+          if (value == 1.0) {
+            cloud->at(y, x).x = cloud->at(y, x).y = cloud->at(y, x).z =
+                std::numeric_limits<float>::quiet_NaN();
           }
-          else
-          {
-            worldPicker->Pick (x, y, value, renderer);
-            worldPicker->GetPickPosition (coords);
-            cloud->at (y, x).x = static_cast<float> (coords[0]);
-            cloud->at (y, x).y = static_cast<float> (coords[1]);
-            cloud->at (y, x).z = static_cast<float> (coords[2]);
-            cloud->at (y, x).getVector4fMap () = backToRealScale_eigen
-                                  * cloud->at (y, x).getVector4fMap ();
+          else {
+            worldPicker->Pick(x, y, value, renderer);
+            worldPicker->GetPickPosition(coords);
+            cloud->at(y, x).x = static_cast<float>(coords[0]);
+            cloud->at(y, x).y = static_cast<float>(coords[1]);
+            cloud->at(y, x).z = static_cast<float>(coords[2]);
+            cloud->at(y, x).getVector4fMap() =
+                backToRealScale_eigen * cloud->at(y, x).getVector4fMap();
           }
         }
       }
 
       delete[] depth;
-
     }
-    else
-    {
+    else {
       cloud->width = resolution_ * resolution_;
       cloud->height = 1;
 
       double coords[3];
-      float * depth = new float[resolution_ * resolution_];
-      render_win->GetZbufferData (0, 0, resolution_ - 1, resolution_ - 1, &(depth[0]));
+      float* depth = new float[resolution_ * resolution_];
+      render_win->GetZbufferData(0, 0, resolution_ - 1, resolution_ - 1, &(depth[0]));
 
       int count_valid_depth_pixels = 0;
-      for (int x = 0; x < resolution_; x++)
-      {
-        for (int y = 0; y < resolution_; y++)
-        {
+      for (int x = 0; x < resolution_; x++) {
+        for (int y = 0; y < resolution_; y++) {
           float value = depth[y * resolution_ + x];
           if (value == 1.0)
             continue;
 
-          worldPicker->Pick (x, y, value, renderer);
-          worldPicker->GetPickPosition (coords);
-          cloud->points[count_valid_depth_pixels].x = static_cast<float> (coords[0]);
-          cloud->points[count_valid_depth_pixels].y = static_cast<float> (coords[1]);
-          cloud->points[count_valid_depth_pixels].z = static_cast<float> (coords[2]);
-          cloud->points[count_valid_depth_pixels].getVector4fMap () = backToRealScale_eigen
-                      * cloud->points[count_valid_depth_pixels].getVector4fMap ();
+          worldPicker->Pick(x, y, value, renderer);
+          worldPicker->GetPickPosition(coords);
+          cloud->points[count_valid_depth_pixels].x = static_cast<float>(coords[0]);
+          cloud->points[count_valid_depth_pixels].y = static_cast<float>(coords[1]);
+          cloud->points[count_valid_depth_pixels].z = static_cast<float>(coords[2]);
+          cloud->points[count_valid_depth_pixels].getVector4fMap() =
+              backToRealScale_eigen *
+              cloud->points[count_valid_depth_pixels].getVector4fMap();
           count_valid_depth_pixels++;
         }
       }
 
       delete[] depth;
 
-      cloud->points.resize (count_valid_depth_pixels);
+      cloud->points.resize(count_valid_depth_pixels);
       cloud->width = count_valid_depth_pixels;
     }
 
-    if(compute_entropy_) {
+    if (compute_entropy_) {
       //////////////////////////////
       // * Compute area of the mesh
       //////////////////////////////
 
-      vtkSmartPointer<vtkPolyData> polydata = mapper->GetInput ();
-      polydata->BuildCells ();
+      vtkSmartPointer<vtkPolyData> polydata = mapper->GetInput();
+      polydata->BuildCells();
 
-      vtkSmartPointer<vtkCellArray> cells = polydata->GetPolys ();
+      vtkSmartPointer<vtkCellArray> cells = polydata->GetPolys();
       vtkIdType npts = 0, *ptIds = nullptr;
 
       double p1[3], p2[3], p3[3], area, totalArea = 0;
-      for (cells->InitTraversal (); cells->GetNextCell (npts, ptIds);)
-      {
-        polydata->GetPoint (ptIds[0], p1);
-        polydata->GetPoint (ptIds[1], p2);
-        polydata->GetPoint (ptIds[2], p3);
-        area = vtkTriangle::TriangleArea (p1, p2, p3);
+      for (cells->InitTraversal(); cells->GetNextCell(npts, ptIds);) {
+        polydata->GetPoint(ptIds[0], p1);
+        polydata->GetPoint(ptIds[1], p2);
+        polydata->GetPoint(ptIds[2], p3);
+        area = vtkTriangle::TriangleArea(p1, p2, p3);
         totalArea += area;
       }
 
       /////////////////////////////////////
       // * Select visible cells (triangles)
       /////////////////////////////////////
-      vtkSmartPointer<vtkHardwareSelector> hardware_selector = vtkSmartPointer<vtkHardwareSelector>::New ();
+      vtkSmartPointer<vtkHardwareSelector> hardware_selector =
+          vtkSmartPointer<vtkHardwareSelector>::New();
       hardware_selector->ClearBuffers();
-      vtkSmartPointer<vtkSelection> hdw_selection = vtkSmartPointer<vtkSelection>::New ();
-      hardware_selector->SetRenderer (renderer);
-      hardware_selector->SetArea (0, 0, resolution_ - 1, resolution_ - 1);
+      vtkSmartPointer<vtkSelection> hdw_selection =
+          vtkSmartPointer<vtkSelection>::New();
+      hardware_selector->SetRenderer(renderer);
+      hardware_selector->SetArea(0, 0, resolution_ - 1, resolution_ - 1);
       hardware_selector->SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_CELLS);
-      hdw_selection = hardware_selector->Select ();
-      vtkSmartPointer<vtkIdTypeArray> ids = vtkSmartPointer<vtkIdTypeArray>::New ();
+      hdw_selection = hardware_selector->Select();
+      vtkSmartPointer<vtkIdTypeArray> ids = vtkSmartPointer<vtkIdTypeArray>::New();
       ids = vtkIdTypeArray::SafeDownCast(hdw_selection->GetNode(0)->GetSelectionList());
       double visible_area = 0;
-      for (vtkIdType sel_id = 0; sel_id < (ids->GetNumberOfTuples ()); sel_id++)
-      {
-        int id_mesh = int (ids->GetValue (sel_id));
-        if(id_mesh >= polydata->GetNumberOfPolys())
+      for (vtkIdType sel_id = 0; sel_id < (ids->GetNumberOfTuples()); sel_id++) {
+        int id_mesh = int(ids->GetValue(sel_id));
+        if (id_mesh >= polydata->GetNumberOfPolys())
           continue;
 
-        vtkCell * cell = polydata->GetCell (id_mesh);
-        vtkTriangle* triangle = dynamic_cast<vtkTriangle*> (cell);
+        vtkCell* cell = polydata->GetCell(id_mesh);
+        vtkTriangle* triangle = dynamic_cast<vtkTriangle*>(cell);
         double p0[3];
         double p1[3];
         double p2[3];
-        triangle->GetPoints ()->GetPoint (0, p0);
-        triangle->GetPoints ()->GetPoint (1, p1);
-        triangle->GetPoints ()->GetPoint (2, p2);
-        area = vtkTriangle::TriangleArea (p0, p1, p2);
+        triangle->GetPoints()->GetPoint(0, p0);
+        triangle->GetPoints()->GetPoint(1, p1);
+        triangle->GetPoints()->GetPoint(2, p2);
+        area = vtkTriangle::TriangleArea(p0, p1, p2);
         visible_area += area;
       }
 
-      entropies_.push_back (float (visible_area / totalArea));
+      entropies_.push_back(float(visible_area / totalArea));
     }
 
-    //transform cloud to give camera coordinates instead of world coordinates!
-    vtkSmartPointer<vtkMatrix4x4> view_transform = cam_tmp->GetViewTransformMatrix ();
+    // transform cloud to give camera coordinates instead of world coordinates!
+    vtkSmartPointer<vtkMatrix4x4> view_transform = cam_tmp->GetViewTransformMatrix();
     Eigen::Matrix4f trans_view;
-    trans_view.setIdentity ();
+    trans_view.setIdentity();
 
     for (int x = 0; x < 4; x++)
       for (int y = 0; y < 4; y++)
-        trans_view (x, y) = float (view_transform->GetElement (x, y));
+        trans_view(x, y) = float(view_transform->GetElement(x, y));
 
-    //NOTE: vtk view coordinate system is different than the standard camera coordinates (z forward, y down, x right)
-    //thus, the fliping in y and z
-    for (auto &point : cloud->points)
-    {
-      point.getVector4fMap () = trans_view * point.getVector4fMap ();
+    // NOTE: vtk view coordinate system is different than the standard camera
+    // coordinates (z forward, y down, x right) thus, the fliping in y and z
+    for (auto& point : cloud->points) {
+      point.getVector4fMap() = trans_view * point.getVector4fMap();
       point.y *= -1.0f;
       point.z *= -1.0f;
     }
 
-    renderer->RemoveActor (actor_view);
+    renderer->RemoveActor(actor_view);
 
-    generated_views_.push_back (cloud);
+    generated_views_.push_back(cloud);
 
-    //create pose, from OBJECT coordinates to CAMERA coordinates!
-    vtkSmartPointer<vtkTransform> transOCtoCC = vtkSmartPointer<vtkTransform>::New ();
-    transOCtoCC->PostMultiply ();
-    transOCtoCC->Identity ();
-    transOCtoCC->Concatenate (matrixCenter);
-    transOCtoCC->Concatenate (matrixRotModel);
-    transOCtoCC->Concatenate (matrixTranslation);
-    transOCtoCC->Concatenate (cam_tmp->GetViewTransformMatrix ());
+    // create pose, from OBJECT coordinates to CAMERA coordinates!
+    vtkSmartPointer<vtkTransform> transOCtoCC = vtkSmartPointer<vtkTransform>::New();
+    transOCtoCC->PostMultiply();
+    transOCtoCC->Identity();
+    transOCtoCC->Concatenate(matrixCenter);
+    transOCtoCC->Concatenate(matrixRotModel);
+    transOCtoCC->Concatenate(matrixTranslation);
+    transOCtoCC->Concatenate(cam_tmp->GetViewTransformMatrix());
 
-    //NOTE: vtk view coordinate system is different than the standard camera coordinates (z forward, y down, x right)
-    //thus, the fliping in y and z
-    vtkSmartPointer<vtkMatrix4x4> cameraSTD = vtkSmartPointer<vtkMatrix4x4>::New ();
-    cameraSTD->Identity ();
-    cameraSTD->SetElement (0, 0, 1);
-    cameraSTD->SetElement (1, 1, -1);
-    cameraSTD->SetElement (2, 2, -1);
+    // NOTE: vtk view coordinate system is different than the standard camera
+    // coordinates (z forward, y down, x right) thus, the fliping in y and z
+    vtkSmartPointer<vtkMatrix4x4> cameraSTD = vtkSmartPointer<vtkMatrix4x4>::New();
+    cameraSTD->Identity();
+    cameraSTD->SetElement(0, 0, 1);
+    cameraSTD->SetElement(1, 1, -1);
+    cameraSTD->SetElement(2, 2, -1);
 
-    transOCtoCC->Concatenate (cameraSTD);
-    transOCtoCC->Modified ();
+    transOCtoCC->Concatenate(cameraSTD);
+    transOCtoCC->Modified();
 
     Eigen::Matrix4f pose_view;
-    pose_view.setIdentity ();
+    pose_view.setIdentity();
 
     for (int x = 0; x < 4; x++)
       for (int y = 0; y < 4; y++)
-        pose_view (x, y) = float (transOCtoCC->GetMatrix ()->GetElement (x, y));
-
-    poses_.push_back (pose_view);
+        pose_view(x, y) = float(transOCtoCC->GetMatrix()->GetElement(x, y));
 
+    poses_.push_back(pose_view);
   }
 }
index 1e1da0b211076f93771ab620ba0842181117128e..50b883906e8da9832d6d44830856b6ba85c05deb 100644 (file)
  */
 
 #include <pcl/features/statistical_multiscale_interest_region_extraction.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/filters/voxel_grid.h>
 #include <pcl/filters/extract_indices.h>
-
+#include <pcl/filters/voxel_grid.h>
+#include <pcl/io/pcd_io.h>
 
 using namespace pcl;
 using namespace std;
@@ -47,56 +46,55 @@ using namespace std;
 const float subsampling_leaf_size = 0.003f;
 const float base_scale = 0.005f;
 
-
 int
-main (int, char **argv)
+main(int, char** argv)
 {
-  PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ> ());
+  PointCloud<PointXYZ>::Ptr cloud(new PointCloud<PointXYZ>());
 
   PCDReader reader;
-  reader.read (argv[1], *cloud);
-  PCL_INFO ("Cloud read: %s\n", argv[1]);
-  std::cerr << "cloud has #points: " << cloud->points.size () << std::endl;
+  reader.read(argv[1], *cloud);
+  PCL_INFO("Cloud read: %s\n", argv[1]);
+  std::cerr << "cloud has #points: " << cloud->points.size() << std::endl;
 
-  PointCloud<PointXYZ>::Ptr cloud_subsampled (new PointCloud<PointXYZ> ());
+  PointCloud<PointXYZ>::Ptr cloud_subsampled(new PointCloud<PointXYZ>());
   VoxelGrid<PointXYZ> subsampling_filter;
-  subsampling_filter.setInputCloud (cloud);
-  subsampling_filter.setLeafSize (subsampling_leaf_size, subsampling_leaf_size, subsampling_leaf_size);
-  subsampling_filter.filter (*cloud_subsampled);
-  std::cerr << "subsampled cloud has #points: " << cloud_subsampled->points.size () << std::endl;
+  subsampling_filter.setInputCloud(cloud);
+  subsampling_filter.setLeafSize(
+      subsampling_leaf_size, subsampling_leaf_size, subsampling_leaf_size);
+  subsampling_filter.filter(*cloud_subsampled);
+  std::cerr << "subsampled cloud has #points: " << cloud_subsampled->points.size()
+            << std::endl;
 
   StatisticalMultiscaleInterestRegionExtraction<PointXYZ> region_extraction;
   std::vector<float> scale_vector;
-  PCL_INFO ("Scale values that will be used: ");
+  PCL_INFO("Scale values that will be used: ");
   float base_scale_aux = base_scale;
-  for (std::size_t scales = 0; scales < 7; ++scales)
-  {
-    PCL_INFO ("%f ", base_scale_aux);
-    scale_vector.push_back (base_scale_aux);
+  for (std::size_t scales = 0; scales < 7; ++scales) {
+    PCL_INFO("%f ", base_scale_aux);
+    scale_vector.push_back(base_scale_aux);
     base_scale_aux *= 1.6f;
   }
-  PCL_INFO ("\n");
-  region_extraction.setInputCloud (cloud_subsampled);
-  region_extraction.setScalesVector (scale_vector);
+  PCL_INFO("\n");
+  region_extraction.setInputCloud(cloud_subsampled);
+  region_extraction.setScalesVector(scale_vector);
   std::list<IndicesPtr> rois;
-  region_extraction.computeRegionsOfInterest (rois);
+  region_extraction.computeRegionsOfInterest(rois);
 
-  PCL_INFO ("Regions of interest found: %d\n", rois.size ());
+  PCL_INFO("Regions of interest found: %d\n", rois.size());
   pcl::ExtractIndices<PointXYZ> extract_indices_filter;
   unsigned int roi_count = 0;
-  for (const auto &roi : rois)
-  {
+  for (const auto& roi : rois) {
     PointCloud<PointXYZ> roi_points;
-    extract_indices_filter.setInputCloud (cloud_subsampled);
-    extract_indices_filter.setIndices (roi);
-    extract_indices_filter.filter (roi_points);
+    extract_indices_filter.setInputCloud(cloud_subsampled);
+    extract_indices_filter.setIndices(roi);
+    extract_indices_filter.filter(roi_points);
 
     char filename[512];
-    sprintf (filename, "roi_%03d.pcd", ++roi_count);
-    io::savePCDFileASCII (filename, roi_points);
+    sprintf(filename, "roi_%03d.pcd", ++roi_count);
+    io::savePCDFileASCII(filename, roi_points);
   }
 
-  io::savePCDFileASCII ("subsampled_input.pcd", *cloud_subsampled);
+  io::savePCDFileASCII("subsampled_input.pcd", *cloud_subsampled);
 
   return 0;
 }
index 35aaf5964603068b15f6715be59433d89cd5de6b..c3e32ac8bc300c9ddb0d798187bc5d2dc7c2c7ae 100755 (executable)
  *
  */
 
-#include <pcl/io/openni_grabber.h>
-#include <pcl/visualization/cloud_viewer.h>
-#include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/visualization/image_viewer.h>
-#include <pcl/io/io.h>
-#include <pcl/io/ply_io.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/io/png_io.h>
-#include <pcl/io/pcd_grabber.h>
-#include <pcl/common/time.h>
 #include <pcl/common/distances.h>
 #include <pcl/common/intersections.h>
+#include <pcl/common/time.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/ModelCoefficients.h>
-#include <pcl/segmentation/planar_region.h>
-#include <pcl/segmentation/organized_multi_plane_segmentation.h>
-#include <pcl/segmentation/organized_connected_component_segmentation.h>
 #include <pcl/filters/extract_indices.h>
+#include <pcl/io/io.h>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/io/pcd_grabber.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/io/ply_io.h>
+#include <pcl/io/png_io.h>
 #include <pcl/sample_consensus/sac_model_plane.h>
-#include <pcl/stereo/stereo_matching.h>
-#include <pcl/segmentation/ground_plane_comparator.h>
 #include <pcl/segmentation/euclidean_cluster_comparator.h>
+#include <pcl/segmentation/ground_plane_comparator.h>
+#include <pcl/segmentation/organized_connected_component_segmentation.h>
+#include <pcl/segmentation/organized_multi_plane_segmentation.h>
+#include <pcl/segmentation/planar_region.h>
+#include <pcl/stereo/stereo_matching.h>
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/visualization/image_viewer.h>
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/ModelCoefficients.h>
 
 #include <mutex>
 
@@ -64,509 +64,506 @@ using Cloud = pcl::PointCloud<PointT>;
 using CloudPtr = Cloud::Ptr;
 using CloudConstPtr = Cloud::ConstPtr;
 
-  /** \brief StereoGroundSegmentation is a demonstration application for using PCL's stereo tools and segmentation tools to detect smooth surfaces suitable for driving.
-    *
-    * \author Alex Trevor
-    */
-class HRCSSegmentation
-{
-  private:
-    pcl::visualization::PCLVisualizer::Ptr viewer;
-    pcl::visualization::ImageViewer::Ptr image_viewer;
-    pcl::PointCloud<PointT>::ConstPtr prev_cloud;
-    pcl::PointCloud<pcl::Normal>::ConstPtr prev_normal_cloud;
-    pcl::PointCloud<pcl::PointXYZ>::ConstPtr prev_ground_cloud;
-    pcl::PointCloud<PointT>::ConstPtr prev_ground_image;
-    pcl::PointCloud<PointT>::ConstPtr prev_label_image;
-    Eigen::Vector4f prev_ground_normal;
-    Eigen::Vector4f prev_ground_centroid;
-    std::mutex cloud_mutex;
-
-    pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
-    pcl::GroundPlaneComparator<PointT, pcl::Normal>::Ptr road_comparator;
-    pcl::OrganizedConnectedComponentSegmentation<PointT, pcl::Label> road_segmentation;
-    std::vector<std::string> left_images;
-    std::vector<std::string> right_images;
-    int files_idx;
-    int images_idx;
-
-    pcl::AdaptiveCostSOStereoMatching stereo;
-    bool trigger;
-    bool continuous;
-    bool display_normals;
-    bool detect_obstacles;
-    int smooth_weak;
-    int smooth_strong;
-
-  public:
-    HRCSSegmentation (const std::vector<std::string> &left_images, const std::vector<std::string> &right_images) :
-      viewer (new pcl::visualization::PCLVisualizer ("3D Viewer")),
-      image_viewer (new pcl::visualization::ImageViewer ("Image Viewer")),
-      prev_cloud (new pcl::PointCloud<PointT>),
-      prev_normal_cloud (new pcl::PointCloud<pcl::Normal>),
-      prev_ground_cloud (new pcl::PointCloud<pcl::PointXYZ>),
-      prev_ground_image (new pcl::PointCloud<PointT>),
-      prev_label_image (new pcl::PointCloud<PointT>),
-      road_comparator (new pcl::GroundPlaneComparator<PointT, pcl::Normal>),
-      road_segmentation (road_comparator)
-    {
-      trigger = true;
-      continuous = false;
-      display_normals = false;
-      detect_obstacles = false;
-
-      this->left_images = left_images;
-      this->right_images = right_images;
-      files_idx = 0;
-      images_idx = 0;
-      
-      // Set up a 3D viewer
-      viewer->setBackgroundColor (0, 0, 0);
-      viewer->addCoordinateSystem (1.0, "global");
-      viewer->initCameraParameters ();
-      viewer->registerKeyboardCallback (&HRCSSegmentation::keyboardCallback, *this, nullptr);
-      
-      // Set up the stereo matching
-      stereo.setMaxDisparity(60);
-      stereo.setXOffset(0);
-      stereo.setRadius(5);
-      
-      smooth_weak = 20;
-      smooth_strong = 100;
-      stereo.setSmoothWeak(smooth_weak);
-      stereo.setSmoothStrong(smooth_strong);
-      stereo.setGammaC(25);
-      stereo.setGammaS(10);
-      
-      stereo.setRatioFilter(20);
-      stereo.setPeakFilter(0);
-      
-      stereo.setLeftRightCheck(true);
-      stereo.setLeftRightCheckThreshold(1);
-      
-      stereo.setPreProcessing(true);
-      
-      // Set up the normal estimation
-      ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
-      ne.setMaxDepthChangeFactor (0.03f);
-      ne.setNormalSmoothingSize (40.0f);//20.0f
-
-      // Set up the groundplane comparator
-      // If the camera was pointing straight out, the normal would be:
-      Eigen::Vector3f nominal_road_normal (0.0, -1.0, 0.0);
-      // Adjust for camera tilt:
-      Eigen::Vector3f tilt_road_normal = Eigen::AngleAxisf (pcl::deg2rad (5.0f), Eigen::Vector3f::UnitX ()) * nominal_road_normal;
-      road_comparator->setExpectedGroundNormal (tilt_road_normal);
-      road_comparator->setGroundAngularThreshold (pcl::deg2rad (10.0f));   
-      road_comparator->setAngularThreshold (pcl::deg2rad (3.0f));
-    }
-    
-    ~HRCSSegmentation ()
-    {
+/** \brief StereoGroundSegmentation is a demonstration application for using PCL's
+ * stereo tools and segmentation tools to detect smooth surfaces suitable for driving.
+ *
+ * \author Alex Trevor
+ */
+class HRCSSegmentation {
+private:
+  pcl::visualization::PCLVisualizer::Ptr viewer;
+  pcl::visualization::ImageViewer::Ptr image_viewer;
+  pcl::PointCloud<PointT>::ConstPtr prev_cloud;
+  pcl::PointCloud<pcl::Normal>::ConstPtr prev_normal_cloud;
+  pcl::PointCloud<pcl::PointXYZ>::ConstPtr prev_ground_cloud;
+  pcl::PointCloud<PointT>::ConstPtr prev_ground_image;
+  pcl::PointCloud<PointT>::ConstPtr prev_label_image;
+  Eigen::Vector4f prev_ground_normal;
+  Eigen::Vector4f prev_ground_centroid;
+  std::mutex cloud_mutex;
+
+  pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
+  pcl::GroundPlaneComparator<PointT, pcl::Normal>::Ptr road_comparator;
+  pcl::OrganizedConnectedComponentSegmentation<PointT, pcl::Label> road_segmentation;
+  std::vector<std::string> left_images;
+  std::vector<std::string> right_images;
+  int files_idx;
+  int images_idx;
+
+  pcl::AdaptiveCostSOStereoMatching stereo;
+  bool trigger;
+  bool continuous;
+  bool display_normals;
+  bool detect_obstacles;
+  int smooth_weak;
+  int smooth_strong;
+
+public:
+  HRCSSegmentation(const std::vector<std::string>& left_images,
+                   const std::vector<std::string>& right_images)
+  : viewer(new pcl::visualization::PCLVisualizer("3D Viewer"))
+  , image_viewer(new pcl::visualization::ImageViewer("Image Viewer"))
+  , prev_cloud(new pcl::PointCloud<PointT>)
+  , prev_normal_cloud(new pcl::PointCloud<pcl::Normal>)
+  , prev_ground_cloud(new pcl::PointCloud<pcl::PointXYZ>)
+  , prev_ground_image(new pcl::PointCloud<PointT>)
+  , prev_label_image(new pcl::PointCloud<PointT>)
+  , road_comparator(new pcl::GroundPlaneComparator<PointT, pcl::Normal>)
+  , road_segmentation(road_comparator)
+  {
+    trigger = true;
+    continuous = false;
+    display_normals = false;
+    detect_obstacles = false;
+
+    this->left_images = left_images;
+    this->right_images = right_images;
+    files_idx = 0;
+    images_idx = 0;
+
+    // Set up a 3D viewer
+    viewer->setBackgroundColor(0, 0, 0);
+    viewer->addCoordinateSystem(1.0, "global");
+    viewer->initCameraParameters();
+    viewer->registerKeyboardCallback(
+        &HRCSSegmentation::keyboardCallback, *this, nullptr);
+
+    // Set up the stereo matching
+    stereo.setMaxDisparity(60);
+    stereo.setXOffset(0);
+    stereo.setRadius(5);
+
+    smooth_weak = 20;
+    smooth_strong = 100;
+    stereo.setSmoothWeak(smooth_weak);
+    stereo.setSmoothStrong(smooth_strong);
+    stereo.setGammaC(25);
+    stereo.setGammaS(10);
+
+    stereo.setRatioFilter(20);
+    stereo.setPeakFilter(0);
+
+    stereo.setLeftRightCheck(true);
+    stereo.setLeftRightCheckThreshold(1);
+
+    stereo.setPreProcessing(true);
+
+    // Set up the normal estimation
+    ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
+    ne.setMaxDepthChangeFactor(0.03f);
+    ne.setNormalSmoothingSize(40.0f); // 20.0f
+
+    // Set up the groundplane comparator
+    // If the camera was pointing straight out, the normal would be:
+    Eigen::Vector3f nominal_road_normal(0.0, -1.0, 0.0);
+    // Adjust for camera tilt:
+    Eigen::Vector3f tilt_road_normal =
+        Eigen::AngleAxisf(pcl::deg2rad(5.0f), Eigen::Vector3f::UnitX()) *
+        nominal_road_normal;
+    road_comparator->setExpectedGroundNormal(tilt_road_normal);
+    road_comparator->setGroundAngularThreshold(pcl::deg2rad(10.0f));
+    road_comparator->setAngularThreshold(pcl::deg2rad(3.0f));
+  }
+
+  ~HRCSSegmentation() {}
+
+  void
+  cloud_cb_(const pcl::PointCloud<PointT>::ConstPtr& cloud)
+  {
+    if (!viewer->wasStopped()) {
+      cloud_mutex.lock();
+      prev_cloud = cloud;
+      cloud_mutex.unlock();
     }
-    
-    void
-    cloud_cb_ (const pcl::PointCloud<PointT>::ConstPtr& cloud)
-    {
-      if (!viewer->wasStopped ())
-      {
-        cloud_mutex.lock ();
-        prev_cloud = cloud;
-        cloud_mutex.unlock ();
+  }
+
+  void
+  keyboardCallback(const pcl::visualization::KeyboardEvent& event, void*)
+  {
+    if (event.keyUp()) {
+      switch (event.getKeyCode()) {
+      case ' ':
+        trigger = true;
+        break;
+      case '1':
+        smooth_strong -= 10;
+        PCL_INFO("smooth_strong: %d\n", smooth_strong);
+        stereo.setSmoothStrong(smooth_strong);
+        break;
+      case '2':
+        smooth_strong += 10;
+        PCL_INFO("smooth_strong: %d\n", smooth_strong);
+        stereo.setSmoothStrong(smooth_strong);
+        break;
+      case '3':
+        smooth_weak -= 10;
+        PCL_INFO("smooth_weak: %d\n", smooth_weak);
+        stereo.setSmoothWeak(smooth_weak);
+        break;
+      case '4':
+        smooth_weak += 10;
+        PCL_INFO("smooth_weak: %d\n", smooth_weak);
+        stereo.setSmoothWeak(smooth_weak);
+        break;
+      case 'c':
+        continuous = !continuous;
+        break;
+      case 'n':
+        display_normals = !display_normals;
+        break;
+      case 'o':
+        detect_obstacles = !detect_obstacles;
+        break;
       }
     }
+  }
 
-    void
-    keyboardCallback (const pcl::visualization::KeyboardEvent& event, void*)
-    {
-      if (event.keyUp ())
-      {
-        switch (event.getKeyCode ())
-        {
-          case ' ':
-            trigger = true;
-            break;
-          case '1':
-            smooth_strong -= 10;
-            PCL_INFO ("smooth_strong: %d\n", smooth_strong);
-            stereo.setSmoothStrong (smooth_strong);
-            break;
-          case '2':
-            smooth_strong += 10;
-            PCL_INFO ("smooth_strong: %d\n", smooth_strong);
-            stereo.setSmoothStrong (smooth_strong);
-            break;
-          case '3':
-            smooth_weak -= 10;
-            PCL_INFO ("smooth_weak: %d\n", smooth_weak);
-            stereo.setSmoothWeak (smooth_weak);
-            break;
-          case '4':
-            smooth_weak += 10;
-            PCL_INFO ("smooth_weak: %d\n", smooth_weak);
-            stereo.setSmoothWeak (smooth_weak);
-            break;
-          case 'c':
-            continuous = !continuous;
-            break;
-          case 'n':
-            display_normals = !display_normals;
-            break;
-          case 'o':
-            detect_obstacles = !detect_obstacles;
-            break;
+  void
+  processStereoPair(const pcl::PointCloud<pcl::RGB>::Ptr& left_image,
+                    const pcl::PointCloud<pcl::RGB>::Ptr& right_image,
+                    pcl::PointCloud<pcl::PointXYZRGB>::Ptr& out_cloud)
+  {
+    stereo.compute(*left_image, *right_image);
+    stereo.medianFilter(4);
+    stereo.getPointCloud(
+        318.112200f, 224.334900f, 368.534700f, 0.8387445f, out_cloud, left_image);
+  }
+
+  void
+  processCloud(const pcl::PointCloud<PointT>::ConstPtr& cloud)
+  {
+    // Compute the normals
+    pcl::PointCloud<pcl::Normal>::Ptr normal_cloud(new pcl::PointCloud<pcl::Normal>);
+    ne.setInputCloud(cloud);
+    ne.compute(*normal_cloud);
+
+    // Set up the groundplane comparator
+    road_comparator->setInputCloud(cloud);
+    road_comparator->setInputNormals(normal_cloud);
+
+    // Run segmentation
+    pcl::PointCloud<pcl::Label> labels;
+    std::vector<pcl::PointIndices> region_indices;
+    road_segmentation.setInputCloud(cloud);
+    road_segmentation.segment(labels, region_indices);
+
+    // Draw the segmentation result
+    pcl::PointCloud<pcl::PointXYZ>::Ptr ground_cloud(
+        new pcl::PointCloud<pcl::PointXYZ>);
+    pcl::PointCloud<pcl::PointXYZRGB>::Ptr ground_image(
+        new pcl::PointCloud<pcl::PointXYZRGB>);
+    pcl::PointCloud<pcl::PointXYZRGB>::Ptr label_image(
+        new pcl::PointCloud<pcl::PointXYZRGB>);
+    *ground_image = *cloud;
+    *label_image = *cloud;
+
+    Eigen::Vector4f clust_centroid = Eigen::Vector4f::Zero();
+    Eigen::Vector4f vp = Eigen::Vector4f::Zero();
+    Eigen::Matrix3f clust_cov;
+    pcl::ModelCoefficients model;
+    model.values.resize(4);
+
+    std::vector<pcl::ModelCoefficients> model_coefficients;
+    std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f>> centroids;
+    std::vector<Eigen::Matrix3f, Eigen::aligned_allocator<Eigen::Matrix3f>> covariances;
+    std::vector<pcl::PointIndices> inlier_indices;
+
+    for (const auto& region_index : region_indices) {
+      if (region_index.indices.size() > 1000) {
+
+        for (std::size_t j = 0; j < region_index.indices.size(); j++) {
+          pcl::PointXYZ ground_pt(cloud->points[region_index.indices[j]].x,
+                                  cloud->points[region_index.indices[j]].y,
+                                  cloud->points[region_index.indices[j]].z);
+          ground_cloud->points.push_back(ground_pt);
+          ground_image->points[region_index.indices[j]].g = static_cast<std::uint8_t>(
+              (cloud->points[region_index.indices[j]].g + 255) / 2);
+          label_image->points[region_index.indices[j]].r = 0;
+          label_image->points[region_index.indices[j]].g = 255;
+          label_image->points[region_index.indices[j]].b = 0;
+        }
+
+        // Compute plane info
+        pcl::computeMeanAndCovarianceMatrix(
+            *cloud, region_index.indices, clust_cov, clust_centroid);
+        Eigen::Vector4f plane_params;
+
+        EIGEN_ALIGN16 Eigen::Vector3f::Scalar eigen_value;
+        EIGEN_ALIGN16 Eigen::Vector3f eigen_vector;
+        pcl::eigen33(clust_cov, eigen_value, eigen_vector);
+        plane_params[0] = eigen_vector[0];
+        plane_params[1] = eigen_vector[1];
+        plane_params[2] = eigen_vector[2];
+        plane_params[3] = 0;
+        plane_params[3] = -1 * plane_params.dot(clust_centroid);
+
+        vp -= clust_centroid;
+        float cos_theta = vp.dot(plane_params);
+        if (cos_theta < 0) {
+          plane_params *= -1;
+          plane_params[3] = 0;
+          plane_params[3] = -1 * plane_params.dot(clust_centroid);
         }
+
+        model.values[0] = plane_params[0];
+        model.values[1] = plane_params[1];
+        model.values[2] = plane_params[2];
+        model.values[3] = plane_params[3];
+        model_coefficients.push_back(model);
+        inlier_indices.push_back(region_index);
+        centroids.push_back(clust_centroid);
+        covariances.push_back(clust_cov);
       }
     }
-    
 
-    void
-    processStereoPair (const pcl::PointCloud<pcl::RGB>::Ptr& left_image, const pcl::PointCloud<pcl::RGB>::Ptr& right_image, pcl::PointCloud<pcl::PointXYZRGB>::Ptr& out_cloud)
-    {
-      stereo.compute (*left_image, *right_image);
-      stereo.medianFilter (4);
-      stereo.getPointCloud(318.112200f, 224.334900f, 368.534700f, 0.8387445f, out_cloud, left_image);
+    // Refinement
+    std::vector<bool> grow_labels;
+    std::vector<int> label_to_model;
+    grow_labels.resize(region_indices.size(), false);
+    label_to_model.resize(region_indices.size(), 0);
+
+    for (std::size_t i = 0; i < model_coefficients.size(); i++) {
+      int model_label = (labels)[inlier_indices[i].indices[0]].label;
+      label_to_model[model_label] = static_cast<int>(i);
+      grow_labels[model_label] = true;
     }
-    
 
-    void
-    processCloud (const pcl::PointCloud<PointT>::ConstPtr& cloud)
-    {
-      // Compute the normals
-      pcl::PointCloud<pcl::Normal>::Ptr normal_cloud (new pcl::PointCloud<pcl::Normal>);
-      ne.setInputCloud (cloud);
-      ne.compute (*normal_cloud);
-
-      // Set up the groundplane comparator
-      road_comparator->setInputCloud (cloud);
-      road_comparator->setInputNormals (normal_cloud);
-
-      // Run segmentation
-      pcl::PointCloud<pcl::Label> labels;
-      std::vector<pcl::PointIndices> region_indices;
-      road_segmentation.setInputCloud (cloud);
-      road_segmentation.segment (labels, region_indices);
-
-      // Draw the segmentation result
-      pcl::PointCloud<pcl::PointXYZ>::Ptr ground_cloud (new pcl::PointCloud<pcl::PointXYZ>);
-      pcl::PointCloud<pcl::PointXYZRGB>::Ptr ground_image (new pcl::PointCloud<pcl::PointXYZRGB>);
-      pcl::PointCloud<pcl::PointXYZRGB>::Ptr label_image (new pcl::PointCloud<pcl::PointXYZRGB>);
-      *ground_image = *cloud;
-      *label_image = *cloud;
-
-      Eigen::Vector4f clust_centroid = Eigen::Vector4f::Zero ();
-      Eigen::Vector4f vp = Eigen::Vector4f::Zero ();
-      Eigen::Matrix3f clust_cov;
-      pcl::ModelCoefficients model;
-      model.values.resize (4);
-
-      std::vector<pcl::ModelCoefficients> model_coefficients;
-      std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > centroids;
-      std::vector<Eigen::Matrix3f, Eigen::aligned_allocator<Eigen::Matrix3f> > covariances;
-      std::vector<pcl::PointIndices> inlier_indices;
-
-      for (const auto &region_index : region_indices)
-      {
-        if (region_index.indices.size () > 1000)
-        {
-
-          for (std::size_t j = 0; j < region_index.indices.size (); j++)
-          {  
-            pcl::PointXYZ ground_pt (cloud->points[region_index.indices[j]].x,
-                                     cloud->points[region_index.indices[j]].y,
-                                     cloud->points[region_index.indices[j]].z);
-            ground_cloud->points.push_back (ground_pt);
-            ground_image->points[region_index.indices[j]].g = static_cast<std::uint8_t> ((cloud->points[region_index.indices[j]].g + 255) / 2);
-            label_image->points[region_index.indices[j]].r = 0;
-            label_image->points[region_index.indices[j]].g = 255;
+    pcl::PointCloud<pcl::Label>::Ptr labels_ptr(new pcl::PointCloud<pcl::Label>);
+    *labels_ptr = labels;
+    pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
+    pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>::Ptr
+        refinement_compare(
+            new pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>());
+    refinement_compare->setInputCloud(cloud);
+    refinement_compare->setDistanceThreshold(0.15f);
+    refinement_compare->setLabels(labels_ptr);
+    refinement_compare->setModelCoefficients(model_coefficients);
+    refinement_compare->setRefineLabels(grow_labels);
+    refinement_compare->setLabelToModel(label_to_model);
+    mps.setRefinementComparator(refinement_compare);
+    mps.setMinInliers(500);
+    mps.setAngularThreshold(pcl::deg2rad(3.0));
+    mps.setDistanceThreshold(0.02);
+    mps.setInputCloud(cloud);
+    mps.setInputNormals(normal_cloud);
+    mps.refine(model_coefficients, inlier_indices, labels_ptr, region_indices);
+
+    // Note the regions that have been extended
+    pcl::PointCloud<PointT> extended_ground_cloud;
+    for (const auto& region_index : region_indices) {
+      if (region_index.indices.size() > 1000) {
+        for (std::size_t j = 0; j < region_index.indices.size(); j++) {
+          // Check to see if it has already been labeled
+          if (ground_image->points[region_index.indices[j]].g ==
+              ground_image->points[region_index.indices[j]].b) {
+            pcl::PointXYZ ground_pt(cloud->points[region_index.indices[j]].x,
+                                    cloud->points[region_index.indices[j]].y,
+                                    cloud->points[region_index.indices[j]].z);
+            ground_cloud->points.push_back(ground_pt);
+            ground_image->points[region_index.indices[j]].r = static_cast<std::uint8_t>(
+                (cloud->points[region_index.indices[j]].r + 255) / 2);
+            ground_image->points[region_index.indices[j]].g = static_cast<std::uint8_t>(
+                (cloud->points[region_index.indices[j]].g + 255) / 2);
+            label_image->points[region_index.indices[j]].r = 128;
+            label_image->points[region_index.indices[j]].g = 128;
             label_image->points[region_index.indices[j]].b = 0;
-          } 
-          
-          // Compute plane info
-          pcl::computeMeanAndCovarianceMatrix (*cloud, region_index.indices, clust_cov, clust_centroid);
-          Eigen::Vector4f plane_params;
-          
-          EIGEN_ALIGN16 Eigen::Vector3f::Scalar eigen_value;
-          EIGEN_ALIGN16 Eigen::Vector3f eigen_vector;
-          pcl::eigen33 (clust_cov, eigen_value, eigen_vector);
-          plane_params[0] = eigen_vector[0];
-          plane_params[1] = eigen_vector[1];
-          plane_params[2] = eigen_vector[2];
-          plane_params[3] = 0;
-          plane_params[3] = -1 * plane_params.dot (clust_centroid);
-          
-          vp -= clust_centroid;
-          float cos_theta = vp.dot (plane_params);
-          if (cos_theta < 0)
-          {
-            plane_params *= -1;
-            plane_params[3] = 0;
-            plane_params[3] = -1 * plane_params.dot (clust_centroid);
-          }
-          
-          model.values[0] = plane_params[0];
-          model.values[1] = plane_params[1];
-          model.values[2] = plane_params[2];
-          model.values[3] = plane_params[3];
-          model_coefficients.push_back (model);
-          inlier_indices.push_back (region_index);
-          centroids.push_back (clust_centroid);
-          covariances.push_back (clust_cov);
-        }
-      }
-      
-      //Refinement
-      std::vector<bool> grow_labels;
-      std::vector<int> label_to_model;
-      grow_labels.resize (region_indices.size (), false);
-      label_to_model.resize (region_indices.size (), 0);
-      
-      for (std::size_t i = 0; i < model_coefficients.size (); i++)
-      {
-        int model_label = (labels)[inlier_indices[i].indices[0]].label;
-        label_to_model[model_label] = static_cast<int> (i);
-        grow_labels[model_label] = true;
-      }
-      
-      pcl::PointCloud<pcl::Label>::Ptr labels_ptr (new pcl::PointCloud<pcl::Label>);
-      *labels_ptr = labels;
-      pcl::OrganizedMultiPlaneSegmentation<PointT, pcl::Normal, pcl::Label> mps;
-      pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>::Ptr refinement_compare (new pcl::PlaneRefinementComparator<PointT, pcl::Normal, pcl::Label>());
-      refinement_compare->setInputCloud (cloud);
-      refinement_compare->setDistanceThreshold (0.15f);
-      refinement_compare->setLabels (labels_ptr);
-      refinement_compare->setModelCoefficients (model_coefficients);
-      refinement_compare->setRefineLabels (grow_labels);
-      refinement_compare->setLabelToModel (label_to_model);
-      mps.setRefinementComparator (refinement_compare);
-      mps.setMinInliers (500);
-      mps.setAngularThreshold (pcl::deg2rad (3.0));
-      mps.setDistanceThreshold (0.02);
-      mps.setInputCloud (cloud);
-      mps.setInputNormals (normal_cloud);
-      mps.refine (model_coefficients,
-                  inlier_indices,
-                  labels_ptr,
-                  region_indices);
-      
-      //Note the regions that have been extended
-      pcl::PointCloud<PointT> extended_ground_cloud;
-      for (const auto &region_index : region_indices)
-      {
-        if (region_index.indices.size () > 1000)
-        {
-          for (std::size_t j = 0; j < region_index.indices.size (); j++)
-          {
-            // Check to see if it has already been labeled
-            if (ground_image->points[region_index.indices[j]].g == ground_image->points[region_index.indices[j]].b)
-            {
-              pcl::PointXYZ ground_pt (cloud->points[region_index.indices[j]].x,
-                                       cloud->points[region_index.indices[j]].y,
-                                       cloud->points[region_index.indices[j]].z);
-              ground_cloud->points.push_back (ground_pt);
-              ground_image->points[region_index.indices[j]].r = static_cast<std::uint8_t> ((cloud->points[region_index.indices[j]].r + 255) / 2);
-              ground_image->points[region_index.indices[j]].g = static_cast<std::uint8_t> ((cloud->points[region_index.indices[j]].g + 255) / 2);
-              label_image->points[region_index.indices[j]].r = 128;
-              label_image->points[region_index.indices[j]].g = 128;
-              label_image->points[region_index.indices[j]].b = 0;
-            }
-            
           }
         }
       }
+    }
 
-      // Segment Obstacles (Disabled by default)
-      Eigen::Vector4f ground_plane_params (1.0, 0.0, 0.0, 1.0);
-      Eigen::Vector4f ground_centroid (0.0, 0.0, 0.0, 0.0);
-      
-      if (!ground_cloud->points.empty ())
-      {
-        ground_centroid = centroids[0];
-        ground_plane_params = Eigen::Vector4f (model_coefficients[0].values[0], model_coefficients[0].values[1], model_coefficients[0].values[2], model_coefficients[0].values[3]);
-      }
+    // Segment Obstacles (Disabled by default)
+    Eigen::Vector4f ground_plane_params(1.0, 0.0, 0.0, 1.0);
+    Eigen::Vector4f ground_centroid(0.0, 0.0, 0.0, 0.0);
 
-      if (detect_obstacles)
-      {
-        pcl::PointCloud<PointT>::CloudVectorType clusters;
-        if (!ground_cloud->points.empty ())
-        {
-          pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSetPtr plane_labels (new pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSet);
-          for (std::size_t i = 0; i < region_indices.size (); ++i)
-            if ((region_indices[i].indices.size () > mps.getMinInliers ()))
-              plane_labels->insert (i);
-        
-          pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr euclidean_cluster_comparator_ (new pcl::EuclideanClusterComparator<PointT, pcl::Label> ());
-          euclidean_cluster_comparator_->setInputCloud (cloud);
-          euclidean_cluster_comparator_->setLabels (labels_ptr);
-          euclidean_cluster_comparator_->setExcludeLabels (plane_labels);
-          euclidean_cluster_comparator_->setDistanceThreshold (0.05f, false);
-        
-          pcl::PointCloud<pcl::Label> euclidean_labels;
-          std::vector<pcl::PointIndices> euclidean_label_indices;
-          pcl::OrganizedConnectedComponentSegmentation<PointT,pcl::Label> euclidean_segmentation (euclidean_cluster_comparator_);
-          euclidean_segmentation.setInputCloud (cloud);
-          euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices);
-        
-          for (const auto &euclidean_label_index : euclidean_label_indices)
-          {
-            if ((euclidean_label_index.indices.size () > 200))
-            {
-              pcl::PointCloud<PointT> cluster;
-              pcl::copyPointCloud (*cloud, euclidean_label_index.indices, cluster);
-              clusters.push_back (cluster);
-
-              Eigen::Vector4f cluster_centroid;
-              Eigen::Matrix3f cluster_cov;
-              pcl::computeMeanAndCovarianceMatrix (*cloud, euclidean_label_index.indices, cluster_cov, cluster_centroid);
-
-              pcl::PointXYZ centroid_pt (cluster_centroid[0], cluster_centroid[1], cluster_centroid[2]);
-              double ptp_dist =  pcl::pointToPlaneDistanceSigned (centroid_pt, ground_plane_params[0], ground_plane_params[1], ground_plane_params[2], ground_plane_params[3]);
-
-              if ((ptp_dist > 0.5) && (ptp_dist < 3.0))
-              {
-              
-                for (std::size_t j = 0; j < euclidean_label_index.indices.size (); j++)
-                {
-                  ground_image->points[euclidean_label_index.indices[j]].r = 255;
-                  label_image->points[euclidean_label_index.indices[j]].r = 255;
-                  label_image->points[euclidean_label_index.indices[j]].g = 0;
-                  label_image->points[euclidean_label_index.indices[j]].b = 0;
-                }
+    if (!ground_cloud->points.empty()) {
+      ground_centroid = centroids[0];
+      ground_plane_params = Eigen::Vector4f(model_coefficients[0].values[0],
+                                            model_coefficients[0].values[1],
+                                            model_coefficients[0].values[2],
+                                            model_coefficients[0].values[3]);
+    }
 
+    if (detect_obstacles) {
+      pcl::PointCloud<PointT>::CloudVectorType clusters;
+      if (!ground_cloud->points.empty()) {
+        pcl::EuclideanClusterComparator<PointT, pcl::Label>::ExcludeLabelSetPtr
+            plane_labels(
+                new pcl::EuclideanClusterComparator<PointT,
+                                                    pcl::Label>::ExcludeLabelSet);
+        for (std::size_t i = 0; i < region_indices.size(); ++i)
+          if ((region_indices[i].indices.size() > mps.getMinInliers()))
+            plane_labels->insert(i);
+
+        pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr
+            euclidean_cluster_comparator_(
+                new pcl::EuclideanClusterComparator<PointT, pcl::Label>());
+        euclidean_cluster_comparator_->setInputCloud(cloud);
+        euclidean_cluster_comparator_->setLabels(labels_ptr);
+        euclidean_cluster_comparator_->setExcludeLabels(plane_labels);
+        euclidean_cluster_comparator_->setDistanceThreshold(0.05f, false);
+
+        pcl::PointCloud<pcl::Label> euclidean_labels;
+        std::vector<pcl::PointIndices> euclidean_label_indices;
+        pcl::OrganizedConnectedComponentSegmentation<PointT, pcl::Label>
+            euclidean_segmentation(euclidean_cluster_comparator_);
+        euclidean_segmentation.setInputCloud(cloud);
+        euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices);
+
+        for (const auto& euclidean_label_index : euclidean_label_indices) {
+          if ((euclidean_label_index.indices.size() > 200)) {
+            pcl::PointCloud<PointT> cluster;
+            pcl::copyPointCloud(*cloud, euclidean_label_index.indices, cluster);
+            clusters.push_back(cluster);
+
+            Eigen::Vector4f cluster_centroid;
+            Eigen::Matrix3f cluster_cov;
+            pcl::computeMeanAndCovarianceMatrix(
+                *cloud, euclidean_label_index.indices, cluster_cov, cluster_centroid);
+
+            pcl::PointXYZ centroid_pt(
+                cluster_centroid[0], cluster_centroid[1], cluster_centroid[2]);
+            double ptp_dist = pcl::pointToPlaneDistanceSigned(centroid_pt,
+                                                              ground_plane_params[0],
+                                                              ground_plane_params[1],
+                                                              ground_plane_params[2],
+                                                              ground_plane_params[3]);
+
+            if ((ptp_dist > 0.5) && (ptp_dist < 3.0)) {
+
+              for (std::size_t j = 0; j < euclidean_label_index.indices.size(); j++) {
+                ground_image->points[euclidean_label_index.indices[j]].r = 255;
+                label_image->points[euclidean_label_index.indices[j]].r = 255;
+                label_image->points[euclidean_label_index.indices[j]].g = 0;
+                label_image->points[euclidean_label_index.indices[j]].b = 0;
               }
-            
-            }    
+            }
           }
-        
-        }
-      }
-
-      // note the NAN points in the image as well
-      for (std::size_t i = 0; i < cloud->points.size (); i++)
-      {
-        if (!pcl::isFinite (cloud->points[i]))
-        {
-          ground_image->points[i].b = static_cast<std::uint8_t>((cloud->points[i].b + 255) / 2);
-          label_image->points[i].r = 0;
-          label_image->points[i].g = 0;
-          label_image->points[i].b = 255;
         }
       }
+    }
 
-      // Update info for the visualization thread
-      {
-        cloud_mutex.lock ();
-        prev_cloud = cloud;
-        prev_normal_cloud = normal_cloud;
-        prev_ground_cloud = ground_cloud;
-        prev_ground_image = ground_image;
-        prev_label_image = label_image;
-        prev_ground_normal = ground_plane_params;
-        prev_ground_centroid = ground_centroid;
-        cloud_mutex.unlock ();
+    // note the NAN points in the image as well
+    for (std::size_t i = 0; i < cloud->points.size(); i++) {
+      if (!pcl::isFinite(cloud->points[i])) {
+        ground_image->points[i].b =
+            static_cast<std::uint8_t>((cloud->points[i].b + 255) / 2);
+        label_image->points[i].r = 0;
+        label_image->points[i].g = 0;
+        label_image->points[i].b = 255;
       }
     }
 
-    void
-    run ()
+    // Update info for the visualization thread
     {
-      while (!viewer->wasStopped ())
-      {
-       // Process a new image
-        if (trigger || continuous)
-        {
-          pcl::PointCloud<pcl::RGB>::Ptr left_cloud (new pcl::PointCloud<pcl::RGB>);
-          pcl::PointCloud<pcl::RGB>::Ptr right_cloud (new pcl::PointCloud<pcl::RGB>);
-          pcl::PointCloud<pcl::PointXYZRGB>::Ptr out_cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
-
-          pcl::PCDReader pcd;
-          pcd.read (left_images[images_idx], *left_cloud);
-          pcd.read (right_images[images_idx], *right_cloud);
-          processStereoPair (left_cloud, right_cloud, out_cloud);
-          processCloud (out_cloud);
-          images_idx++;
-
-          trigger = false;
+      cloud_mutex.lock();
+      prev_cloud = cloud;
+      prev_normal_cloud = normal_cloud;
+      prev_ground_cloud = ground_cloud;
+      prev_ground_image = ground_image;
+      prev_label_image = label_image;
+      prev_ground_normal = ground_plane_params;
+      prev_ground_centroid = ground_centroid;
+      cloud_mutex.unlock();
+    }
+  }
+
+  void
+  run()
+  {
+    while (!viewer->wasStopped()) {
+      // Process a new image
+      if (trigger || continuous) {
+        pcl::PointCloud<pcl::RGB>::Ptr left_cloud(new pcl::PointCloud<pcl::RGB>);
+        pcl::PointCloud<pcl::RGB>::Ptr right_cloud(new pcl::PointCloud<pcl::RGB>);
+        pcl::PointCloud<pcl::PointXYZRGB>::Ptr out_cloud(
+            new pcl::PointCloud<pcl::PointXYZRGB>);
+
+        pcl::PCDReader pcd;
+        pcd.read(left_images[images_idx], *left_cloud);
+        pcd.read(right_images[images_idx], *right_cloud);
+        processStereoPair(left_cloud, right_cloud, out_cloud);
+        processCloud(out_cloud);
+        images_idx++;
+
+        trigger = false;
+      }
+
+      // Draw visualizations
+      if (cloud_mutex.try_lock()) {
+        if (!viewer->updatePointCloud(prev_ground_image, "cloud"))
+          viewer->addPointCloud(prev_ground_image, "cloud");
+
+        if (prev_normal_cloud->points.size() > 1000 && display_normals) {
+          viewer->removePointCloud("normals");
+          viewer->addPointCloudNormals<PointT, pcl::Normal>(
+              prev_ground_image, prev_normal_cloud, 10, 0.15f, "normals");
+          viewer->setPointCloudRenderingProperties(
+              pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "normals");
         }
-        
-       // Draw visualizations
-        if (cloud_mutex.try_lock ())
-        {
-          if (!viewer->updatePointCloud (prev_ground_image, "cloud"))
-            viewer->addPointCloud (prev_ground_image, "cloud");
-          
-          if (prev_normal_cloud->points.size () > 1000 && display_normals)
-          {  
-            viewer->removePointCloud ("normals");
-            viewer->addPointCloudNormals<PointT, pcl::Normal>(prev_ground_image, prev_normal_cloud, 10, 0.15f, "normals");
-            viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.5, "normals");
-          }
-          
-          if (prev_cloud->points.size () > 1000)
-          {
-            image_viewer->addRGBImage<PointT>(prev_ground_image, "rgb_image", 0.3);
-          }
-          
-          // Show the groundplane normal
-          Eigen::Vector3f nominal_road_normal (0.0, -1.0, 0.0);
-          // Adjust for camera tilt
-          Eigen::Vector3f tilt_road_normal = Eigen::AngleAxisf (pcl::deg2rad (5.0f), Eigen::Vector3f::UnitX ()) * nominal_road_normal;
-          
-          // Show the groundplane normal
-          pcl::PointXYZ np1 (prev_ground_centroid[0], prev_ground_centroid[1], prev_ground_centroid[2]);
-          pcl::PointXYZ np2 (prev_ground_centroid[0] + prev_ground_normal[0],
-                             prev_ground_centroid[1] + prev_ground_normal[1],
-                             prev_ground_centroid[2] + prev_ground_normal[2]);
-          pcl::PointXYZ np3 (prev_ground_centroid[0] + tilt_road_normal[0],
-                             prev_ground_centroid[1] + tilt_road_normal[1],
-                             prev_ground_centroid[2] + tilt_road_normal[2]);
-          
-          viewer->removeShape ("ground_norm");
-          viewer->addArrow (np2, np1, 1.0, 0, 0, false, "ground_norm");          
-          viewer->removeShape ("expected_ground_norm");
-          viewer->addArrow (np3, np1, 0.0, 1.0, 0, false, "expected_ground_norm");          
-
-          cloud_mutex.unlock ();
+
+        if (prev_cloud->points.size() > 1000) {
+          image_viewer->addRGBImage<PointT>(prev_ground_image, "rgb_image", 0.3);
         }
-        viewer->spinOnce (100);
-        image_viewer->spinOnce (100);
-        
+
+        // Show the groundplane normal
+        Eigen::Vector3f nominal_road_normal(0.0, -1.0, 0.0);
+        // Adjust for camera tilt
+        Eigen::Vector3f tilt_road_normal =
+            Eigen::AngleAxisf(pcl::deg2rad(5.0f), Eigen::Vector3f::UnitX()) *
+            nominal_road_normal;
+
+        // Show the groundplane normal
+        pcl::PointXYZ np1(
+            prev_ground_centroid[0], prev_ground_centroid[1], prev_ground_centroid[2]);
+        pcl::PointXYZ np2(prev_ground_centroid[0] + prev_ground_normal[0],
+                          prev_ground_centroid[1] + prev_ground_normal[1],
+                          prev_ground_centroid[2] + prev_ground_normal[2]);
+        pcl::PointXYZ np3(prev_ground_centroid[0] + tilt_road_normal[0],
+                          prev_ground_centroid[1] + tilt_road_normal[1],
+                          prev_ground_centroid[2] + tilt_road_normal[2]);
+
+        viewer->removeShape("ground_norm");
+        viewer->addArrow(np2, np1, 1.0, 0, 0, false, "ground_norm");
+        viewer->removeShape("expected_ground_norm");
+        viewer->addArrow(np3, np1, 0.0, 1.0, 0, false, "expected_ground_norm");
+
+        cloud_mutex.unlock();
       }
+      viewer->spinOnce(100);
+      image_viewer->spinOnce(100);
     }
-    
-
-
+  }
 };
 
 int
-main (int argc, char** argv)
+main(int argc, char** argv)
 {
-  if (argc < 3)
-  {
-    PCL_INFO ("usage: pcl_stereo_ground_segmentation left_image_directory right_image_directory\n");
-    PCL_INFO ("note: images must be in PCD format.  See pcl_png2pcd\n");
+  if (argc < 3) {
+    PCL_INFO("usage: pcl_stereo_ground_segmentation left_image_directory "
+             "right_image_directory\n");
+    PCL_INFO("note: images must be in PCD format.  See pcl_png2pcd\n");
   }
 
   // Get list of stereo files
   std::vector<std::string> left_images;
   boost::filesystem::directory_iterator end_itr;
-  for (boost::filesystem::directory_iterator itr (argv[1]); itr != end_itr; ++itr)
-  {
-    left_images.push_back (itr->path ().string ());
+  for (boost::filesystem::directory_iterator itr(argv[1]); itr != end_itr; ++itr) {
+    left_images.push_back(itr->path().string());
   }
-  sort (left_images.begin (), left_images.end ());
+  sort(left_images.begin(), left_images.end());
   std::vector<std::string> right_images;
-  for (boost::filesystem::directory_iterator itr (argv[2]); itr != end_itr; ++itr)
-  {
-    right_images.push_back (itr->path ().string ());
+  for (boost::filesystem::directory_iterator itr(argv[2]); itr != end_itr; ++itr) {
+    right_images.push_back(itr->path().string());
   }
-  sort (right_images.begin (), right_images.end ());
+  sort(right_images.begin(), right_images.end());
 
-  PCL_INFO ("Press space to advance to the next frame, or 'c' to enable continuous mode\n");
+  PCL_INFO(
+      "Press space to advance to the next frame, or 'c' to enable continuous mode\n");
 
   // Process and display
-  HRCSSegmentation hrcs (left_images, right_images);
-  hrcs.run ();
-  
+  HRCSSegmentation hrcs(left_images, right_images);
+  hrcs.run();
+
   return 0;
 }
index a68376db30f9a442714e1810454464068b44b755..7b88a3bae6da2350625413f0d8824321c5fcdb8f 100644 (file)
@@ -1,48 +1,46 @@
-#include <pcl/surface/surfel_smoothing.h>
-#include <pcl/io/pcd_io.h>
 #include <pcl/features/normal_3d.h>
-
+#include <pcl/io/pcd_io.h>
+#include <pcl/surface/surfel_smoothing.h>
 
 using namespace pcl;
 
 int
-main (int argc, char **argv)
+main(int argc, char** argv)
 {
-  if (argc != 5)
-  {
-    PCL_ERROR ("./surfel_smoothing_test normal_search_radius surfel_scale source_cloud destination_cloud\n");
-    return (-1);
+  if (argc != 5) {
+    PCL_ERROR("./surfel_smoothing_test normal_search_radius surfel_scale source_cloud "
+              "destination_cloud\n");
+    return -1;
   }
-  PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ> ());
-  PointCloud<Normal>::Ptr normals (new PointCloud<Normal> ());
+  PointCloud<PointXYZ>::Ptr cloud(new PointCloud<PointXYZ>());
+  PointCloud<Normal>::Ptr normals(new PointCloud<Normal>());
 
   PCDReader reader;
-  reader.read (argv[3], *cloud);
-  PCL_INFO ("Cloud read: %s\n", argv[3]);
-
-  float normal_search_radius = static_cast<float> (atof (argv[1]));
-  float surfel_scale = static_cast<float> (atof (argv[2]));
+  reader.read(argv[3], *cloud);
+  PCL_INFO("Cloud read: %s\n", argv[3]);
 
+  float normal_search_radius = static_cast<float>(atof(argv[1]));
+  float surfel_scale = static_cast<float>(atof(argv[2]));
 
   NormalEstimation<PointXYZ, Normal> normal_estimation;
-  normal_estimation.setInputCloud (cloud);
-  search::KdTree<PointXYZ>::Ptr search_tree (new search::KdTree<PointXYZ>);
-  normal_estimation.setSearchMethod (search_tree);
-  normal_estimation.setRadiusSearch (normal_search_radius);
-  normal_estimation.compute (*normals);
-
-  SurfelSmoothing<PointXYZ, Normal> surfel_smoothing (surfel_scale);
-  surfel_smoothing.setInputCloud (cloud);
-  surfel_smoothing.setInputNormals (normals);
-  surfel_smoothing.setSearchMethod (search_tree);
+  normal_estimation.setInputCloud(cloud);
+  search::KdTree<PointXYZ>::Ptr search_tree(new search::KdTree<PointXYZ>);
+  normal_estimation.setSearchMethod(search_tree);
+  normal_estimation.setRadiusSearch(normal_search_radius);
+  normal_estimation.compute(*normals);
+
+  SurfelSmoothing<PointXYZ, Normal> surfel_smoothing(surfel_scale);
+  surfel_smoothing.setInputCloud(cloud);
+  surfel_smoothing.setInputNormals(normals);
+  surfel_smoothing.setSearchMethod(search_tree);
   PointCloud<PointXYZ>::Ptr output_positions;
   PointCloud<Normal>::Ptr output_normals;
-  surfel_smoothing.computeSmoothedCloud (output_positions, output_normals);
+  surfel_smoothing.computeSmoothedCloud(output_positions, output_normals);
 
-  PointCloud<PointNormal>::Ptr output_with_normals (new PointCloud<PointNormal> ());
-  pcl::concatenateFields (*output_positions, *normals, *output_with_normals);
+  PointCloud<PointNormal>::Ptr output_with_normals(new PointCloud<PointNormal>());
+  pcl::concatenateFields(*output_positions, *normals, *output_with_normals);
 
-  io::savePCDFileASCII (argv[4], *output_with_normals);
+  io::savePCDFileASCII(argv[4], *output_with_normals);
 
-  return (0);
+  return 0;
 }
index 4b9e181e1702972950ec45bdcea57e6b5dd86ce5..aef388bc3afe17039ade782aa55af63a217012f1 100644 (file)
@@ -1,54 +1,54 @@
-#include <vector>
-#include <string>
-#include <sstream>
-#include <pcl/io/pcd_io.h>
 #include <pcl/common/time.h>
 #include <pcl/console/parse.h>
-#include <pcl/search/kdtree.h>
+#include <pcl/io/pcd_io.h>
 #include <pcl/search/brute_force.h>
+#include <pcl/search/kdtree.h>
+
+#include <sstream>
+#include <string>
+#include <vector>
 
 using namespace std;
 
 int
-main (int argc, char ** argv)
+main(int argc, char** argv)
 {
-  if (argc < 2)
-  {
-    pcl::console::print_info ("Syntax is: %s [-pcd <pcd-file>] (-radius <radius> [-knn <k>] | -knn <k> )\n", argv[0]);
-    return (1);
+  if (argc < 2) {
+    pcl::console::print_info(
+        "Syntax is: %s [-pcd <pcd-file>] (-radius <radius> [-knn <k>] | -knn <k> )\n",
+        argv[0]);
+    return 1;
   }
 
   string pcd_path;
-  bool use_pcd_file = pcl::console::find_switch (argc, argv, "-pcd");
+  bool use_pcd_file = pcl::console::find_switch(argc, argv, "-pcd");
   if (use_pcd_file)
-    pcl::console::parse (argc, argv, "-pcd", pcd_path);
+    pcl::console::parse(argc, argv, "-pcd", pcd_path);
 
   float radius = -1;
-  if (pcl::console::find_switch (argc, argv, "-radius"))
-    pcl::console::parse (argc, argv, "-radius", radius);
+  if (pcl::console::find_switch(argc, argv, "-radius"))
+    pcl::console::parse(argc, argv, "-radius", radius);
 
   int k = -1;
-  if (pcl::console::find_switch (argc, argv, "-knn"))
-    pcl::console::parse (argc, argv, "-knn", k);
+  if (pcl::console::find_switch(argc, argv, "-knn"))
+    pcl::console::parse(argc, argv, "-knn", k);
 
-  if (radius < 0 && k < 0)
-  {
-    std::cout << "please specify at least one of the options -radius and -knn" << std::endl;
-    return (1);
+  if (radius < 0 && k < 0) {
+    std::cout << "please specify at least one of the options -radius and -knn"
+              << std::endl;
+    return 1;
   }
 
-  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
 
   if (use_pcd_file)
-    pcl::io::loadPCDFile (pcd_path, *cloud);
-  else
-  {
-    cloud->resize (1000000);
-    for (std::size_t idx = 0; idx < cloud->size (); ++idx)
-    {
-      (*cloud)[idx].x = static_cast<float> (rand () / RAND_MAX);
-      (*cloud)[idx].y = static_cast<float> (rand () / RAND_MAX);
-      (*cloud)[idx].z = static_cast<float> (rand () / RAND_MAX);
+    pcl::io::loadPCDFile(pcd_path, *cloud);
+  else {
+    cloud->resize(1000000);
+    for (std::size_t idx = 0; idx < cloud->size(); ++idx) {
+      (*cloud)[idx].x = static_cast<float>(rand() / RAND_MAX);
+      (*cloud)[idx].y = static_cast<float>(rand() / RAND_MAX);
+      (*cloud)[idx].z = static_cast<float>(rand() / RAND_MAX);
     }
   }
 
@@ -69,71 +69,77 @@ main (int argc, char ** argv)
   double bf_setup;
   double bf_search;
 
-  if (k > 0)
-  {
-    start = pcl::getTime ();
-    tree.setInputCloud (cloud);
-    stop = pcl::getTime ();
+  if (k > 0) {
+    start = pcl::getTime();
+    tree.setInputCloud(cloud);
+    stop = pcl::getTime();
     std::cout << "setting up kd tree: " << (kd_setup = stop - start) << std::endl;
 
-    start = pcl::getTime ();
-    tree.nearestKSearchT (query, k, kd_indices, kd_distances);
-    stop = pcl::getTime ();
-    std::cout << "single search with kd tree; " << (kd_search = stop - start) << " :: " << kd_indices[0] << " , " << kd_distances [0] << std::endl;
+    start = pcl::getTime();
+    tree.nearestKSearchT(query, k, kd_indices, kd_distances);
+    stop = pcl::getTime();
+    std::cout << "single search with kd tree; " << (kd_search = stop - start)
+              << " :: " << kd_indices[0] << " , " << kd_distances[0] << std::endl;
 
     pcl::search::BruteForce<pcl::PointXYZRGB> brute_force;
-    start = pcl::getTime ();
-    brute_force.setInputCloud (cloud);
-    stop = pcl::getTime ();
-    std::cout << "setting up brute force search: " << (bf_setup = stop - start) << std::endl;
-
-    start = pcl::getTime ();
-    brute_force.nearestKSearchT (query, k, bf_indices, bf_distances);
-    stop = pcl::getTime ();
-    std::cout << "single search with brute force; " << (bf_search = stop - start) << " :: " << bf_indices[0] << " , " << bf_distances [0] << std::endl;
-    std::cout << "amortization after searches: " << (kd_setup - bf_setup) / (bf_search - kd_search) << std::endl;
+    start = pcl::getTime();
+    brute_force.setInputCloud(cloud);
+    stop = pcl::getTime();
+    std::cout << "setting up brute force search: " << (bf_setup = stop - start)
+              << std::endl;
+
+    start = pcl::getTime();
+    brute_force.nearestKSearchT(query, k, bf_indices, bf_distances);
+    stop = pcl::getTime();
+    std::cout << "single search with brute force; " << (bf_search = stop - start)
+              << " :: " << bf_indices[0] << " , " << bf_distances[0] << std::endl;
+    std::cout << "amortization after searches: "
+              << (kd_setup - bf_setup) / (bf_search - kd_search) << std::endl;
   }
-  else
-  {
-    start = pcl::getTime ();
-    tree.setInputCloud (cloud);
-    stop = pcl::getTime ();
+  else {
+    start = pcl::getTime();
+    tree.setInputCloud(cloud);
+    stop = pcl::getTime();
     std::cout << "setting up kd tree: " << (kd_setup = stop - start) << std::endl;
 
-    start = pcl::getTime ();
-    tree.radiusSearch (query, radius, kd_indices, kd_distances, k);
-    stop = pcl::getTime ();
-    std::cout << "single search with kd tree; " << (kd_search = stop - start) << " :: " << kd_indices[0] << " , " << kd_distances [0] << std::endl;
+    start = pcl::getTime();
+    tree.radiusSearch(query, radius, kd_indices, kd_distances, k);
+    stop = pcl::getTime();
+    std::cout << "single search with kd tree; " << (kd_search = stop - start)
+              << " :: " << kd_indices[0] << " , " << kd_distances[0] << std::endl;
 
     pcl::search::BruteForce<pcl::PointXYZRGB> brute_force;
-    start = pcl::getTime ();
-    brute_force.setInputCloud (cloud);
-    stop = pcl::getTime ();
-    std::cout << "setting up brute force search: " << (bf_setup = stop - start) << std::endl;
-
-    start = pcl::getTime ();
-    brute_force.radiusSearch (query, radius, bf_indices, bf_distances, k);
-    stop = pcl::getTime ();
-    std::cout << "single search with brute force; " << (bf_search = stop - start) << " :: " << bf_indices[0] << " , " << bf_distances [0] << std::endl;
-    std::cout << "amortization after searches: " << (kd_setup - bf_setup) / (bf_search - kd_search) << std::endl;
+    start = pcl::getTime();
+    brute_force.setInputCloud(cloud);
+    stop = pcl::getTime();
+    std::cout << "setting up brute force search: " << (bf_setup = stop - start)
+              << std::endl;
+
+    start = pcl::getTime();
+    brute_force.radiusSearch(query, radius, bf_indices, bf_distances, k);
+    stop = pcl::getTime();
+    std::cout << "single search with brute force; " << (bf_search = stop - start)
+              << " :: " << bf_indices[0] << " , " << bf_distances[0] << std::endl;
+    std::cout << "amortization after searches: "
+              << (kd_setup - bf_setup) / (bf_search - kd_search) << std::endl;
   }
 
-  if (kd_indices.size () != bf_indices.size ())
-  {
-    std::cerr << "size of results do not match " <<kd_indices.size () << " vs. " << bf_indices.size () << std::endl;
+  if (kd_indices.size() != bf_indices.size()) {
+    std::cerr << "size of results do not match " << kd_indices.size() << " vs. "
+              << bf_indices.size() << std::endl;
   }
-  else
-  {
-    std::cerr << "size of result: " <<kd_indices.size () << std::endl;
-    for (std::size_t idx = 0; idx < kd_indices.size (); ++idx)
-    {
-      if (kd_indices[idx] != bf_indices[idx] && kd_distances[idx] != bf_distances[idx])
-      {
-        std::cerr << "results do not match: " << idx << " nearest neighbor: "
-                << kd_indices[idx] << " with distance: " << kd_distances[idx] << " vs. "
-                << bf_indices[idx] << " with distance: " << bf_distances[idx] << std::endl;
+  else {
+    std::cerr << "size of result: " << kd_indices.size() << std::endl;
+    for (std::size_t idx = 0; idx < kd_indices.size(); ++idx) {
+      if (kd_indices[idx] != bf_indices[idx] &&
+          kd_distances[idx] != bf_distances[idx]) {
+        std::cerr << "results do not match: " << idx
+                  << " nearest neighbor: " << kd_indices[idx]
+                  << " with distance: " << kd_distances[idx] << " vs. "
+                  << bf_indices[idx] << " with distance: " << bf_distances[idx]
+                  << std::endl;
       }
     }
   }
-  return (0);
+  return 0;
 }
index 0773e99cb262c06d7dac04ef82cb872f8e51e725..6efa822c8b8ad329d13a9aa228b076e13a202f89 100644 (file)
 #
 # .. code-block:: cmake
 #
-# find_package(ClangFormat) 
+# find_package(ClangFormat)
 # if(ClangFormat_FOUND)
 # message("clang-format executable found: ${ClangFormat_EXECUTABLE}\n"
-#         "version: ${ClangFormat_VERSION}") 
+#         "version: ${ClangFormat_VERSION}")
 # endif()
 
 find_program(ClangFormat_EXECUTABLE
              NAMES
+             # unreleased versions
+                   clang-format-14
+                   clang-format-13
+                   clang-format-12
+                   clang-format-11
+             # current latest
+                   clang-format-10
                    clang-format-9
-                   clang-format-9.0
+             # since clang-format-8, only major version is prefixed
                    clang-format-8
                    clang-format-8.0
                    clang-format-7
index 6d7ac0cf12fe326592ceaa41f1bfba2ea26cbb6e..a8329c6f67ada3ad7cca2389c1ecfcf009f0200a 100644 (file)
@@ -55,8 +55,10 @@ else()
             PATHS /usr/include /usr/local/include /opt/local/include /sw/include
             PATH_SUFFIXES libusb-1.0)
 
+  # We need to look for libusb-1.0 too because find_library does not attempt to find
+  # library files with a "lib" prefix implicitly on Windows
   find_library(LIBUSB_1_LIBRARY
-               NAMES usb-1.0
+               NAMES usb-1.0 libusb-1.0
                PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
 
   set(LIBUSB_1_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIR})
index 4587e4cc06147f0061e63a4822d2ceebe7e09ed1..9d41140467f3bda8354195b6e0a7e65f30ca101e 100644 (file)
@@ -1,10 +1,10 @@
-find_package(ClangFormat 7)
+find_package(ClangFormat 10)
 # search for version number in clang-format without version number
 if(ClangFormat_FOUND)
   message(STATUS "Adding target 'format'")
   add_custom_target(
   format
-  COMMAND sh 
+  COMMAND sh
     ${PCL_SOURCE_DIR}/.dev/format.sh
     ${ClangFormat_EXECUTABLE}
     ${PCL_SOURCE_DIR}
index 23fa7589abf1c69f20311aedd2975b878ae5e877..9dc695672580c2008098e9b071c852246a5f1e96 100644 (file)
@@ -224,6 +224,10 @@ function(PCL_ADD_LIBRARY _name)
   target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})
   # must link explicitly against boost.
   target_link_libraries(${_name} ${Boost_LIBRARIES} Threads::Threads)
+  if(TARGET OpenMP::OpenMP_CXX)
+    target_link_libraries(${_name} OpenMP::OpenMP_CXX)
+  endif()
+
   if((UNIX AND NOT ANDROID) OR MINGW)
     target_link_libraries(${_name} m)
   endif()
@@ -386,7 +390,7 @@ macro(PCL_ADD_TEST _name _exename)
   target_link_libraries(${_exename} ${Boost_LIBRARIES})
 
   #Only applies to MSVC
-  if(MSVC)    
+  if(MSVC)
     #Requires CMAKE version 3.13.0
     if(CMAKE_VERSION VERSION_LESS "3.13.0" AND (NOT ArgumentWarningShown))
       message(WARNING "Arguments for unit test projects are not added - this requires at least CMake 3.13. Can be added manually in \"Project settings -> Debugging -> Command arguments\"")
@@ -475,7 +479,7 @@ function(PCL_MAKE_PKGCONFIG _name)
   set(oneValueArgs COMPONENT DESC CFLAGS LIB_FLAGS)
   set(multiValueArgs PCL_DEPS INT_DEPS EXT_DEPS)
   cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-  
+
   set(PKG_NAME ${_name})
   set(PKG_DESC ${PKGCONFIG_DESC})
   set(PKG_CFLAGS ${PKGCONFIG_CFLAGS})
@@ -558,7 +562,7 @@ macro(PCL_SET_SUBSYS_STATUS _name _status)
   if(${ARGC} EQUAL 3)
     set(_reason ${ARGV2})
   else()
-    set(_reason "No reason")
+    set(_reason "No reason provided")
   endif()
   SET_IN_GLOBAL_MAP(PCL_SUBSYS_STATUS ${_name} ${_status})
   SET_IN_GLOBAL_MAP(PCL_SUBSYS_REASONS ${_name} ${_reason})
@@ -573,7 +577,7 @@ macro(PCL_SET_SUBSUBSYS_STATUS _parent _name _status)
   if(${ARGC} EQUAL 4)
     set(_reason ${ARGV2})
   else()
-    set(_reason "No reason")
+    set(_reason "No reason provided")
   endif()
   SET_IN_GLOBAL_MAP(PCL_SUBSYS_STATUS ${_parent}_${_name} ${_status})
   SET_IN_GLOBAL_MAP(PCL_SUBSYS_REASONS ${_parent}_${_name} ${_reason})
index 59aa3fe6686b0c3a9f74d1d81eac4a797f1cd2da..09b7cba4732b3bf3f85683a660e8bd15057c5ffa 100644 (file)
@@ -52,12 +52,15 @@ set(srcs
 
 set(incs
   include/pcl/correspondence.h
+  include/pcl/memory.h
   include/pcl/exceptions.h
   include/pcl/pcl_base.h
   include/pcl/pcl_exports.h
   include/pcl/pcl_macros.h
+  include/pcl/types.h
   include/pcl/point_cloud.h
   include/pcl/point_traits.h
+  include/pcl/type_traits.h
   include/pcl/point_types_conversion.h
   include/pcl/point_representation.h
   include/pcl/point_types.h
@@ -108,7 +111,6 @@ set(common_incs
   include/pcl/common/utils.h
   include/pcl/common/geometry.h
   include/pcl/common/gaussian.h
-  include/pcl/common/point_operators.h
   include/pcl/common/spring.h
   include/pcl/common/intensity.h
   include/pcl/common/random.h
@@ -171,6 +173,14 @@ set(kissfft_srcs
 set(LIB_NAME "pcl_${SUBSYS_NAME}")
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
 PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${kissfft_srcs} ${incs} ${common_incs} ${impl_incs} ${tools_incs} ${kissfft_incs} ${common_incs_impl} ${range_image_incs} ${range_image_incs_impl})
+
+if(MSVC AND NOT (MSVC_VERSION LESS 1915))
+  # MSVC resolved a byte alignment issue in compiler version 15.9
+  # We get this due to using Eigen objects and allocating those objects with make_shared
+  # It has to be public so that everything linking with common has this definition too
+  target_compile_definitions(${LIB_NAME} PUBLIC _ENABLE_EXTENDED_ALIGNED_STORAGE)
+endif()
+
 PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC})
 
 # Install include files
index 8a692d776569bd7fcdaa1c4cad35b6140f142fad..34e78d0099d141bc016badeae716ade1e6d14a07 100644 (file)
@@ -1,10 +1,10 @@
 #pragma once
 
+#include <pcl/memory.h>  // for shared_ptr
+
 #include <string>   // for string
 #include <ostream>  // for ostream
 
-#include <pcl/make_shared.h>  // for shared_ptr
-
 namespace pcl
 {
   struct PCLHeader
@@ -41,3 +41,4 @@ namespace pcl
   }
 
 } // namespace pcl
+
index f27ad6879a00d90762bffeb894728cb677ea2592..63b327621e89d704caed6598d18c345fec3caf90 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <boost/predef/other/endian.h>
 
+#include <pcl/pcl_macros.h>  // for PCL_EXPORTS
 #include <pcl/PCLHeader.h>
 #include <pcl/PCLPointField.h>
 
index 58f0895b773a5949349d91015e55400d143e9a66..09f90ff87be8a6f38fdad35e294ab639c96e67e6 100644 (file)
@@ -1,10 +1,11 @@
 #pragma once
 
+#include <pcl/memory.h>       // for shared_ptr
+#include <pcl/type_traits.h>  // for asEnum_v
+
 #include <string>   // for string
 #include <ostream>  // for ostream
 
-#include <pcl/pcl_macros.h>  // for shared_ptr
-
 namespace pcl
 {
   struct PCLPointField
@@ -15,14 +16,14 @@ namespace pcl
     std::uint8_t datatype = 0;
     std::uint32_t count = 0;
 
-    enum PointFieldTypes { INT8 = 1,
-                           UINT8 = 2,
-                           INT16 = 3,
-                           UINT16 = 4,
-                           INT32 = 5,
-                           UINT32 = 6,
-                           FLOAT32 = 7,
-                           FLOAT64 = };
+    enum PointFieldTypes { INT8 = traits::asEnum_v<std::int8_t>,
+                           UINT8 = traits::asEnum_v<std::uint8_t>,
+                           INT16 = traits::asEnum_v<std::int16_t>,
+                           UINT16 = traits::asEnum_v<std::uint16_t>,
+                           INT32 = traits::asEnum_v<std::int32_t>,
+                           UINT32 = traits::asEnum_v<std::uint32_t>,
+                           FLOAT32 = traits::asEnum_v<float>,
+                           FLOAT64 = traits::asEnum_v<double>};
 
   public:
     using Ptr = shared_ptr< ::pcl::PCLPointField>;
@@ -44,4 +45,20 @@ namespace pcl
     s << "  " << v.count << std::endl;
     return (s);
   }
+
+  // Return true if the PCLPointField matches the expected name and data type.
+  // Written as a struct to allow partially specializing on Tag.
+  template<typename PointT, typename Tag>
+  struct FieldMatches
+  {
+    bool operator() (const PCLPointField& field)
+    {
+      return ((field.name == traits::name<PointT, Tag>::value) &&
+              (field.datatype == traits::datatype<PointT, Tag>::value) &&
+              ((field.count == traits::datatype<PointT, Tag>::size) ||
+               (field.count == 0 && traits::datatype<PointT, Tag>::size == 1 /* see bug #821 */)));
+    }
+  };
+
 } // namespace pcl
+
index 031699f64bd2c7d2570779df40186dbe0a4bf4fd..2a648aa29ffe45ed80f6adf18733b40ceebc780d 100644 (file)
@@ -6,21 +6,21 @@
 
 // Include the correct Header path here
 #include <pcl/PCLHeader.h>
+#include <pcl/types.h>
 
 namespace pcl
 {
   struct PointIndices
   {
+    using Ptr = shared_ptr< ::pcl::PointIndices>;
+    using ConstPtr = shared_ptr<const ::pcl::PointIndices>;
+
     PointIndices ()
     {}
 
     ::pcl::PCLHeader header;
 
-    std::vector<int> indices;
-
-    public:
-      using Ptr = shared_ptr< ::pcl::PointIndices>;
-      using ConstPtr = shared_ptr<const ::pcl::PointIndices>;
+    Indices indices;
   }; // struct PointIndices
 
   using PointIndicesPtr = PointIndices::Ptr;
index cf6ab9fce9de2deec7c13269e338d18ee95fe989..2b17569232be5be81fac6d4a041fc9dc8ea7006b 100644 (file)
@@ -1,10 +1,11 @@
 #pragma once
 
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h>
+
 #include <string>
 #include <vector>
 #include <ostream>
-#include <boost/shared_ptr.hpp>
-#include <pcl/pcl_macros.h>
 
 namespace pcl
 {
index 3c5d68c0cbbb8c1526eabc5f7c1788c01e95b54d..09908e61164e9982a4fb0cd7c2e0685326cb7a9c 100644 (file)
@@ -45,8 +45,6 @@
 #ifndef Q_MOC_RUN
 // Marking all Boost headers as system headers to remove warnings
 #include <boost/fusion/sequence/intrinsic/at_key.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/make_shared.hpp>
 #include <boost/mpl/size.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/signals2.hpp>
index 8fde539b9b94e09d785fc13c1b5495d308c23d7b..6ff9cd17de954ccddae5146d1b93f78e3737ebf0 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <pcl/PointIndices.h>
 #include <pcl/cloud_iterator.h>
 
index 13804a973858f46b150c168af2c6cf47a7cc26bf..513baf77349ceda24b845904bb66bd6d4448d986 100644 (file)
@@ -46,6 +46,7 @@
 #include <boost/fusion/include/as_vector.hpp>
 #include <boost/fusion/include/filter_if.hpp>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 
index 381a7c285a05f32366cc320560d156297e8228c1..7e527a6ccf8cce5551d00873f51a0b18c9f7b8aa 100644 (file)
  * $Id$
  *
  */
-#ifndef BIVARIATE_POLYNOMIAL_HPP
-#define BIVARIATE_POLYNOMIAL_HPP
+
+#pragma once
+
+#include <pcl/common/bivariate_polynomial.h>
 
 #include <algorithm>
 #include <cmath>
 #include <iostream>
 #include <vector>
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template<typename real>
-pcl::BivariatePolynomialT<real>::BivariatePolynomialT (int new_degree) :
+BivariatePolynomialT<real>::BivariatePolynomialT (int new_degree) :
   degree(0), parameters(nullptr), gradient_x(nullptr), gradient_y(nullptr)
 {
   setDegree(new_degree);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real>
-pcl::BivariatePolynomialT<real>::BivariatePolynomialT (const BivariatePolynomialT& other) :
+BivariatePolynomialT<real>::BivariatePolynomialT (const BivariatePolynomialT& other) :
   degree(0), parameters(NULL), gradient_x(NULL), gradient_y(NULL)
 {
   deepCopy (other);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real>
-pcl::BivariatePolynomialT<real>::~BivariatePolynomialT ()
+BivariatePolynomialT<real>::~BivariatePolynomialT ()
 {
   memoryCleanUp ();
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::setDegree (int newDegree)
+BivariatePolynomialT<real>::setDegree (int newDegree)
 {
   if (newDegree <= 0)
   {
@@ -89,18 +94,18 @@ pcl::BivariatePolynomialT<real>::setDegree (int newDegree)
   delete gradient_y; gradient_y = nullptr;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::memoryCleanUp ()
+BivariatePolynomialT<real>::memoryCleanUp ()
 {
   delete[] parameters; parameters = nullptr;
   delete gradient_x; gradient_x = nullptr;
   delete gradient_y; gradient_y = nullptr;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::deepCopy (const pcl::BivariatePolynomialT<real>& other)
+BivariatePolynomialT<real>::deepCopy (const pcl::BivariatePolynomialT<real>& other)
 {
   if (this == &other) return;
   if (degree != other.degree)
@@ -109,12 +114,14 @@ pcl::BivariatePolynomialT<real>::deepCopy (const pcl::BivariatePolynomialT<real>
     degree = other.degree;
     parameters = new real[getNoOfParameters ()];
   }
-  if (other.gradient_x == NULL)
+  if (!other.gradient_x)
   {
-    delete gradient_x; gradient_x=NULL;
-    delete gradient_y; gradient_y=NULL;
+    delete gradient_x;
+    delete gradient_y;
+    gradient_x = nullptr;
+    gradient_y = nullptr;
   }
-  else if (gradient_x==NULL)
+  else if (!gradient_x)
   {
     gradient_x = new pcl::BivariatePolynomialT<real> ();
     gradient_y = new pcl::BivariatePolynomialT<real> ();
@@ -122,16 +129,16 @@ pcl::BivariatePolynomialT<real>::deepCopy (const pcl::BivariatePolynomialT<real>
 
   std::copy_n(other.parameters, getNoOfParameters (), parameters);
 
-  if (other.gradient_x != NULL)
+  if (other.gradient_x != nullptr)
   {
     gradient_x->deepCopy (*other.gradient_x);
     gradient_y->deepCopy (*other.gradient_y);
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::calculateGradient (bool forceRecalc)
+BivariatePolynomialT<real>::calculateGradient (bool forceRecalc)
 {
   if (gradient_x!=NULL && !forceRecalc) return;
 
@@ -160,9 +167,9 @@ pcl::BivariatePolynomialT<real>::calculateGradient (bool forceRecalc)
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> real
-pcl::BivariatePolynomialT<real>::getValue (real x, real y) const
+BivariatePolynomialT<real>::getValue (real x, real y) const
 {
   unsigned int parametersSize = getNoOfParameters ();
   real* tmpParameter = &parameters[parametersSize-1];
@@ -181,19 +188,19 @@ pcl::BivariatePolynomialT<real>::getValue (real x, real y) const
   return ret;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::getValueOfGradient (real x, real y, real& gradX, real& gradY)
+BivariatePolynomialT<real>::getValueOfGradient (real x, real y, real& gradX, real& gradY)
 {
   calculateGradient ();
   gradX = gradient_x->getValue (x, y);
   gradY = gradient_y->getValue (x, y);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::findCriticalPoints (std::vector<real>& x_values, std::vector<real>& y_values,
-                                                     std::vector<int>& types) const
+BivariatePolynomialT<real>::findCriticalPoints (std::vector<real>& x_values, std::vector<real>& y_values,
+                                                std::vector<int>& types) const
 {
   x_values.clear ();
   y_values.clear ();
@@ -228,9 +235,9 @@ pcl::BivariatePolynomialT<real>::findCriticalPoints (std::vector<real>& x_values
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> std::ostream&
-pcl::operator<< (std::ostream& os, const pcl::BivariatePolynomialT<real>& p)
+operator<< (std::ostream& os, const pcl::BivariatePolynomialT<real>& p)
 {
   real* tmpParameter = p.parameters;
   bool first = true;
@@ -266,26 +273,26 @@ pcl::operator<< (std::ostream& os, const pcl::BivariatePolynomialT<real>& p)
   return (os);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::writeBinary (std::ostream& os) const
+BivariatePolynomialT<real>::writeBinary (std::ostream& os) const
 {
   os.write (reinterpret_cast<const char*> (&degree), sizeof (int));
   unsigned int paramCnt = getNoOfParametersFromDegree (this->degree);
   os.write (reinterpret_cast<const char*> (this->parameters), paramCnt * sizeof (real));
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::writeBinary (const char* filename) const
+BivariatePolynomialT<real>::writeBinary (const char* filename) const
 {
   std::ofstream fout (filename);
   writeBinary (fout);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::readBinary (std::istream& os)
+BivariatePolynomialT<real>::readBinary (std::istream& os)
 {
   memoryCleanUp ();
   os.read (reinterpret_cast<char*> (&this->degree), sizeof (int));
@@ -294,12 +301,12 @@ pcl::BivariatePolynomialT<real>::readBinary (std::istream& os)
   os.read (reinterpret_cast<char*> (&(*this->parameters)), paramCnt * sizeof (real));
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename real> void
-pcl::BivariatePolynomialT<real>::readBinary (const char* filename)
+BivariatePolynomialT<real>::readBinary (const char* filename)
 {
   std::ifstream fin (filename);
   readBinary (fin);
 }
 
-#endif
+} // namespace pcl
index 65a8d4c1130a9bfa60f286925ff9981d2c961ea8..598e52324779e2b59f99da00fa6fa59995667b3f 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_IMPL_CENTROID_H_
-#define PCL_COMMON_IMPL_CENTROID_H_
+#pragma once
 
 #include <pcl/common/centroid.h>
 #include <pcl/conversions.h>
-#include <boost/mpl/size.hpp>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
+#include <boost/fusion/algorithm/transformation/filter_if.hpp> // for boost::fusion::filter_if
+#include <boost/fusion/algorithm/iteration/for_each.hpp> // for boost::fusion::for_each
+#include <boost/mpl/size.hpp> // for boost::mpl::size
+
+
+namespace pcl
+{
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::compute3DCentroid (ConstCloudIterator<PointT> &cloud_iterator,
-                        Eigen::Matrix<Scalar, 4, 1> &centroid)
+compute3DCentroid (ConstCloudIterator<PointT> &cloud_iterator,
+                   Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   // Initialize to 0
   centroid.setZero ();
-  
+
   unsigned cp = 0;
 
   // For each point in the cloud
@@ -74,10 +80,10 @@ pcl::compute3DCentroid (ConstCloudIterator<PointT> &cloud_iterator,
   return (cp);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::compute3DCentroid (const pcl::PointCloud<PointT> &cloud, 
-                        Eigen::Matrix<Scalar, 4, 1> &centroid)
+compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
+                   Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   if (cloud.empty ())
     return (0);
@@ -118,11 +124,11 @@ pcl::compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
   return (cp);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::compute3DCentroid (const pcl::PointCloud<PointT> &cloud, 
-                        const std::vector<int> &indices,
-                        Eigen::Matrix<Scalar, 4, 1> &centroid)
+compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
+                   const std::vector<int> &indices,
+                   Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   if (indices.empty ())
     return (0);
@@ -160,20 +166,20 @@ pcl::compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
   return (cp);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
-                        const pcl::PointIndices &indices,
-                        Eigen::Matrix<Scalar, 4, 1> &centroid)
+compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
+                   const pcl::PointIndices &indices,
+                   Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   return (pcl::compute3DCentroid (cloud, indices.indices, centroid));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned
-pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                              const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                              Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                         const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                         Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   if (cloud.empty ())
     return (0);
@@ -240,11 +246,11 @@ pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
   return (point_count);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
-                                        const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                                        Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
+                                   const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                                   Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   unsigned point_count = pcl::computeCovarianceMatrix (cloud, centroid, covariance_matrix);
   if (point_count != 0)
@@ -252,12 +258,12 @@ pcl::computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
   return (point_count);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                              const std::vector<int> &indices,
-                              const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                              Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                         const std::vector<int> &indices,
+                         const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                         Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   if (indices.empty ())
     return (0);
@@ -323,22 +329,22 @@ pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
   return (static_cast<unsigned int> (point_count));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                              const pcl::PointIndices &indices,
-                              const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                              Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                         const pcl::PointIndices &indices,
+                         const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                         Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   return (pcl::computeCovarianceMatrix (cloud, indices.indices, centroid, covariance_matrix));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
-                                        const std::vector<int> &indices,
-                                        const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                                        Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
+                                   const std::vector<int> &indices,
+                                   const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                                   Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   unsigned point_count = pcl::computeCovarianceMatrix (cloud, indices, centroid, covariance_matrix);
   if (point_count != 0)
@@ -347,12 +353,12 @@ pcl::computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
   return (point_count);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
-                                        const pcl::PointIndices &indices,
-                                        const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                                        Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
+                                   const pcl::PointIndices &indices,
+                                   const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                                   Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   unsigned int point_count = pcl::computeCovarianceMatrix (cloud, indices.indices, centroid, covariance_matrix);
   if (point_count != 0)
@@ -361,10 +367,10 @@ pcl::computeCovarianceMatrixNormalized (const pcl::PointCloud<PointT> &cloud,
   return point_count;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                              Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                         Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   // create the buffer on the stack which is much faster than using cloud[indices[i]] and centroid as a buffer
   Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor>::Zero ();
@@ -415,11 +421,11 @@ pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
   return (point_count);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                              const std::vector<int> &indices,
-                              Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                         const std::vector<int> &indices,
+                         Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   // create the buffer on the stack which is much faster than using cloud[indices[i]] and centroid as a buffer
   Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor>::Zero ();
@@ -469,20 +475,20 @@ pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
   return (point_count);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                              const pcl::PointIndices &indices,
-                              Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
+computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                         const pcl::PointIndices &indices,
+                         Eigen::Matrix<Scalar, 3, 3> &covariance_matrix)
 {
   return (computeCovarianceMatrix (cloud, indices.indices, covariance_matrix));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                                     Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
-                                     Eigen::Matrix<Scalar, 4, 1> &centroid)
+computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                                Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
+                                Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   // create the buffer on the stack which is much faster than using cloud[indices[i]] and centroid as a buffer
   Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor>::Zero ();
@@ -543,12 +549,12 @@ pcl::computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
   return (static_cast<unsigned int> (point_count));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                                     const std::vector<int> &indices,
-                                     Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
-                                     Eigen::Matrix<Scalar, 4, 1> &centroid)
+computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                                const std::vector<int> &indices,
+                                Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
+                                Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   // create the buffer on the stack which is much faster than using cloud[indices[i]] and centroid as a buffer
   Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor> accu = Eigen::Matrix<Scalar, 1, 9, Eigen::RowMajor>::Zero ();
@@ -610,22 +616,22 @@ pcl::computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
   return (static_cast<unsigned int> (point_count));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline unsigned int
-pcl::computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
-                                     const pcl::PointIndices &indices,
-                                     Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
-                                     Eigen::Matrix<Scalar, 4, 1> &centroid)
+computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
+                                const pcl::PointIndices &indices,
+                                Eigen::Matrix<Scalar, 3, 3> &covariance_matrix,
+                                Eigen::Matrix<Scalar, 4, 1> &centroid)
 {
   return (computeMeanAndCovarianceMatrix (cloud, indices.indices, covariance_matrix, centroid));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (ConstCloudIterator<PointT> &cloud_iterator,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       pcl::PointCloud<PointT> &cloud_out,
-                       int npts)
+demeanPointCloud (ConstCloudIterator<PointT> &cloud_iterator,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  pcl::PointCloud<PointT> &cloud_out,
+                  int npts)
 {
   // Calculate the number of points if not given
   if (npts == 0)
@@ -653,11 +659,11 @@ pcl::demeanPointCloud (ConstCloudIterator<PointT> &cloud_iterator,
   cloud_out.height = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       pcl::PointCloud<PointT> &cloud_out)
+demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  pcl::PointCloud<PointT> &cloud_out)
 {
   cloud_out = cloud_in;
 
@@ -670,12 +676,12 @@ pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                       const std::vector<int> &indices,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       pcl::PointCloud<PointT> &cloud_out)
+demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const std::vector<int> &indices,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  pcl::PointCloud<PointT> &cloud_out)
 {
   cloud_out.header = cloud_in.header;
   cloud_out.is_dense = cloud_in.is_dense;
@@ -700,22 +706,22 @@ pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                       const pcl::PointIndices& indices,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       pcl::PointCloud<PointT> &cloud_out)
+demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const pcl::PointIndices& indices,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  pcl::PointCloud<PointT> &cloud_out)
 {
   return (demeanPointCloud (cloud_in, indices.indices, centroid, cloud_out));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (ConstCloudIterator<PointT> &cloud_iterator,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out,
-                       int npts)
+demeanPointCloud (ConstCloudIterator<PointT> &cloud_iterator,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out,
+                  int npts)
 {
   // Calculate the number of points if not given
   if (npts == 0)
@@ -741,11 +747,11 @@ pcl::demeanPointCloud (ConstCloudIterator<PointT> &cloud_iterator,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
+demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
 {
   std::size_t npts = cloud_in.size ();
 
@@ -764,12 +770,12 @@ pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   //cloud_out.block (3, 0, 1, npts).setZero ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                       const std::vector<int> &indices,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
+demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const std::vector<int> &indices,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
 {
   std::size_t npts = indices.size ();
 
@@ -788,20 +794,20 @@ pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   //cloud_out.block (3, 0, 1, npts).setZero ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                       const pcl::PointIndices &indices,
-                       const Eigen::Matrix<Scalar, 4, 1> &centroid,
-                       Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
+demeanPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const pcl::PointIndices &indices,
+                  const Eigen::Matrix<Scalar, 4, 1> &centroid,
+                  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_out)
 {
   return (pcl::demeanPointCloud (cloud_in, indices.indices, centroid, cloud_out));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline void
-pcl::computeNDCentroid (const pcl::PointCloud<PointT> &cloud, 
-                        Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &centroid)
+computeNDCentroid (const pcl::PointCloud<PointT> &cloud,
+                   Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &centroid)
 {
   using FieldList = typename pcl::traits::fieldList<PointT>::type;
 
@@ -820,11 +826,11 @@ pcl::computeNDCentroid (const pcl::PointCloud<PointT> &cloud,
   centroid /= static_cast<Scalar> (cloud.size ());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline void
-pcl::computeNDCentroid (const pcl::PointCloud<PointT> &cloud, 
-                        const std::vector<int> &indices,
-                        Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &centroid)
+computeNDCentroid (const pcl::PointCloud<PointT> &cloud,
+                   const std::vector<int> &indices,
+                   Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &centroid)
 {
   using FieldList = typename pcl::traits::fieldList<PointT>::type;
 
@@ -843,17 +849,17 @@ pcl::computeNDCentroid (const pcl::PointCloud<PointT> &cloud,
   centroid /= static_cast<Scalar> (indices.size ());
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline void
-pcl::computeNDCentroid (const pcl::PointCloud<PointT> &cloud,
-                        const pcl::PointIndices &indices, 
-                        Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &centroid)
+computeNDCentroid (const pcl::PointCloud<PointT> &cloud,
+                   const pcl::PointIndices &indices,
+                   Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &centroid)
 {
   return (pcl::computeNDCentroid (cloud, indices.indices, centroid));
 }
 
 template <typename PointT> void
-pcl::CentroidPoint<PointT>::add (const PointT& point)
+CentroidPoint<PointT>::add (const PointT& point)
 {
   // Invoke add point on each accumulator
   boost::fusion::for_each (accumulators_, detail::AddPoint<PointT> (point));
@@ -862,7 +868,7 @@ pcl::CentroidPoint<PointT>::add (const PointT& point)
 
 template <typename PointT>
 template <typename PointOutT> void
-pcl::CentroidPoint<PointT>::get (PointOutT& point) const
+CentroidPoint<PointT>::get (PointOutT& point) const
 {
   if (num_points_ != 0)
   {
@@ -874,8 +880,9 @@ pcl::CentroidPoint<PointT>::get (PointOutT& point) const
   }
 }
 
+
 template <typename PointInT, typename PointOutT> std::size_t
-pcl::computeCentroid (const pcl::PointCloud<PointInT>& cloud,
+computeCentroid (const pcl::PointCloud<PointInT>& cloud,
                       PointOutT& centroid)
 {
   pcl::CentroidPoint<PointInT> cp;
@@ -892,8 +899,9 @@ pcl::computeCentroid (const pcl::PointCloud<PointInT>& cloud,
   return (cp.getSize ());
 }
 
+
 template <typename PointInT, typename PointOutT> std::size_t
-pcl::computeCentroid (const pcl::PointCloud<PointInT>& cloud,
+computeCentroid (const pcl::PointCloud<PointInT>& cloud,
                       const std::vector<int>& indices,
                       PointOutT& centroid)
 {
@@ -911,5 +919,5 @@ pcl::computeCentroid (const pcl::PointCloud<PointInT>& cloud,
   return (cp.getSize ());
 }
 
-#endif  //#ifndef PCL_COMMON_IMPL_CENTROID_H_
+} // namespace pcl
 
index a168226280d250f69f5b579f45e1000e57976bbb..d5978f539d7ccd28d8307b38d86f13b964f0fd7b 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_IMPL_COPY_POINT_HPP_
-#define PCL_COMMON_IMPL_COPY_POINT_HPP_
+#pragma once
 
 #include <pcl/point_types.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <pcl/for_each_type.h>
 #include <pcl/common/concatenate.h>
+#include <pcl/common/copy_point.h>
+
 
 namespace pcl
 {
 
-  namespace detail
-  {
-
-    /* CopyPointHelper and its specializations copy the contents of a source
-     * point to a target point. There are three cases:
-     *
-     *  - Points have the same type.
-     *    In this case a single `memcpy` is used.
-     *
-     *  - Points have different types and one of the following is true:
-     *      * both have RGB fields;
-     *      * both have RGBA fields;
-     *      * one or both have no RGB/RGBA fields.
-     *    In this case we find the list of common fields and copy their
-     *    contents one by one with `NdConcatenateFunctor`.
-     *
-     *  - Points have different types and one of these types has RGB field, and
-     *    the other has RGBA field.
-     *    In this case we also find the list of common fields and copy their
-     *    contents. In order to account for the fact that RGB and RGBA do not
-     *    match we have an additional `memcpy` to copy the contents of one into
-     *    another.
-     *
-     * An appropriate version of CopyPointHelper is instantiated during
-     * compilation time automatically, so there is absolutely no run-time
-     * overhead. */
+namespace detail
+{
 
-    template <typename PointInT, typename PointOutT, typename Enable = void>
-    struct CopyPointHelper { };
+/* CopyPointHelper and its specializations copy the contents of a source
+ * point to a target point. There are three cases:
+ *
+ *  - Points have the same type.
+ *    In this case a single `memcpy` is used.
+ *
+ *  - Points have different types and one of the following is true:
+ *      * both have RGB fields;
+ *      * both have RGBA fields;
+ *      * one or both have no RGB/RGBA fields.
+ *    In this case we find the list of common fields and copy their
+ *    contents one by one with `NdConcatenateFunctor`.
+ *
+ *  - Points have different types and one of these types has RGB field, and
+ *    the other has RGBA field.
+ *    In this case we also find the list of common fields and copy their
+ *    contents. In order to account for the fact that RGB and RGBA do not
+ *    match we have an additional `memcpy` to copy the contents of one into
+ *    another.
+ *
+ * An appropriate version of CopyPointHelper is instantiated during
+ * compilation time automatically, so there is absolutely no run-time
+ * overhead. */
 
-    template <typename PointInT, typename PointOutT>
-    struct CopyPointHelper<PointInT, PointOutT, std::enable_if_t<std::is_same<PointInT, PointOutT>::value>>
-    {
-      void operator () (const PointInT& point_in, PointOutT& point_out) const
-      {
-        memcpy (&point_out, &point_in, sizeof (PointInT));
-      }
-    };
+template <typename PointInT, typename PointOutT, typename Enable = void>
+struct CopyPointHelper { };
 
-    template <typename PointInT, typename PointOutT>
-    struct CopyPointHelper<PointInT, PointOutT,
-                           std::enable_if_t<boost::mpl::and_<boost::mpl::not_<std::is_same<PointInT, PointOutT>>,
-                                                             boost::mpl::or_<boost::mpl::not_<pcl::traits::has_color<PointInT>>,
-                                                                             boost::mpl::not_<pcl::traits::has_color<PointOutT>>,
-                                                                             boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgb>,
-                                                                                              pcl::traits::has_field<PointOutT, pcl::fields::rgb>>,
-                                                                             boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgba>,
-                                                                                              pcl::traits::has_field<PointOutT, pcl::fields::rgba>>>>::value>>
-    {
-      void operator () (const PointInT& point_in, PointOutT& point_out) const
-      {
-        using FieldListInT = typename pcl::traits::fieldList<PointInT>::type;
-        using FieldListOutT = typename pcl::traits::fieldList<PointOutT>::type;
-        using FieldList = typename pcl::intersect<FieldListInT, FieldListOutT>::type;
-        pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointInT, PointOutT> (point_in, point_out));
-      }
-    };
+template <typename PointInT, typename PointOutT>
+struct CopyPointHelper<PointInT, PointOutT, std::enable_if_t<std::is_same<PointInT, PointOutT>::value>>
+{
+  void operator () (const PointInT& point_in, PointOutT& point_out) const
+  {
+    memcpy (&point_out, &point_in, sizeof (PointInT));
+  }
+};
 
-    template <typename PointInT, typename PointOutT>
-    struct CopyPointHelper<PointInT, PointOutT,
-                           std::enable_if_t<boost::mpl::and_<boost::mpl::not_<std::is_same<PointInT, PointOutT>>,
-                                            boost::mpl::or_<boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgb>,
-                                                                             pcl::traits::has_field<PointOutT, pcl::fields::rgba>>,
-                                                            boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgba>,
-                                                                             pcl::traits::has_field<PointOutT, pcl::fields::rgb>>>>::value>>
-    {
-      void operator () (const PointInT& point_in, PointOutT& point_out) const
-      {
-        using FieldListInT = typename pcl::traits::fieldList<PointInT>::type;
-        using FieldListOutT = typename pcl::traits::fieldList<PointOutT>::type;
-        using FieldList = typename pcl::intersect<FieldListInT, FieldListOutT>::type;
-        const std::uint32_t offset_in  = boost::mpl::if_<pcl::traits::has_field<PointInT, pcl::fields::rgb>,
-                                                    pcl::traits::offset<PointInT, pcl::fields::rgb>,
-                                                    pcl::traits::offset<PointInT, pcl::fields::rgba> >::type::value;
-        const std::uint32_t offset_out = boost::mpl::if_<pcl::traits::has_field<PointOutT, pcl::fields::rgb>,
-                                                    pcl::traits::offset<PointOutT, pcl::fields::rgb>,
-                                                    pcl::traits::offset<PointOutT, pcl::fields::rgba> >::type::value;
-        pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointInT, PointOutT> (point_in, point_out));
-        memcpy (reinterpret_cast<char*> (&point_out) + offset_out,
-                reinterpret_cast<const char*> (&point_in) + offset_in,
-                4);
-      }
-    };
+template <typename PointInT, typename PointOutT>
+struct CopyPointHelper<PointInT, PointOutT,
+                       std::enable_if_t<boost::mpl::and_<boost::mpl::not_<std::is_same<PointInT, PointOutT>>,
+                                                         boost::mpl::or_<boost::mpl::not_<pcl::traits::has_color<PointInT>>,
+                                                                         boost::mpl::not_<pcl::traits::has_color<PointOutT>>,
+                                                                         boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgb>,
+                                                                                          pcl::traits::has_field<PointOutT, pcl::fields::rgb>>,
+                                                                         boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgba>,
+                                                                                          pcl::traits::has_field<PointOutT, pcl::fields::rgba>>>>::value>>
+{
+  void operator () (const PointInT& point_in, PointOutT& point_out) const
+  {
+    using FieldListInT = typename pcl::traits::fieldList<PointInT>::type;
+    using FieldListOutT = typename pcl::traits::fieldList<PointOutT>::type;
+    using FieldList = typename pcl::intersect<FieldListInT, FieldListOutT>::type;
+    pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointInT, PointOutT> (point_in, point_out));
+  }
+};
 
+template <typename PointInT, typename PointOutT>
+struct CopyPointHelper<PointInT, PointOutT,
+                       std::enable_if_t<boost::mpl::and_<boost::mpl::not_<std::is_same<PointInT, PointOutT>>,
+                                        boost::mpl::or_<boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgb>,
+                                                                         pcl::traits::has_field<PointOutT, pcl::fields::rgba>>,
+                                                        boost::mpl::and_<pcl::traits::has_field<PointInT, pcl::fields::rgba>,
+                                                                         pcl::traits::has_field<PointOutT, pcl::fields::rgb>>>>::value>>
+{
+  void operator () (const PointInT& point_in, PointOutT& point_out) const
+  {
+    using FieldListInT = typename pcl::traits::fieldList<PointInT>::type;
+    using FieldListOutT = typename pcl::traits::fieldList<PointOutT>::type;
+    using FieldList = typename pcl::intersect<FieldListInT, FieldListOutT>::type;
+    const std::uint32_t offset_in  = boost::mpl::if_<pcl::traits::has_field<PointInT, pcl::fields::rgb>,
+                                                pcl::traits::offset<PointInT, pcl::fields::rgb>,
+                                                pcl::traits::offset<PointInT, pcl::fields::rgba> >::type::value;
+    const std::uint32_t offset_out = boost::mpl::if_<pcl::traits::has_field<PointOutT, pcl::fields::rgb>,
+                                                pcl::traits::offset<PointOutT, pcl::fields::rgb>,
+                                                pcl::traits::offset<PointOutT, pcl::fields::rgba> >::type::value;
+    pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointInT, PointOutT> (point_in, point_out));
+    memcpy (reinterpret_cast<char*> (&point_out) + offset_out,
+            reinterpret_cast<const char*> (&point_in) + offset_in,
+            4);
   }
+};
 
-}
+} // namespace detail
 
 template <typename PointInT, typename PointOutT> void
-pcl::copyPoint (const PointInT& point_in, PointOutT& point_out)
+copyPoint (const PointInT& point_in, PointOutT& point_out)
 {
   detail::CopyPointHelper<PointInT, PointOutT> copy;
   copy (point_in, point_out);
 }
 
-#endif //PCL_COMMON_IMPL_COPY_POINT_HPP_
+} // namespace pcl
 
index d41f205538cb1254700e12c9a199f44248e4e683..9388ce1fc436c2ff4bc74f4fc82070833d41f8b1 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_EIGEN_IMPL_HPP_
-#define PCL_COMMON_EIGEN_IMPL_HPP_
+#pragma once
+
+#include <pcl/common/eigen.h>
+#include <pcl/console/print.h>
 
 #include <array>
 #include <algorithm>
 #include <cmath>
-#include <pcl/console/print.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename Scalar, typename Roots> inline void
-pcl::computeRoots2 (const Scalar& b, const Scalar& c, Roots& roots)
+computeRoots2 (const Scalar& b, const Scalar& c, Roots& roots)
 {
   roots (0) = Scalar (0);
   Scalar d = Scalar (b * b - 4.0 * c);
@@ -59,9 +63,9 @@ pcl::computeRoots2 (const Scalar& b, const Scalar& c, Roots& roots)
   roots (1) = 0.5f * (b - sd);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Roots> inline void
-pcl::computeRoots (const Matrix& m, Roots& roots)
+computeRoots (const Matrix& m, Roots& roots)
 {
   using Scalar = typename Matrix::Scalar;
 
@@ -124,9 +128,9 @@ pcl::computeRoots (const Matrix& m, Roots& roots)
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Vector> inline void
-pcl::eigen22 (const Matrix& mat, typename Matrix::Scalar& eigenvalue, Vector& eigenvector)
+eigen22 (const Matrix& mat, typename Matrix::Scalar& eigenvalue, Vector& eigenvector)
 {
   // if diagonal matrix, the eigenvalues are the diagonal elements
   // and the eigenvectors are not unique, thus set to Identity
@@ -163,9 +167,9 @@ pcl::eigen22 (const Matrix& mat, typename Matrix::Scalar& eigenvalue, Vector& ei
   eigenvector.normalize ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Vector> inline void
-pcl::eigen22 (const Matrix& mat, Matrix& eigenvectors, Vector& eigenvalues)
+eigen22 (const Matrix& mat, Matrix& eigenvectors, Vector& eigenvalues)
 {
   // if diagonal matrix, the eigenvalues are the diagonal elements
   // and the eigenvectors are not unique, thus set to Identity
@@ -217,9 +221,9 @@ pcl::eigen22 (const Matrix& mat, Matrix& eigenvectors, Vector& eigenvalues)
   eigenvectors.coeffRef (3) = -eigenvectors.coeffRef (0);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Vector> inline void
-pcl::computeCorrespondingEigenVector (const Matrix& mat, const typename Matrix::Scalar& eigenvalue, Vector& eigenvector)
+computeCorrespondingEigenVector (const Matrix& mat, const typename Matrix::Scalar& eigenvalue, Vector& eigenvector)
 {
   using Scalar = typename Matrix::Scalar;
   // Scale the matrix so its entries are in [-1,1].  The scaling is applied
@@ -249,8 +253,9 @@ pcl::computeCorrespondingEigenVector (const Matrix& mat, const typename Matrix::
     eigenvector = vec3 / std::sqrt (len3);
 }
 
-namespace pcl {
-namespace detail{
+namespace detail
+{
+
 template <typename Vector, typename Scalar>
 struct EigenVector {
   Vector vector;
@@ -283,12 +288,12 @@ getLargest3x3Eigenvector (const Matrix scaledMatrix)
   return EigenVector<Vector, Scalar> {crossProduct.row (index) / length,
                                       length};
 }
+
 }  // namespace detail
-}  // namespace pcl
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Vector> inline void
-pcl::eigen33 (const Matrix& mat, typename Matrix::Scalar& eigenvalue, Vector& eigenvector)
+eigen33 (const Matrix& mat, typename Matrix::Scalar& eigenvalue, Vector& eigenvector)
 {
   using Scalar = typename Matrix::Scalar;
   // Scale the matrix so its entries are in [-1,1].  The scaling is applied
@@ -310,9 +315,9 @@ pcl::eigen33 (const Matrix& mat, typename Matrix::Scalar& eigenvalue, Vector& ei
   eigenvector = detail::getLargest3x3Eigenvector<Vector> (scaledMat).vector;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Vector> inline void
-pcl::eigen33 (const Matrix& mat, Vector& evals)
+eigen33 (const Matrix& mat, Vector& evals)
 {
   using Scalar = typename Matrix::Scalar;
   Scalar scale = mat.cwiseAbs ().maxCoeff ();
@@ -324,9 +329,9 @@ pcl::eigen33 (const Matrix& mat, Vector& evals)
   evals *= scale;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix, typename Vector> inline void
-pcl::eigen33 (const Matrix& mat, Matrix& evecs, Vector& evals)
+eigen33 (const Matrix& mat, Matrix& evecs, Vector& evals)
 {
   using Scalar = typename Matrix::Scalar;
   // Scale the matrix so its entries are in [-1,1].  The scaling is applied
@@ -395,9 +400,9 @@ pcl::eigen33 (const Matrix& mat, Matrix& evecs, Vector& evals)
   evals *= scale;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix> inline typename Matrix::Scalar
-pcl::invert2x2 (const Matrix& matrix, Matrix& inverse)
+invert2x2 (const Matrix& matrix, Matrix& inverse)
 {
   using Scalar = typename Matrix::Scalar;
   Scalar det = matrix.coeff (0) * matrix.coeff (3) - matrix.coeff (1) * matrix.coeff (2);
@@ -414,9 +419,9 @@ pcl::invert2x2 (const Matrix& matrix, Matrix& inverse)
   return det;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix> inline typename Matrix::Scalar
-pcl::invert3x3SymMatrix (const Matrix& matrix, Matrix& inverse)
+invert3x3SymMatrix (const Matrix& matrix, Matrix& inverse)
 {
   using Scalar = typename Matrix::Scalar;
   // elements
@@ -449,9 +454,9 @@ pcl::invert3x3SymMatrix (const Matrix& matrix, Matrix& inverse)
   return det;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix> inline typename Matrix::Scalar
-pcl::invert3x3Matrix (const Matrix& matrix, Matrix& inverse)
+invert3x3Matrix (const Matrix& matrix, Matrix& inverse)
 {
   using Scalar = typename Matrix::Scalar;
 
@@ -482,9 +487,9 @@ pcl::invert3x3Matrix (const Matrix& matrix, Matrix& inverse)
   return det;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Matrix> inline typename Matrix::Scalar
-pcl::determinant3x3Matrix (const Matrix& matrix)
+determinant3x3Matrix (const Matrix& matrix)
 {
   // result is independent of Row/Col Major storage!
   return matrix.coeff (0) * (matrix.coeff (4) * matrix.coeff (8) - matrix.coeff (5) * matrix.coeff (7)) +
@@ -492,11 +497,11 @@ pcl::determinant3x3Matrix (const Matrix& matrix)
          matrix.coeff (2) * (matrix.coeff (3) * matrix.coeff (7) - matrix.coeff (4) * matrix.coeff (6)) ;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 void
-pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
-                                const Eigen::Vector3f& y_direction,
-                                Eigen::Affine3f& transformation)
+getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
+                           const Eigen::Vector3f& y_direction,
+                           Eigen::Affine3f& transformation)
 {
   Eigen::Vector3f tmp0 = (y_direction.cross(z_axis)).normalized();
   Eigen::Vector3f tmp1 = (z_axis.cross(tmp0)).normalized();
@@ -508,21 +513,21 @@ pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
   transformation(3,0)=0.0f;    transformation(3,1)=0.0f;    transformation(3,2)=0.0f;    transformation(3,3)=1.0f;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 Eigen::Affine3f
-pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
-                                const Eigen::Vector3f& y_direction)
+getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
+                           const Eigen::Vector3f& y_direction)
 {
   Eigen::Affine3f transformation;
   getTransFromUnitVectorsZY (z_axis, y_direction, transformation);
   return (transformation);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 void
-pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
-                                const Eigen::Vector3f& y_direction,
-                                Eigen::Affine3f& transformation)
+getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
+                           const Eigen::Vector3f& y_direction,
+                           Eigen::Affine3f& transformation)
 {
   Eigen::Vector3f tmp2 = (x_axis.cross(y_direction)).normalized();
   Eigen::Vector3f tmp1 = (tmp2.cross(x_axis)).normalized();
@@ -534,60 +539,61 @@ pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
   transformation(3,0)=0.0f;    transformation(3,1)=0.0f;    transformation(3,2)=0.0f;    transformation(3,3)=1.0f;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 Eigen::Affine3f
-pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
-                                const Eigen::Vector3f& y_direction)
+getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
+                           const Eigen::Vector3f& y_direction)
 {
   Eigen::Affine3f transformation;
   getTransFromUnitVectorsXY (x_axis, y_direction, transformation);
   return (transformation);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 void
-pcl::getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
-                                          const Eigen::Vector3f& z_axis,
-                                          Eigen::Affine3f& transformation)
+getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
+                                     const Eigen::Vector3f& z_axis,
+                                     Eigen::Affine3f& transformation)
 {
   getTransFromUnitVectorsZY (z_axis, y_direction, transformation);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 Eigen::Affine3f
-pcl::getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
-                                          const Eigen::Vector3f& z_axis)
+getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
+                                     const Eigen::Vector3f& z_axis)
 {
   Eigen::Affine3f transformation;
   getTransformationFromTwoUnitVectors (y_direction, z_axis, transformation);
   return (transformation);
 }
 
+
 void
-pcl::getTransformationFromTwoUnitVectorsAndOrigin (const Eigen::Vector3f& y_direction,
-                                                   const Eigen::Vector3f& z_axis,
-                                                   const Eigen::Vector3f& origin,
-                                                   Eigen::Affine3f& transformation)
+getTransformationFromTwoUnitVectorsAndOrigin (const Eigen::Vector3f& y_direction,
+                                              const Eigen::Vector3f& z_axis,
+                                              const Eigen::Vector3f& origin,
+                                              Eigen::Affine3f& transformation)
 {
   getTransformationFromTwoUnitVectors(y_direction, z_axis, transformation);
   Eigen::Vector3f translation = transformation*origin;
   transformation(0,3)=-translation[0];  transformation(1,3)=-translation[1];  transformation(2,3)=-translation[2];
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> void
-pcl::getEulerAngles (const Eigen::Transform<Scalar, 3, Eigen::Affine> &t, Scalar &roll, Scalar &pitch, Scalar &yaw)
+getEulerAngles (const Eigen::Transform<Scalar, 3, Eigen::Affine> &t, Scalar &roll, Scalar &pitch, Scalar &yaw)
 {
   roll = std::atan2 (t (2, 1), t (2, 2));
   pitch = asin (-t (2, 0));
   yaw = std::atan2 (t (1, 0), t (0, 0));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> void
-pcl::getTranslationAndEulerAngles (const Eigen::Transform<Scalar, 3, Eigen::Affine> &t,
-                                  Scalar &x, Scalar &y, Scalar &z,
-                                  Scalar &roll, Scalar &pitch, Scalar &yaw)
+getTranslationAndEulerAngles (const Eigen::Transform<Scalar, 3, Eigen::Affine> &t,
+                              Scalar &x, Scalar &y, Scalar &z,
+                              Scalar &roll, Scalar &pitch, Scalar &yaw)
 {
   x = t (0, 3);
   y = t (1, 3);
@@ -597,11 +603,11 @@ pcl::getTranslationAndEulerAngles (const Eigen::Transform<Scalar, 3, Eigen::Affi
   yaw = std::atan2 (t (1, 0), t (0, 0));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> void
-pcl::getTransformation (Scalar x, Scalar y, Scalar z,
-                        Scalar roll, Scalar pitch, Scalar yaw,
-                        Eigen::Transform<Scalar, 3, Eigen::Affine> &t)
+getTransformation (Scalar x, Scalar y, Scalar z,
+                   Scalar roll, Scalar pitch, Scalar yaw,
+                   Eigen::Transform<Scalar, 3, Eigen::Affine> &t)
 {
   Scalar A = std::cos (yaw),  B = sin (yaw),  C  = std::cos (pitch), D  = sin (pitch),
          E = std::cos (roll), F = sin (roll), DE = D*E,         DF = D*F;
@@ -612,9 +618,9 @@ pcl::getTransformation (Scalar x, Scalar y, Scalar z,
   t (3, 0) = 0;    t (3, 1) = 0;           t (3, 2) = 0;           t (3, 3) = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Derived> void
-pcl::saveBinary (const Eigen::MatrixBase<Derived>& matrix, std::ostream& file)
+saveBinary (const Eigen::MatrixBase<Derived>& matrix, std::ostream& file)
 {
   std::uint32_t rows = static_cast<std::uint32_t> (matrix.rows ()), cols = static_cast<std::uint32_t> (matrix.cols ());
   file.write (reinterpret_cast<char*> (&rows), sizeof (rows));
@@ -627,9 +633,9 @@ pcl::saveBinary (const Eigen::MatrixBase<Derived>& matrix, std::ostream& file)
     }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Derived> void
-pcl::loadBinary (Eigen::MatrixBase<Derived> const & matrix_, std::istream& file)
+loadBinary (Eigen::MatrixBase<Derived> const & matrix_, std::istream& file)
 {
   Eigen::MatrixBase<Derived> &matrix = const_cast<Eigen::MatrixBase<Derived> &> (matrix_);
 
@@ -648,10 +654,10 @@ pcl::loadBinary (Eigen::MatrixBase<Derived> const & matrix_, std::istream& file)
     }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Derived, typename OtherDerived>
 typename Eigen::internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type
-pcl::umeyama (const Eigen::MatrixBase<Derived>& src, const Eigen::MatrixBase<OtherDerived>& dst, bool with_scaling)
+umeyama (const Eigen::MatrixBase<Derived>& src, const Eigen::MatrixBase<OtherDerived>& dst, bool with_scaling)
 {
 #if EIGEN_VERSION_AT_LEAST (3, 3, 0)
   return Eigen::umeyama (src, dst, with_scaling);
@@ -725,11 +731,11 @@ pcl::umeyama (const Eigen::MatrixBase<Derived>& src, const Eigen::MatrixBase<Oth
 #endif
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> bool
-pcl::transformLine (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_in,
-                          Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_out,
-                    const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
+transformLine (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_in,
+                     Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_out,
+               const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
 {
   if (line_in.innerSize () != 6 || line_out.innerSize () != 6)
   {
@@ -747,11 +753,11 @@ pcl::transformLine (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_in,
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> void
-pcl::transformPlane (const Eigen::Matrix<Scalar, 4, 1> &plane_in,
-                           Eigen::Matrix<Scalar, 4, 1> &plane_out,
-                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
+transformPlane (const Eigen::Matrix<Scalar, 4, 1> &plane_in,
+                      Eigen::Matrix<Scalar, 4, 1> &plane_out,
+                const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
 {
   Eigen::Hyperplane < Scalar, 3 > plane;
   plane.coeffs () << plane_in;
@@ -764,11 +770,11 @@ pcl::transformPlane (const Eigen::Matrix<Scalar, 4, 1> &plane_in,
   #endif
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> void
-pcl::transformPlane (const pcl::ModelCoefficients::Ptr plane_in,
-                           pcl::ModelCoefficients::Ptr plane_out,
-                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
+transformPlane (const pcl::ModelCoefficients::Ptr plane_in,
+                      pcl::ModelCoefficients::Ptr plane_out,
+                const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
 {
   std::vector<Scalar> values (plane_in->values.begin (), plane_in->values.end ());
   Eigen::Matrix < Scalar, 4, 1 > v_plane_in (values.data ());
@@ -777,12 +783,12 @@ pcl::transformPlane (const pcl::ModelCoefficients::Ptr plane_in,
   std::copy_n(v_plane_in.data (), 4, plane_in->values.begin ());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> bool
-pcl::checkCoordinateSystem (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_x,
-                            const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_y,
-                            const Scalar norm_limit,
-                            const Scalar dot_limit)
+checkCoordinateSystem (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_x,
+                       const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line_y,
+                       const Scalar norm_limit,
+                       const Scalar dot_limit)
 {
   if (line_x.innerSize () != 6 || line_y.innerSize () != 6)
   {
@@ -843,13 +849,13 @@ pcl::checkCoordinateSystem (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename Scalar> bool
-pcl::transformBetween2CoordinateSystems (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> from_line_x,
-                                         const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> from_line_y,
-                                         const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> to_line_x,
-                                         const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> to_line_y,
-                                         Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
+transformBetween2CoordinateSystems (const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> from_line_x,
+                                    const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> from_line_y,
+                                    const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> to_line_x,
+                                    const Eigen::Matrix<Scalar, Eigen::Dynamic, 1> to_line_y,
+                                    Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
 {
   if (from_line_x.innerSize () != 6 || from_line_y.innerSize () != 6 || to_line_x.innerSize () != 6 || to_line_y.innerSize () != 6)
   {
@@ -901,4 +907,5 @@ pcl::transformBetween2CoordinateSystems (const Eigen::Matrix<Scalar, Eigen::Dyna
   return (true);
 }
 
-#endif  //PCL_COMMON_EIGEN_IMPL_HPP_
+} // namespace pcl
+
index 3631a0de17e51d25848b7f0649380bb544d7b810..403231dcbe91d46a5fd791b27e6e15b3b99b1227 100644 (file)
@@ -4,7 +4,7 @@
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2011, Willow Garage, Inc.
  *
- *  All rights reserved. 
+ *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *
  */
 
-#ifndef PCL_GAUSSIAN_KERNEL_IMPL
-#define PCL_GAUSSIAN_KERNEL_IMPL
+#pragma once
 
+#include <pcl/common/gaussian.h>
 #include <pcl/exceptions.h>
 
+namespace pcl
+{
+
 template <typename PointT> void
-pcl::GaussianKernel::convolveRows(const pcl::PointCloud<PointT> &input,
-                                  std::function <float (const PointT& p)> field_accessor,
-                                  const Eigen::VectorXf& kernel,
-                                  pcl::PointCloud<float> &output) const
+GaussianKernel::convolveRows(const pcl::PointCloud<PointT> &input,
+                             std::function <float (const PointT& p)> field_accessor,
+                             const Eigen::VectorXf& kernel,
+                             pcl::PointCloud<float> &output) const
 {
   assert(kernel.size () % 2 == 1);
   int kernel_width = kernel.size () -1;
@@ -76,10 +79,10 @@ pcl::GaussianKernel::convolveRows(const pcl::PointCloud<PointT> &input,
 }
 
 template <typename PointT> void
-pcl::GaussianKernel::convolveCols(const pcl::PointCloud<PointT> &input,
-                                  std::function <float (const PointT& p)> field_accessor,
-                                  const Eigen::VectorXf& kernel,
-                                  pcl::PointCloud<float> &output) const
+GaussianKernel::convolveCols(const pcl::PointCloud<PointT> &input,
+                             std::function <float (const PointT& p)> field_accessor,
+                             const Eigen::VectorXf& kernel,
+                             pcl::PointCloud<float> &output) const
 {
   assert(kernel.size () % 2 == 1);
   int kernel_width = kernel.size () -1;
@@ -110,4 +113,5 @@ pcl::GaussianKernel::convolveCols(const pcl::PointCloud<PointT> &input,
   }
 }
 
-#endif
+} // namespace pcl
+
index a2d4dd110056c2bcb914f72071408c669b3bc1ca..3337d49a754f831640eef8c468c4085ec7548193 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_GENERATE_HPP_
-#define PCL_COMMON_GENERATE_HPP_
+#pragma once
 
+#include <pcl/common/generate.h>
 #include <pcl/console/print.h>
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace common
+{
+
 template <typename PointT, typename GeneratorT>
-pcl::common::CloudGenerator<PointT, GeneratorT>::CloudGenerator ()
+CloudGenerator<PointT, GeneratorT>::CloudGenerator ()
   : x_generator_ ()
   , y_generator_ ()
   , z_generator_ ()
 {}
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT>
-pcl::common::CloudGenerator<PointT, GeneratorT>::CloudGenerator (const GeneratorParameters& params)
+CloudGenerator<PointT, GeneratorT>::CloudGenerator (const GeneratorParameters& params)
 {
   setParameters (params);
 }
 
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename GeneratorT>
-pcl::common::CloudGenerator<PointT, GeneratorT>::CloudGenerator (const GeneratorParameters& x_params,
-                                                                 const GeneratorParameters& y_params,
-                                                                 const GeneratorParameters& z_params)
+CloudGenerator<PointT, GeneratorT>::CloudGenerator (const GeneratorParameters& x_params,
+                                                    const GeneratorParameters& y_params,
+                                                    const GeneratorParameters& z_params)
   : x_generator_ (x_params)
   , y_generator_ (y_params)
   , z_generator_ (z_params)
 {}
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> void
-pcl::common::CloudGenerator<PointT, GeneratorT>::setParameters (const GeneratorParameters& params)
+CloudGenerator<PointT, GeneratorT>::setParameters (const GeneratorParameters& params)
 {
   GeneratorParameters y_params = params;
   y_params.seed += 1;
@@ -78,54 +83,54 @@ pcl::common::CloudGenerator<PointT, GeneratorT>::setParameters (const GeneratorP
   z_params.seed += 1;
   x_generator_.setParameters (params);
   y_generator_.setParameters (y_params);
-  z_generator_.setParameters (z_params);  
+  z_generator_.setParameters (z_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> void
-pcl::common::CloudGenerator<PointT, GeneratorT>::setParametersForX (const GeneratorParameters& x_params)
+CloudGenerator<PointT, GeneratorT>::setParametersForX (const GeneratorParameters& x_params)
 {
   x_generator_.setParameters (x_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> void
-pcl::common::CloudGenerator<PointT, GeneratorT>::setParametersForY (const GeneratorParameters& y_params)
+CloudGenerator<PointT, GeneratorT>::setParametersForY (const GeneratorParameters& y_params)
 {
   y_generator_.setParameters (y_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> void
-pcl::common::CloudGenerator<PointT, GeneratorT>::setParametersForZ (const GeneratorParameters& z_params)
+CloudGenerator<PointT, GeneratorT>::setParametersForZ (const GeneratorParameters& z_params)
 {
   z_generator_.setParameters (z_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT, typename GeneratorT> const typename pcl::common::CloudGenerator<PointT, GeneratorT>::GeneratorParameters& 
-pcl::common::CloudGenerator<PointT, GeneratorT>::getParametersForX () const
+
+template <typename PointT, typename GeneratorT> const typename CloudGenerator<PointT, GeneratorT>::GeneratorParameters& 
+CloudGenerator<PointT, GeneratorT>::getParametersForX () const
 {
   x_generator_.getParameters ();
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT, typename GeneratorT> const typename pcl::common::CloudGenerator<PointT, GeneratorT>::GeneratorParameters& 
-pcl::common::CloudGenerator<PointT, GeneratorT>::getParametersForY () const
+
+template <typename PointT, typename GeneratorT> const typename CloudGenerator<PointT, GeneratorT>::GeneratorParameters& 
+CloudGenerator<PointT, GeneratorT>::getParametersForY () const
 {
   y_generator_.getParameters ();
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT, typename GeneratorT> const typename pcl::common::CloudGenerator<PointT, GeneratorT>::GeneratorParameters& 
-pcl::common::CloudGenerator<PointT, GeneratorT>::getParametersForZ () const
+
+template <typename PointT, typename GeneratorT> const typename CloudGenerator<PointT, GeneratorT>::GeneratorParameters& 
+CloudGenerator<PointT, GeneratorT>::getParametersForZ () const
 {
   z_generator_.getParameters ();
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> PointT
-pcl::common::CloudGenerator<PointT, GeneratorT>::get ()
+CloudGenerator<PointT, GeneratorT>::get ()
 {
   PointT p;
   p.x = x_generator_.run ();
@@ -134,34 +139,34 @@ pcl::common::CloudGenerator<PointT, GeneratorT>::get ()
   return (p);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> int
-pcl::common::CloudGenerator<PointT, GeneratorT>::fill (pcl::PointCloud<PointT>& cloud)
+CloudGenerator<PointT, GeneratorT>::fill (pcl::PointCloud<PointT>& cloud)
 {
   return (fill (cloud.width, cloud.height, cloud));
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename GeneratorT> int
-pcl::common::CloudGenerator<PointT, GeneratorT>::fill (int width, int height, pcl::PointCloud<PointT>& cloud)
+CloudGenerator<PointT, GeneratorT>::fill (int width, int height, pcl::PointCloud<PointT>& cloud)
 {
   if (width < 1)
   {
     PCL_ERROR ("[pcl::common::CloudGenerator] Cloud width must be >= 1!\n");
     return (-1);
   }
-  
+
   if (height < 1)
   {
     PCL_ERROR ("[pcl::common::CloudGenerator] Cloud height must be >= 1!\n");
     return (-1);
   }
-  
+
   if (!cloud.empty ())
   {
     PCL_WARN ("[pcl::common::CloudGenerator] Cloud data will be erased with new data!\n");
   }
-  
+
   cloud.width = width;
   cloud.height = height;
   cloud.resize (cloud.width * cloud.height);
@@ -175,31 +180,31 @@ pcl::common::CloudGenerator<PointT, GeneratorT>::fill (int width, int height, pc
   return (0);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT>
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::CloudGenerator ()
+CloudGenerator<pcl::PointXY, GeneratorT>::CloudGenerator ()
   : x_generator_ ()
   , y_generator_ ()
 {}
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT>
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::CloudGenerator (const GeneratorParameters& x_params,
-                                                                       const GeneratorParameters& y_params)
+CloudGenerator<pcl::PointXY, GeneratorT>::CloudGenerator (const GeneratorParameters& x_params,
+                                                          const GeneratorParameters& y_params)
   : x_generator_ (x_params)
   , y_generator_ (y_params)
 {}
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT>
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::CloudGenerator (const GeneratorParameters& params)
+CloudGenerator<pcl::PointXY, GeneratorT>::CloudGenerator (const GeneratorParameters& params)
 {
   setParameters (params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT> void
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::setParameters (const GeneratorParameters& params)
+CloudGenerator<pcl::PointXY, GeneratorT>::setParameters (const GeneratorParameters& params)
 {
   x_generator_.setParameters (params);
   GeneratorParameters y_params = params;
@@ -207,37 +212,37 @@ pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::setParameters (const Gene
   y_generator_.setParameters (y_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT> void
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::setParametersForX (const GeneratorParameters& x_params)
+CloudGenerator<pcl::PointXY, GeneratorT>::setParametersForX (const GeneratorParameters& x_params)
 {
   x_generator_.setParameters (x_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT> void
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::setParametersForY (const GeneratorParameters& y_params)
+CloudGenerator<pcl::PointXY, GeneratorT>::setParametersForY (const GeneratorParameters& y_params)
 {
   y_generator_.setParameters (y_params);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename GeneratorT> const typename pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::GeneratorParameters& 
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::getParametersForX () const
+
+template <typename GeneratorT> const typename CloudGenerator<pcl::PointXY, GeneratorT>::GeneratorParameters&
+CloudGenerator<pcl::PointXY, GeneratorT>::getParametersForX () const
 {
   x_generator_.getParameters ();
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename GeneratorT> const typename pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::GeneratorParameters& 
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::getParametersForY () const
+
+template <typename GeneratorT> const typename CloudGenerator<pcl::PointXY, GeneratorT>::GeneratorParameters&
+CloudGenerator<pcl::PointXY, GeneratorT>::getParametersForY () const
 {
   y_generator_.getParameters ();
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT> pcl::PointXY
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::get ()
+CloudGenerator<pcl::PointXY, GeneratorT>::get ()
 {
   pcl::PointXY p;
   p.x = x_generator_.run ();
@@ -245,29 +250,29 @@ pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::get ()
   return (p);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT> int
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::fill (pcl::PointCloud<pcl::PointXY>& cloud)
+CloudGenerator<pcl::PointXY, GeneratorT>::fill (pcl::PointCloud<pcl::PointXY>& cloud)
 {
   return (fill (cloud.width, cloud.height, cloud));
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename GeneratorT> int
-pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::fill (int width, int height, pcl::PointCloud<pcl::PointXY>& cloud)
+CloudGenerator<pcl::PointXY, GeneratorT>::fill (int width, int height, pcl::PointCloud<pcl::PointXY>& cloud)
 {
   if (width < 1)
   {
     PCL_ERROR ("[pcl::common::CloudGenerator] Cloud width must be >= 1\n!");
     return (-1);
   }
-  
+
   if (height < 1)
   {
     PCL_ERROR ("[pcl::common::CloudGenerator] Cloud height must be >= 1\n!");
     return (-1);
   }
-  
+
   if (!cloud.empty ())
     PCL_WARN ("[pcl::common::CloudGenerator] Cloud data will be erased with new data\n!");
 
@@ -284,4 +289,6 @@ pcl::common::CloudGenerator<pcl::PointXY, GeneratorT>::fill (int width, int heig
   return (0);
 }
 
-#endif
+} // namespace common
+} // namespace pcl
+
index 92c33a5a4ded6e67f5ffe49a10ef2fdd8010be8c..526bcd94a17520059162a5dacc01e3d423ae2543 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_INTENSITY_FIELD_ACCESSOR_IMPL_HPP
-#define PCL_COMMON_INTENSITY_FIELD_ACCESSOR_IMPL_HPP
+#pragma once
 
+#include <pcl/common/intensity.h>
 #include <pcl/point_types.h>
+
+
 namespace pcl
 {
   namespace common
@@ -551,4 +553,3 @@ namespace pcl
   }
 }
 
-#endif
index cb73739e23e7905cd27569bd18023860d6c3fb3c..ba7686ed792db9df3b0dd90dbf1a219fb367863a 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_INTERSECTIONS_IMPL_HPP_
-#define PCL_COMMON_INTERSECTIONS_IMPL_HPP_
+#pragma once
 
+#include <pcl/common/intersections.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/console/print.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
 
 bool
-pcl::lineWithLineIntersection (const Eigen::VectorXf &line_a, 
-                               const Eigen::VectorXf &line_b, 
-                               Eigen::Vector4f &point, double sqr_eps)
+lineWithLineIntersection (const Eigen::VectorXf &line_a,
+                          const Eigen::VectorXf &line_b,
+                          Eigen::Vector4f &point, double sqr_eps)
 {
   Eigen::Vector4f p1, p2;
   lineToLineSegment (line_a, line_b, p1, p2);
@@ -62,21 +64,22 @@ pcl::lineWithLineIntersection (const Eigen::VectorXf &line_a,
   return (false);
 }
 
+
 bool
-pcl::lineWithLineIntersection (const pcl::ModelCoefficients &line_a, 
-                               const pcl::ModelCoefficients &line_b, 
-                               Eigen::Vector4f &point, double sqr_eps)
+lineWithLineIntersection (const pcl::ModelCoefficients &line_a,
+                          const pcl::ModelCoefficients &line_b,
+                          Eigen::Vector4f &point, double sqr_eps)
 {
   Eigen::VectorXf coeff1 = Eigen::VectorXf::Map (&line_a.values[0], line_a.values.size ());
   Eigen::VectorXf coeff2 = Eigen::VectorXf::Map (&line_b.values[0], line_b.values.size ());
   return (lineWithLineIntersection (coeff1, coeff2, point, sqr_eps));
 }
 
-template <typename Scalar> bool 
-pcl::planeWithPlaneIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a, 
-                                 const Eigen::Matrix<Scalar, 4, 1> &plane_b,
-                                 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line,
-                                 double angular_tolerance)
+template <typename Scalar> bool
+planeWithPlaneIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
+                            const Eigen::Matrix<Scalar, 4, 1> &plane_b,
+                            Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line,
+                            double angular_tolerance)
 {
   using Vector3 = Eigen::Matrix<Scalar, 3, 1>;
   using Vector4 = Eigen::Matrix<Scalar, 4, 1>;
@@ -104,7 +107,7 @@ pcl::planeWithPlaneIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
 
   // Construct system of equations using lagrange multipliers with one objective function and two constraints
   Matrix5 langrange_coefs;
-  langrange_coefs << 2,0,0, plane_a[0], plane_b[0],  
+  langrange_coefs << 2,0,0, plane_a[0], plane_b[0],
                      0,2,0, plane_a[1], plane_b[1],
                      0,0,2, plane_a[2], plane_b[2],
                      plane_a[0], plane_a[1], plane_a[2], 0, 0,
@@ -121,11 +124,11 @@ pcl::planeWithPlaneIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
 }
 
 template <typename Scalar> bool
-pcl::threePlanesIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a, 
-                              const Eigen::Matrix<Scalar, 4, 1> &plane_b,
-                              const Eigen::Matrix<Scalar, 4, 1> &plane_c,
-                              Eigen::Matrix<Scalar, 3, 1> &intersection_point,
-                              double determinant_tolerance)
+threePlanesIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
+                         const Eigen::Matrix<Scalar, 4, 1> &plane_b,
+                         const Eigen::Matrix<Scalar, 4, 1> &plane_c,
+                         Eigen::Matrix<Scalar, 3, 1> &intersection_point,
+                         double determinant_tolerance)
 {
   using Vector3 = Eigen::Matrix<Scalar, 3, 1>;
   using Matrix3 = Eigen::Matrix<Scalar, 3, 3>;
@@ -168,4 +171,5 @@ pcl::threePlanesIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
   return (true);
 }
 
-#endif  //PCL_COMMON_INTERSECTIONS_IMPL_HPP
+} // namespace pcl
+
index 9bb16c60e6fa1544f4a7272795f0ba8b265aed44..cda997005bb4679f151879708c82ada2c8f9244c 100644 (file)
  *
  */
 
-#ifndef PCL_IO_IMPL_IO_HPP_
-#define PCL_IO_IMPL_IO_HPP_
+#pragma once
 
 #include <pcl/common/concatenate.h>
 #include <pcl/common/copy_point.h>
+#include <pcl/common/io.h>
 #include <pcl/point_types.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointT> int
-pcl::getFieldIndex (const pcl::PointCloud<PointT> &, 
-                    const std::string &field_name, 
-                    std::vector<pcl::PCLPointField> &fields)
+getFieldIndex (const pcl::PointCloud<PointT> &,
+               const std::string &field_name,
+               std::vector<pcl::PCLPointField> &fields)
 {
   return getFieldIndex<PointT>(field_name, fields);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> int
-pcl::getFieldIndex (const std::string &field_name, 
-                    std::vector<pcl::PCLPointField> &fields)
+getFieldIndex (const std::string &field_name,
+               std::vector<pcl::PCLPointField> &fields)
 {
   fields = getFields<PointT> ();
   const auto& ref = fields;
   return pcl::getFieldIndex<PointT> (field_name, ref);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> int
-pcl::getFieldIndex (const std::string &field_name,
-                    const std::vector<pcl::PCLPointField> &fields)
+getFieldIndex (const std::string &field_name,
+               const std::vector<pcl::PCLPointField> &fields)
 {
   const auto result = std::find_if(fields.begin (), fields.end (),
       [&field_name](const auto& field) { return field.name == field_name; });
@@ -76,23 +79,23 @@ pcl::getFieldIndex (const std::string &field_name,
   return std::distance(fields.begin (), result);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::getFields (const pcl::PointCloud<PointT> &, std::vector<pcl::PCLPointField> &fields)
+getFields (const pcl::PointCloud<PointT> &, std::vector<pcl::PCLPointField> &fields)
 {
   fields = getFields<PointT> ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::getFields (std::vector<pcl::PCLPointField> &fields)
+getFields (std::vector<pcl::PCLPointField> &fields)
 {
   fields = getFields<PointT> ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> std::vector<pcl::PCLPointField>
-pcl::getFields ()
+getFields ()
 {
   std::vector<pcl::PCLPointField> fields;
   // Get the fields list
@@ -100,9 +103,9 @@ pcl::getFields ()
   return fields;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> std::string
-pcl::getFieldsList (const pcl::PointCloud<PointT> &)
+getFieldsList (const pcl::PointCloud<PointT> &)
 {
   // Get the fields list
   const auto fields = getFields<PointT>();
@@ -113,10 +116,10 @@ pcl::getFieldsList (const pcl::PointCloud<PointT> &)
   return (result);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> void
-pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
-                     pcl::PointCloud<PointOutT> &cloud_out)
+copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
+                pcl::PointCloud<PointOutT> &cloud_out)
 {
   // Allocate enough space and copy the basics
   cloud_out.header   = cloud_in.header;
@@ -139,11 +142,11 @@ pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
       copyPoint (cloud_in.points[i], cloud_out.points[i]);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename IndicesVectorAllocator> void
-pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
-                     const std::vector<int, IndicesVectorAllocator> &indices,
-                     pcl::PointCloud<PointT> &cloud_out)
+copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                const std::vector<int, IndicesVectorAllocator> &indices,
+                pcl::PointCloud<PointT> &cloud_out)
 {
   // Do we want to copy everything?
   if (indices.size () == cloud_in.points.size ())
@@ -166,11 +169,11 @@ pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
     cloud_out.points[i] = cloud_in.points[indices[i]];
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IndicesVectorAllocator> void
-pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
-                     const std::vector<int, IndicesVectorAllocator> &indices,
-                     pcl::PointCloud<PointOutT> &cloud_out)
+copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
+                const std::vector<int, IndicesVectorAllocator> &indices,
+                pcl::PointCloud<PointOutT> &cloud_out)
 {
   // Allocate enough space and copy the basics
   cloud_out.points.resize (indices.size ());
@@ -186,10 +189,10 @@ pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
     copyPoint (cloud_in.points[indices[i]], cloud_out.points[i]);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
-                     const pcl::PointIndices &indices,
+copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                const pcl::PointIndices &indices,
                      pcl::PointCloud<PointT> &cloud_out)
 {
   // Do we want to copy everything?
@@ -213,20 +216,20 @@ pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
     cloud_out.points[i] = cloud_in.points[indices.indices[i]];
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> void
-pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
-                     const pcl::PointIndices &indices,
-                     pcl::PointCloud<PointOutT> &cloud_out)
+copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
+                const pcl::PointIndices &indices,
+                pcl::PointCloud<PointOutT> &cloud_out)
 {
   copyPointCloud (cloud_in, indices.indices, cloud_out);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
-                     const std::vector<pcl::PointIndices> &indices,
-                     pcl::PointCloud<PointT> &cloud_out)
+copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                const std::vector<pcl::PointIndices> &indices,
+                pcl::PointCloud<PointT> &cloud_out)
 {
   int nr_p = 0;
   for (const auto &index : indices)
@@ -262,11 +265,11 @@ pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> void
-pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in, 
-                     const std::vector<pcl::PointIndices> &indices,
-                     pcl::PointCloud<PointOutT> &cloud_out)
+copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
+                const std::vector<pcl::PointIndices> &indices,
+                pcl::PointCloud<PointOutT> &cloud_out)
 {
   const auto nr_p = std::accumulate(indices.begin (), indices.end (), 0,
       [](const auto& acc, const auto& index) { return index.indices.size() + acc; });
@@ -300,11 +303,11 @@ pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointIn1T, typename PointIn2T, typename PointOutT> void
-pcl::concatenateFields (const pcl::PointCloud<PointIn1T> &cloud1_in,
-                        const pcl::PointCloud<PointIn2T> &cloud2_in,
-                        pcl::PointCloud<PointOutT> &cloud_out)
+concatenateFields (const pcl::PointCloud<PointIn1T> &cloud1_in,
+                   const pcl::PointCloud<PointIn2T> &cloud2_in,
+                   pcl::PointCloud<PointOutT> &cloud_out)
 {
   using FieldList1 = typename pcl::traits::fieldList<PointIn1T>::type;
   using FieldList2 = typename pcl::traits::fieldList<PointIn2T>::type;
@@ -334,10 +337,10 @@ pcl::concatenateFields (const pcl::PointCloud<PointIn1T> &cloud1_in,
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, pcl::PointCloud<PointT> &cloud_out,
-                     int top, int bottom, int left, int right, pcl::InterpolationType border_type, const PointT& value)
+copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, pcl::PointCloud<PointT> &cloud_out,
+                int top, int bottom, int left, int right, pcl::InterpolationType border_type, const PointT& value)
 {
   if (top < 0 || left < 0 || bottom < 0 || right < 0)
   {
@@ -420,7 +423,7 @@ pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, pcl::PointCloud<Po
                     cloud_out.width * sizeof (PointT));
           }
         }
-        catch (pcl::BadArgumentException &e)
+        catch (pcl::BadArgumentException&)
         {
           PCL_ERROR ("[pcl::copyPointCloud] Unhandled interpolation type %d!\n", border_type);
         }
@@ -460,5 +463,5 @@ pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, pcl::PointCloud<Po
   }
 }
 
-#endif // PCL_IO_IMPL_IO_H_
+} // namespace pcl
 
index 330c147317f255b7345af78c188bd5be1e75e284..9d69d6209f7bb1c9f086859b6ef27b6ea8c032ee 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_NORMS_IMPL_HPP_
-#define PCL_COMMON_NORMS_IMPL_HPP_
+#pragma once
 
-#include <pcl/pcl_macros.h>
+#include <pcl/common/norms.h>
 #include <pcl/console/print.h>
+#include <pcl/pcl_macros.h>
+
 
 namespace pcl
 {
@@ -237,6 +238,5 @@ HIK_Norm(FloatVectorT a, FloatVectorT b, int dim)
   return norm;
 }
 
-}
-#endif
+} // namespace pcl
 
index 89ff87e0b3dbe0df1fdda9add3f1f770f2de784c..98b6cb473585dddc8f656578685c1a11ccfedefb 100644 (file)
  * $Id$
  */
 
-#ifndef PCL_PCA_IMPL_HPP
-#define PCL_PCA_IMPL_HPP
+#pragma once
 
-#include <pcl/point_types.h>
 #include <pcl/common/centroid.h>
 #include <pcl/common/eigen.h>
+#include <pcl/common/pca.h>
 #include <pcl/common/transforms.h>
+#include <pcl/point_types.h>
 #include <pcl/exceptions.h>
 
-/////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template<typename PointT> bool
-pcl::PCA<PointT>::initCompute () 
+PCA<PointT>::initCompute ()
 {
   if(!Base::initCompute ())
   {
@@ -57,10 +60,10 @@ pcl::PCA<PointT>::initCompute ()
   {
     PCL_THROW_EXCEPTION (InitFailedException, "[pcl::PCA::initCompute] number of points < 3");
   }
-  
+
   // Compute mean
   mean_ = Eigen::Vector4f::Zero ();
-  compute3DCentroid (*input_, *indices_, mean_);  
+  compute3DCentroid (*input_, *indices_, mean_);
   // Compute demeanished cloud
   Eigen::MatrixXf cloud_demean;
   demeanPointCloud (*input_, *indices_, mean_, cloud_demean);
@@ -68,7 +71,7 @@ pcl::PCA<PointT>::initCompute ()
   // Compute the product cloud_demean * cloud_demean^T
   const Eigen::Matrix3f alpha = (1.f / (float (indices_->size ()) - 1.f))
                                   * cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose ();
-  
+
   // Compute eigen vectors and values
   Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> evd (alpha);
   // Organize eigenvectors and eigenvalues in ascendent order
@@ -77,7 +80,7 @@ pcl::PCA<PointT>::initCompute ()
     eigenvalues_[i] = evd.eigenvalues () [2-i];
     eigenvectors_.col (i) = evd.eigenvectors ().col (2-i);
   }
-  // Enforce right hand rule 
+  // Enforce right hand rule
   eigenvectors_.col(2) = eigenvectors_.col(0).cross(eigenvectors_.col(1));
   // If not basis only then compute the coefficients
   if (!basis_only_)
@@ -86,9 +89,9 @@ pcl::PCA<PointT>::initCompute ()
   return (true);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> inline void 
-pcl::PCA<PointT>::update (const PointT& input_point, FLAG flag) 
+
+template<typename PointT> inline void
+PCA<PointT>::update (const PointT& input_point, FLAG flag)
 {
   if (!compute_done_)
     initCompute ();
@@ -101,7 +104,7 @@ pcl::PCA<PointT>::update (const PointT& input_point, FLAG flag)
   Eigen::VectorXf a = eigenvectors_.transpose() * (input - mean_.head<3>());
   Eigen::VectorXf y = (eigenvectors_ * a) + mean_.head<3>();
   Eigen::VectorXf h = y - input;
-  if (h.norm() > 0) 
+  if (h.norm() > 0)
     h.normalize ();
   else
     h.setZero ();
@@ -140,7 +143,7 @@ pcl::PCA<PointT>::update (const PointT& input_point, FLAG flag)
     coefficients_.col(coefficients_.cols()-1) = (R.transpose() * a) + etha;
   }
   mean_.head<3>() = meanp;
-  switch (flag) 
+  switch (flag)
   {
     case increase:
       if (eigenvectors_.rows() >= eigenvectors_.cols())
@@ -156,22 +159,22 @@ pcl::PCA<PointT>::update (const PointT& input_point, FLAG flag)
   }
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline void
-pcl::PCA<PointT>::project (const PointT& input, PointT& projection)
+PCA<PointT>::project (const PointT& input, PointT& projection)
 {
   if(!compute_done_)
     initCompute ();
   if (!compute_done_)
     PCL_THROW_EXCEPTION (InitFailedException, "[pcl::PCA::project] PCA initCompute failed");
-  
+
   Eigen::Vector3f demean_input = input.getVector3fMap () - mean_.head<3> ();
   projection.getVector3fMap () = eigenvectors_.transpose() * demean_input;
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline void
-pcl::PCA<PointT>::project (const PointCloud& input, PointCloud& projection)
+PCA<PointT>::project (const PointCloud& input, PointCloud& projection)
 {
   if(!compute_done_)
     initCompute ();
@@ -198,9 +201,9 @@ pcl::PCA<PointT>::project (const PointCloud& input, PointCloud& projection)
   }
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline void
-pcl::PCA<PointT>::reconstruct (const PointT& projection, PointT& input)
+PCA<PointT>::reconstruct (const PointT& projection, PointT& input)
 {
   if(!compute_done_)
     initCompute ();
@@ -211,9 +214,9 @@ pcl::PCA<PointT>::reconstruct (const PointT& projection, PointT& input)
   input.getVector3fMap ()+= mean_.head<3> ();
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline void
-pcl::PCA<PointT>::reconstruct (const PointCloud& projection, PointCloud& input)
+PCA<PointT>::reconstruct (const PointCloud& projection, PointCloud& input)
 {
   if(!compute_done_)
     initCompute ();
@@ -230,7 +233,7 @@ pcl::PCA<PointT>::reconstruct (const PointCloud& projection, PointCloud& input)
     PointT p;
     for (std::size_t i = 0; i < input.size (); ++i)
     {
-      if (!std::isfinite (input[i].x) || 
+      if (!std::isfinite (input[i].x) ||
           !std::isfinite (input[i].y) ||
           !std::isfinite (input[i].z))
         continue;
@@ -240,4 +243,5 @@ pcl::PCA<PointT>::reconstruct (const PointCloud& projection, PointCloud& input)
   }
 }
 
-#endif
+} // namespace pcl
+
index 4557c7491d282679b3dfa205ad8766b3fbdec876..6e82d848f04601a5f57830da45fb3f0f72df849f 100644 (file)
 
 /* \author Bastian Steder */
 
+#pragma once
+
+#include <pcl/common/piecewise_linear_function.h>
+
 #include <algorithm>
 #include <cmath>
 // #include <iostream>
@@ -57,4 +61,4 @@ inline float PiecewiseLinearFunction::getValue(float point) const
   return data_points_[data_point_before]+interpolation_size*(data_points_[data_point_before+1]-data_points_[data_point_before]);
 }
 
-}  // end namespace pcl
+}  // namespace pcl
index 6bdf0ab356107106f2a818facf682eee191561f3..6b2f28881d50d4920cdf349ba4f79ec30f0af0a1 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  *
  */
-#ifndef PCL_POLYNOMIAL_CALCULATIONS_HPP_
-#define PCL_POLYNOMIAL_CALCULATIONS_HPP_
 
-////////////////////////////////////
+#pragma once
+
+#include <pcl/common/polynomial_calculations.h>
+
+
+namespace pcl
+{
 
 template <typename real>
 inline void
-  pcl::PolynomialCalculationsT<real>::Parameters::setZeroValue (real new_zero_value)
+PolynomialCalculationsT<real>::Parameters::setZeroValue (real new_zero_value)
 {
   zero_value = new_zero_value;
   sqr_zero_value = zero_value*zero_value;
 }
 
-////////////////////////////////////
 
 template <typename real>
 inline void
-  pcl::PolynomialCalculationsT<real>::solveLinearEquation (real a, real b, std::vector<real>& roots) const
+PolynomialCalculationsT<real>::solveLinearEquation (real a, real b, std::vector<real>& roots) const
 {
   //std::cout << "Trying to solve "<<a<<"x + "<<b<<" = 0\n";
 
@@ -81,11 +84,10 @@ inline void
 #endif
 }
 
-////////////////////////////////////
 
 template <typename real>
 inline void
-  pcl::PolynomialCalculationsT<real>::solveQuadraticEquation (real a, real b, real c, std::vector<real>& roots) const
+PolynomialCalculationsT<real>::solveQuadraticEquation (real a, real b, real c, std::vector<real>& roots) const
 {
   //std::cout << "Trying to solve "<<a<<"x^2 + "<<b<<"x + "<<c<<" = 0\n";
 
@@ -137,11 +139,10 @@ inline void
 #endif
 }
 
-////////////////////////////////////
 
 template<typename real>
 inline void
-  pcl::PolynomialCalculationsT<real>::solveCubicEquation (real a, real b, real c, real d, std::vector<real>& roots) const
+PolynomialCalculationsT<real>::solveCubicEquation (real a, real b, real c, real d, std::vector<real>& roots) const
 {
   //std::cout << "Trying to solve "<<a<<"x^3 + "<<b<<"x^2 + "<<c<<"x + "<<d<<" = 0\n";
 
@@ -239,12 +240,11 @@ inline void
 #endif
 }
 
-////////////////////////////////////
 
 template<typename real>
 inline void
-  pcl::PolynomialCalculationsT<real>::solveQuarticEquation (real a, real b, real c, real d, real e,
-                                                            std::vector<real>& roots) const
+PolynomialCalculationsT<real>::solveQuarticEquation (real a, real b, real c, real d, real e,
+                                                     std::vector<real>& roots) const
 {
   //std::cout << "Trying to solve "<<a<<"x^4 + "<<b<<"x^3 + "<<c<<"x^2 + "<<d<<"x + "<<e<<" = 0\n";
 
@@ -391,25 +391,23 @@ inline void
 #endif
 }
 
-////////////////////////////////////
 
 template<typename real>
 inline pcl::BivariatePolynomialT<real>
-  pcl::PolynomialCalculationsT<real>::bivariatePolynomialApproximation (
-      std::vector<Eigen::Matrix<real, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<real, 3, 1> > >& samplePoints, unsigned int polynomial_degree, bool& error) const
+PolynomialCalculationsT<real>::bivariatePolynomialApproximation (
+  std::vector<Eigen::Matrix<real, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<real, 3, 1> > >& samplePoints, unsigned int polynomial_degree, bool& error) const
 {
   pcl::BivariatePolynomialT<real> ret;
   error = bivariatePolynomialApproximation (samplePoints, polynomial_degree, ret);
   return ret;
 }
 
-////////////////////////////////////
 
 template<typename real>
 inline bool
-  pcl::PolynomialCalculationsT<real>::bivariatePolynomialApproximation (
-      std::vector<Eigen::Matrix<real, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<real, 3, 1> > >& samplePoints, unsigned int polynomial_degree,
-      pcl::BivariatePolynomialT<real>& ret) const
+PolynomialCalculationsT<real>::bivariatePolynomialApproximation (
+  std::vector<Eigen::Matrix<real, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<real, 3, 1> > >& samplePoints, unsigned int polynomial_degree,
+  pcl::BivariatePolynomialT<real>& ret) const
 {
   const auto parameters_size = BivariatePolynomialT<real>::getNoOfParametersFromDegree (polynomial_degree);
 
@@ -505,5 +503,5 @@ inline bool
   return true;
 }
 
-#endif      // PCL_POLYNOMIAL_CALCULATIONS_HPP_
+} // namespace pcl
 
index 71d1ef7ba8b5ae3fb6bc25a093171782d16c0438..06c891252c9eaa891e06ec57a47ffe41693dab0a 100644 (file)
  *
  */
 
-#ifndef __PCL_ORGANIZED_PROJECTION_MATRIX_HPP__
-#define __PCL_ORGANIZED_PROJECTION_MATRIX_HPP__
+#pragma once
 
+#include <pcl/common/projection_matrix.h>
 #include <pcl/cloud_iterator.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 namespace pcl
 {
-  namespace common
+
+namespace common
+{
+
+namespace internal
+{
+
+template <typename MatrixT> void
+makeSymmetric (MatrixT& matrix, bool use_upper_triangular = true)
+{
+  if (use_upper_triangular && (MatrixT::Flags & Eigen::RowMajorBit))
   {
-    namespace internal
-    {
-      template <typename MatrixT> void
-      makeSymmetric (MatrixT& matrix, bool use_upper_triangular = true)
-      {
-        if (use_upper_triangular && (MatrixT::Flags & Eigen::RowMajorBit))
-        {
-          matrix.coeffRef (4) = matrix.coeff (1);
-          matrix.coeffRef (8) = matrix.coeff (2);
-          matrix.coeffRef (9) = matrix.coeff (6);
-          matrix.coeffRef (12) = matrix.coeff (3);
-          matrix.coeffRef (13) = matrix.coeff (7);
-          matrix.coeffRef (14) = matrix.coeff (11);
-        }
-        else
-        {
-          matrix.coeffRef (1) = matrix.coeff (4);
-          matrix.coeffRef (2) = matrix.coeff (8);
-          matrix.coeffRef (6) = matrix.coeff (9);
-          matrix.coeffRef (3) = matrix.coeff (12);
-          matrix.coeffRef (7) = matrix.coeff (13);
-          matrix.coeffRef (11) = matrix.coeff (14);
-        }
-      }
-    }
+    matrix.coeffRef (4) = matrix.coeff (1);
+    matrix.coeffRef (8) = matrix.coeff (2);
+    matrix.coeffRef (9) = matrix.coeff (6);
+    matrix.coeffRef (12) = matrix.coeff (3);
+    matrix.coeffRef (13) = matrix.coeff (7);
+    matrix.coeffRef (14) = matrix.coeff (11);
+  }
+  else
+  {
+    matrix.coeffRef (1) = matrix.coeff (4);
+    matrix.coeffRef (2) = matrix.coeff (8);
+    matrix.coeffRef (6) = matrix.coeff (9);
+    matrix.coeffRef (3) = matrix.coeff (12);
+    matrix.coeffRef (7) = matrix.coeff (13);
+    matrix.coeffRef (11) = matrix.coeff (14);
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////
-template <typename PointT> double 
-pcl::estimateProjectionMatrix (
-    typename pcl::PointCloud<PointT>::ConstPtr cloud, 
-    Eigen::Matrix<float, 3, 4, Eigen::RowMajor>& projection_matrix, 
+} // namespace internal
+} // namespace common
+
+
+template <typename PointT> double
+estimateProjectionMatrix (
+    typename pcl::PointCloud<PointT>::ConstPtr cloud,
+    Eigen::Matrix<float, 3, 4, Eigen::RowMajor>& projection_matrix,
     const std::vector<int>& indices)
 {
   // internally we calculate with double but store the result into float matrices.
@@ -88,19 +91,19 @@ pcl::estimateProjectionMatrix (
     PCL_ERROR ("[pcl::estimateProjectionMatrix] Input dataset is not organized!\n");
     return (-1.0);
   }
-  
+
   Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor> A = Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor>::Zero ();
   Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor> B = Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor>::Zero ();
   Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor> C = Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor>::Zero ();
   Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor> D = Eigen::Matrix<Scalar, 4, 4, Eigen::RowMajor>::Zero ();
 
   pcl::ConstCloudIterator <PointT> pointIt (*cloud, indices);
-  
+
   while (pointIt)
   {
     unsigned yIdx = pointIt.getCurrentPointIndex () / cloud->width;
     unsigned xIdx = pointIt.getCurrentPointIndex () % cloud->width;
-    
+
     const PointT& point = *pointIt;
     if (std::isfinite (point.x))
     {
@@ -167,14 +170,14 @@ pcl::estimateProjectionMatrix (
 
       D.coeffRef (15) += xx_yy;
     }
-    
+
     ++pointIt;
-  } // while  
-  
-  pcl::common::internal::makeSymmetric (A);
-  pcl::common::internal::makeSymmetric (B);
-  pcl::common::internal::makeSymmetric (C);
-  pcl::common::internal::makeSymmetric (D);
+  } // while
+
+  common::internal::makeSymmetric (A);
+  common::internal::makeSymmetric (B);
+  common::internal::makeSymmetric (C);
+  common::internal::makeSymmetric (D);
 
   Eigen::Matrix<Scalar, 12, 12, Eigen::RowMajor> X = Eigen::Matrix<Scalar, 12, 12, Eigen::RowMajor>::Zero ();
   X.topLeftCorner<4,4> ().matrix () = A;
@@ -190,7 +193,7 @@ pcl::estimateProjectionMatrix (
 
   // check whether the residual MSE is low. If its high, the cloud was not captured from a projective device.
   Eigen::Matrix<Scalar, 1, 1> residual_sqr = eigen_vectors.col (0).transpose () * X *  eigen_vectors.col (0);
-  
+
   double residual = residual_sqr.coeff (0);
 
   projection_matrix.coeffRef (0) = static_cast <float> (eigen_vectors.coeff (0));
@@ -212,4 +215,5 @@ pcl::estimateProjectionMatrix (
   return (residual);
 }
 
-#endif
+} // namespace pcl
+
index 3babfc27f1bbea9779b1318d7d67bdbbfc58f627..a53d5226cb938fe987bc9e711d2a487c398bc1f9 100644 (file)
  *
  */
 
-#ifndef PCL_COMMON_RANDOM_HPP_
-#define PCL_COMMON_RANDOM_HPP_
+#pragma once
+
+#include <pcl/common/random.h>
+
+
+namespace pcl
+{
+
+namespace common
+{
+
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename T>
-pcl::common::UniformGenerator<T>::UniformGenerator(T min, T max, std::uint32_t seed)
+UniformGenerator<T>::UniformGenerator(T min, T max, std::uint32_t seed)
   : distribution_ (min, max)
 {
   parameters_ = Parameters (min, max, seed);
@@ -51,9 +59,8 @@ pcl::common::UniformGenerator<T>::UniformGenerator(T min, T max, std::uint32_t s
 }
 
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename T>
-pcl::common::UniformGenerator<T>::UniformGenerator(const Parameters& parameters)
+UniformGenerator<T>::UniformGenerator(const Parameters& parameters)
   : parameters_ (parameters)
   , distribution_ (parameters_.min, parameters_.max)
 {
@@ -61,9 +68,9 @@ pcl::common::UniformGenerator<T>::UniformGenerator(const Parameters& parameters)
     rng_.seed (parameters_.seed);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T> void
-pcl::common::UniformGenerator<T>::setSeed (std::uint32_t seed)
+UniformGenerator<T>::setSeed (std::uint32_t seed)
 {
   if (seed != static_cast<std::uint32_t> (-1))
   {
@@ -72,9 +79,9 @@ pcl::common::UniformGenerator<T>::setSeed (std::uint32_t seed)
   }
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T> void
-pcl::common::UniformGenerator<T>::setParameters (T min, T max, std::uint32_t seed)
+UniformGenerator<T>::setParameters (T min, T max, std::uint32_t seed)
 {
   parameters_.min = min;
   parameters_.max = max;
@@ -89,9 +96,9 @@ pcl::common::UniformGenerator<T>::setParameters (T min, T max, std::uint32_t see
   }
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T> void
-pcl::common::UniformGenerator<T>::setParameters (const Parameters& parameters)
+UniformGenerator<T>::setParameters (const Parameters& parameters)
 {
   parameters_ = parameters;
   typename DistributionType::param_type params (parameters_.min, parameters_.max);
@@ -101,9 +108,9 @@ pcl::common::UniformGenerator<T>::setParameters (const Parameters& parameters)
     rng_.seed (parameters_.seed);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T>
-pcl::common::NormalGenerator<T>::NormalGenerator(T mean, T sigma, std::uint32_t seed)
+NormalGenerator<T>::NormalGenerator(T mean, T sigma, std::uint32_t seed)
   : distribution_ (mean, sigma)
 {
   parameters_ = Parameters (mean, sigma, seed);
@@ -112,9 +119,8 @@ pcl::common::NormalGenerator<T>::NormalGenerator(T mean, T sigma, std::uint32_t
 }
 
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename T>
-pcl::common::NormalGenerator<T>::NormalGenerator(const Parameters& parameters)
+NormalGenerator<T>::NormalGenerator(const Parameters& parameters)
   : parameters_ (parameters)
   , distribution_ (parameters_.mean, parameters_.sigma)
 {
@@ -122,9 +128,9 @@ pcl::common::NormalGenerator<T>::NormalGenerator(const Parameters& parameters)
     rng_.seed (parameters_.seed);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T> void
-pcl::common::NormalGenerator<T>::setSeed (std::uint32_t seed)
+NormalGenerator<T>::setSeed (std::uint32_t seed)
 {
   if (seed != static_cast<std::uint32_t> (-1))
   {
@@ -133,9 +139,9 @@ pcl::common::NormalGenerator<T>::setSeed (std::uint32_t seed)
   }
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T> void
-pcl::common::NormalGenerator<T>::setParameters (T mean, T sigma, std::uint32_t seed)
+NormalGenerator<T>::setParameters (T mean, T sigma, std::uint32_t seed)
 {
   parameters_.mean = mean;
   parameters_.sigma = sigma;
@@ -147,9 +153,9 @@ pcl::common::NormalGenerator<T>::setParameters (T mean, T sigma, std::uint32_t s
     rng_.seed (parameters_.seed);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename T> void
-pcl::common::NormalGenerator<T>::setParameters (const Parameters& parameters)
+NormalGenerator<T>::setParameters (const Parameters& parameters)
 {
   parameters_ = parameters;
   typename DistributionType::param_type params (parameters_.mean, parameters_.sigma);
@@ -159,4 +165,6 @@ pcl::common::NormalGenerator<T>::setParameters (const Parameters& parameters)
     rng_.seed (parameters_.seed);
 }
 
-#endif
+} // namespace common
+} // namespace pcl
+
index c8a549fa1ebdb61922edd4de8176a0fd385fe97e..b27f20c1c9d76b5b7cb2cd2520369bd92984219c 100644 (file)
  *
  */
 
-#ifndef PCL_POINT_CLOUD_SPRING_IMPL_HPP_
-#define PCL_POINT_CLOUD_SPRING_IMPL_HPP_
+#pragma once
 
-template <typename PointT> void 
-pcl::common::expandColumns (const PointCloud<PointT>& input, PointCloud<PointT>& output, 
-                            const PointT& val, const std::size_t& amount)
+#include <pcl/common/spring.h>
+
+
+namespace pcl
+{
+
+namespace common
+{
+
+template <typename PointT> void
+expandColumns (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+               const PointT& val, const std::size_t& amount)
 {
   if (amount <= 0)
     PCL_THROW_EXCEPTION (InitFailedException,
@@ -51,7 +59,7 @@ pcl::common::expandColumns (const PointCloud<PointT>& input, PointCloud<PointT>&
 
   if (!input.isOrganized () || amount > (input.width/2))
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::expandColumns] error: " 
+                         "[pcl::common::expandColumns] error: "
                          << "columns expansion requires organised point cloud");
 
   std::uint32_t old_height = input.height;
@@ -72,9 +80,9 @@ pcl::common::expandColumns (const PointCloud<PointT>& input, PointCloud<PointT>&
   output.height = old_height;
 }
 
-template <typename PointT> void 
-pcl::common::expandRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                         const PointT& val, const std::size_t& amount)
+template <typename PointT> void
+expandRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+            const PointT& val, const std::size_t& amount)
 {
   if (amount <= 0)
     PCL_THROW_EXCEPTION (InitFailedException,
@@ -93,9 +101,9 @@ pcl::common::expandRows (const PointCloud<PointT>& input, PointCloud<PointT>& ou
   output.height = new_height;
 }
 
-template <typename PointT> void 
-pcl::common::duplicateColumns (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                               const std::size_t& amount)
+template <typename PointT> void
+duplicateColumns (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+                  const std::size_t& amount)
 {
   if (amount <= 0)
     PCL_THROW_EXCEPTION (InitFailedException,
@@ -104,7 +112,7 @@ pcl::common::duplicateColumns (const PointCloud<PointT>& input, PointCloud<Point
 
   if (!input.isOrganized () || amount > (input.width/2))
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::duplicateColumns] error: " 
+                         "[pcl::common::duplicateColumns] error: "
                          << "columns expansion requires organised point cloud");
 
   std::size_t old_height = input.height;
@@ -126,13 +134,13 @@ pcl::common::duplicateColumns (const PointCloud<PointT>& input, PointCloud<Point
   output.height = old_height;
 }
 
-template <typename PointT> void 
-pcl::common::duplicateRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                            const std::size_t& amount)
+template <typename PointT> void
+duplicateRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+               const std::size_t& amount)
 {
   if (amount <= 0 || amount > (input.height/2))
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::duplicateRows] error: amount must be ]0.." 
+                         "[pcl::common::duplicateRows] error: amount must be ]0.."
                          << (input.height/2) << "] !");
 
   std::uint32_t old_height = input.height;
@@ -151,9 +159,9 @@ pcl::common::duplicateRows (const PointCloud<PointT>& input, PointCloud<PointT>&
   output.height = new_height;
 }
 
-template <typename PointT> void 
-pcl::common::mirrorColumns (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                                  const std::size_t& amount)
+template <typename PointT> void
+mirrorColumns (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+               const std::size_t& amount)
 {
   if (amount <= 0)
     PCL_THROW_EXCEPTION (InitFailedException,
@@ -162,7 +170,7 @@ pcl::common::mirrorColumns (const PointCloud<PointT>& input, PointCloud<PointT>&
 
   if (!input.isOrganized () || amount > (input.width/2))
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::mirrorColumns] error: " 
+                         "[pcl::common::mirrorColumns] error: "
                          << "columns expansion requires organised point cloud");
 
   std::size_t old_height = input.height;
@@ -183,13 +191,13 @@ pcl::common::mirrorColumns (const PointCloud<PointT>& input, PointCloud<PointT>&
   output.height = old_height;
 }
 
-template <typename PointT> void 
-pcl::common::mirrorRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                         const std::size_t& amount)
+template <typename PointT> void
+mirrorRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+            const std::size_t& amount)
 {
   if (amount <= 0 || amount > (input.height/2))
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::mirrorRows] error: amount must be ]0.." 
+                         "[pcl::common::mirrorRows] error: amount must be ]0.."
                          << (input.height/2) << "] !");
 
   std::uint32_t old_height = input.height;
@@ -210,13 +218,13 @@ pcl::common::mirrorRows (const PointCloud<PointT>& input, PointCloud<PointT>& ou
   output.height = new_height;
 }
 
-template <typename PointT> void 
-pcl::common::deleteRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                         const std::size_t& amount)
+template <typename PointT> void
+deleteRows (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+            const std::size_t& amount)
 {
   if (amount <= 0 || amount > (input.height/2))
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::deleteRows] error: amount must be ]0.." 
+                         "[pcl::common::deleteRows] error: amount must be ]0.."
                          << (input.height/2) << "] !");
 
   std::uint32_t old_height = input.height;
@@ -227,9 +235,9 @@ pcl::common::deleteRows (const PointCloud<PointT>& input, PointCloud<PointT>& ou
   output.width = old_width;
 }
 
-template <typename PointT> void 
-pcl::common::deleteCols (const PointCloud<PointT>& input, PointCloud<PointT>& output,
-                         const std::size_t& amount)
+template <typename PointT> void
+deleteCols (const PointCloud<PointT>& input, PointCloud<PointT>& output,
+            const std::size_t& amount)
 {
   if (amount <= 0 || amount > (input.width/2))
     PCL_THROW_EXCEPTION (InitFailedException,
@@ -238,7 +246,7 @@ pcl::common::deleteCols (const PointCloud<PointT>& input, PointCloud<PointT>& ou
 
   if (!input.isOrganized ())
     PCL_THROW_EXCEPTION (InitFailedException,
-                         "[pcl::common::deleteCols] error: " 
+                         "[pcl::common::deleteCols] error: "
                          << "columns delete requires organised point cloud");
 
   std::uint32_t old_height = input.height;
@@ -249,10 +257,12 @@ pcl::common::deleteCols (const PointCloud<PointT>& input, PointCloud<PointT>& ou
     typename PointCloud<PointT>::iterator start = output.begin () + j * new_width;
     output.erase (start, start + amount);
     start = output.begin () + (j+1) * new_width;
-    output.erase (start, start + amount);    
+    output.erase (start, start + amount);
   }
   output.height = old_height;
   output.width = new_width;
 }
 
-#endif
+} // namespace common
+} // namespace pcl
+
index 4067a5bd6a84332fb34de57a34c690385980d7a0..71849fff856de5e9d8ff306566021531fdc74a1c 100644 (file)
  *
  */
 
+#pragma once
+
 #include <pcl/common/eigen.h>
+#include <pcl/common/transformation_from_correspondences.h>
+
+
+namespace pcl
+{
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 inline void
-pcl::TransformationFromCorrespondences::reset ()
+TransformationFromCorrespondences::reset ()
 {
   no_of_samples_ = 0;
   accumulated_weight_ = 0.0;
@@ -48,28 +54,28 @@ pcl::TransformationFromCorrespondences::reset ()
   covariance_.fill(0);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 inline void
-pcl::TransformationFromCorrespondences::add (const Eigen::Vector3f& point, const Eigen::Vector3f& corresponding_point,
-                                             float weight)
+TransformationFromCorrespondences::add (const Eigen::Vector3f& point, const Eigen::Vector3f& corresponding_point,
+                                        float weight)
 {
   if (weight==0.0f)
     return;
-  
+
   ++no_of_samples_;
   accumulated_weight_ += weight;
   float alpha = weight/accumulated_weight_;
-  
+
   Eigen::Vector3f diff1 = point - mean1_, diff2 = corresponding_point - mean2_;
   covariance_ = (1.0f-alpha)*(covariance_ + alpha * (diff2 * diff1.transpose()));
-  
+
   mean1_ += alpha*(diff1);
   mean2_ += alpha*(diff2);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 inline Eigen::Affine3f
-pcl::TransformationFromCorrespondences::getTransformation ()
+TransformationFromCorrespondences::getTransformation ()
 {
   //Eigen::JacobiSVD<Eigen::Matrix<float, 3, 3> > svd (covariance_, Eigen::ComputeFullU | Eigen::ComputeFullV);
   Eigen::JacobiSVD<Eigen::Matrix<float, 3, 3> > svd (covariance_, Eigen::ComputeFullU | Eigen::ComputeFullV);
@@ -79,15 +85,18 @@ pcl::TransformationFromCorrespondences::getTransformation ()
   s.setIdentity();
   if (u.determinant()*v.determinant() < 0.0f)
     s(2,2) = -1.0f;
-  
+
   Eigen::Matrix<float, 3, 3> r = u * s * v.transpose();
   Eigen::Vector3f t = mean2_ - r*mean1_;
-  
+
   Eigen::Affine3f ret;
   ret(0,0)=r(0,0); ret(0,1)=r(0,1); ret(0,2)=r(0,2); ret(0,3)=t(0);
   ret(1,0)=r(1,0); ret(1,1)=r(1,1); ret(1,2)=r(1,2); ret(1,3)=t(1);
   ret(2,0)=r(2,0); ret(2,1)=r(2,1); ret(2,2)=r(2,2); ret(2,3)=t(2);
   ret(3,0)=0.0f;   ret(3,1)=0.0f;   ret(3,2)=0.0f;   ret(3,3)=1.0f;
-  
+
   return (ret);
 }
+
+} // namespace pcl
+
index eff1bdd9a28af1b8203e9224cf4a959933b066e7..a643309e9bcc5573096bd9a788cfa2b72f905196 100644 (file)
  *
  */
 
+#pragma once
+
+#include <pcl/common/transforms.h>
+
 #if defined(__SSE2__)
 #include <xmmintrin.h>
 #endif
 #include <cstddef>
 #include <vector>
 
+
 namespace pcl
 {
 
-  namespace detail
+namespace detail
+{
+
+/** A helper struct to apply an SO3 or SE3 transform to a 3D point.
+  * Supports single and double precision transform matrices. */
+template<typename Scalar>
+struct Transformer
+{
+  const Eigen::Matrix<Scalar, 4, 4>& tf;
+
+  /** Construct a transformer object.
+    * The transform matrix is captured by const reference. Make sure that it does not go out of scope before this
+    * object does. */
+  Transformer (const Eigen::Matrix<Scalar, 4, 4>& transform) : tf (transform) { };
+
+  /** Apply SO3 transform (top-left corner of the transform matrix).
+    * \param[in] src input 3D point (pointer to 3 floats)
+    * \param[out] tgt output 3D point (pointer to 4 floats), can be the same as input. The fourth element is set to 0. */
+  void so3 (const float* src, float* tgt) const
   {
+    const Scalar p[3] = { src[0], src[1], src[2] };  // need this when src == tgt
+    tgt[0] = static_cast<float> (tf (0, 0) * p[0] + tf (0, 1) * p[1] + tf (0, 2) * p[2]);
+    tgt[1] = static_cast<float> (tf (1, 0) * p[0] + tf (1, 1) * p[1] + tf (1, 2) * p[2]);
+    tgt[2] = static_cast<float> (tf (2, 0) * p[0] + tf (2, 1) * p[1] + tf (2, 2) * p[2]);
+    tgt[3] = 0;
+  }
 
-    /** A helper struct to apply an SO3 or SE3 transform to a 3D point.
-      * Supports single and double precision transform matrices. */
-    template<typename Scalar>
-    struct Transformer
-    {
-      const Eigen::Matrix<Scalar, 4, 4>& tf;
-
-      /** Construct a transformer object.
-        * The transform matrix is captured by const reference. Make sure that it does not go out of scope before this
-        * object does. */
-      Transformer (const Eigen::Matrix<Scalar, 4, 4>& transform) : tf (transform) { };
-
-      /** Apply SO3 transform (top-left corner of the transform matrix).
-        * \param[in] src input 3D point (pointer to 3 floats)
-        * \param[out] tgt output 3D point (pointer to 4 floats), can be the same as input. The fourth element is set to 0. */
-      void so3 (const float* src, float* tgt) const
-      {
-        const Scalar p[3] = { src[0], src[1], src[2] };  // need this when src == tgt
-        tgt[0] = static_cast<float> (tf (0, 0) * p[0] + tf (0, 1) * p[1] + tf (0, 2) * p[2]);
-        tgt[1] = static_cast<float> (tf (1, 0) * p[0] + tf (1, 1) * p[1] + tf (1, 2) * p[2]);
-        tgt[2] = static_cast<float> (tf (2, 0) * p[0] + tf (2, 1) * p[1] + tf (2, 2) * p[2]);
-        tgt[3] = 0;
-      }
-
-      /** Apply SE3 transform.
-        * \param[in] src input 3D point (pointer to 3 floats)
-        * \param[out] tgt output 3D point (pointer to 4 floats), can be the same as input. The fourth element is set to 1. */
-      void se3 (const float* src, float* tgt) const
-      {
-        const Scalar p[3] = { src[0], src[1], src[2] };  // need this when src == tgt
-        tgt[0] = static_cast<float> (tf (0, 0) * p[0] + tf (0, 1) * p[1] + tf (0, 2) * p[2] + tf (0, 3));
-        tgt[1] = static_cast<float> (tf (1, 0) * p[0] + tf (1, 1) * p[1] + tf (1, 2) * p[2] + tf (1, 3));
-        tgt[2] = static_cast<float> (tf (2, 0) * p[0] + tf (2, 1) * p[1] + tf (2, 2) * p[2] + tf (2, 3));
-        tgt[3] = 1;
-      }
-    };
+  /** Apply SE3 transform.
+    * \param[in] src input 3D point (pointer to 3 floats)
+    * \param[out] tgt output 3D point (pointer to 4 floats), can be the same as input. The fourth element is set to 1. */
+  void se3 (const float* src, float* tgt) const
+  {
+    const Scalar p[3] = { src[0], src[1], src[2] };  // need this when src == tgt
+    tgt[0] = static_cast<float> (tf (0, 0) * p[0] + tf (0, 1) * p[1] + tf (0, 2) * p[2] + tf (0, 3));
+    tgt[1] = static_cast<float> (tf (1, 0) * p[0] + tf (1, 1) * p[1] + tf (1, 2) * p[2] + tf (1, 3));
+    tgt[2] = static_cast<float> (tf (2, 0) * p[0] + tf (2, 1) * p[1] + tf (2, 2) * p[2] + tf (2, 3));
+    tgt[3] = 1;
+  }
+};
 
 #if defined(__SSE2__)
 
-    /** Optimized version for single-precision transforms using SSE2 intrinsics. */
-    template<>
-    struct Transformer<float>
-    {
-      /// Columns of the transform matrix stored in XMM registers.
-      __m128 c[4];
-
-      Transformer(const Eigen::Matrix4f& tf)
-      {
-        for (std::size_t i = 0; i < 4; ++i)
-          c[i] = _mm_load_ps (tf.col (i).data ());
-      }
-
-      void so3 (const float* src, float* tgt) const
-      {
-        __m128 p0 = _mm_mul_ps (_mm_load_ps1 (&src[0]), c[0]);
-        __m128 p1 = _mm_mul_ps (_mm_load_ps1 (&src[1]), c[1]);
-        __m128 p2 = _mm_mul_ps (_mm_load_ps1 (&src[2]), c[2]);
-        _mm_store_ps (tgt, _mm_add_ps(p0, _mm_add_ps(p1, p2)));
-      }
-
-      void se3 (const float* src, float* tgt) const
-      {
-        __m128 p0 = _mm_mul_ps (_mm_load_ps1 (&src[0]), c[0]);
-        __m128 p1 = _mm_mul_ps (_mm_load_ps1 (&src[1]), c[1]);
-        __m128 p2 = _mm_mul_ps (_mm_load_ps1 (&src[2]), c[2]);
-        _mm_store_ps (tgt, _mm_add_ps(p0, _mm_add_ps(p1, _mm_add_ps(p2, c[3]))));
-      }
-    };
-
-#if !defined(__AVX__)
+/** Optimized version for single-precision transforms using SSE2 intrinsics. */
+template<>
+struct Transformer<float>
+{
+  /// Columns of the transform matrix stored in XMM registers.
+  __m128 c[4];
 
-    /** Optimized version for double-precision transform using SSE2 intrinsics. */
-    template<>
-    struct Transformer<double>
-    {
-      /// Columns of the transform matrix stored in XMM registers.
-      __m128d c[4][2];
-
-      Transformer(const Eigen::Matrix4d& tf)
-      {
-        for (std::size_t i = 0; i < 4; ++i)
-        {
-          c[i][0] = _mm_load_pd (tf.col (i).data () + 0);
-          c[i][1] = _mm_load_pd (tf.col (i).data () + 2);
-        }
-      }
-
-      void so3 (const float* src, float* tgt) const
-      {
-        __m128d xx = _mm_cvtps_pd (_mm_load_ps1 (&src[0]));
-        __m128d p0 = _mm_mul_pd (xx, c[0][0]);
-        __m128d p1 = _mm_mul_pd (xx, c[0][1]);
-
-        for (std::size_t i = 1; i < 3; ++i)
-        {
-          __m128d vv = _mm_cvtps_pd (_mm_load_ps1 (&src[i]));
-          p0 = _mm_add_pd (_mm_mul_pd (vv, c[i][0]), p0);
-          p1 = _mm_add_pd (_mm_mul_pd (vv, c[i][1]), p1);
-        }
-
-        _mm_store_ps (tgt, _mm_movelh_ps (_mm_cvtpd_ps (p0), _mm_cvtpd_ps (p1)));
-      }
-
-      void se3 (const float* src, float* tgt) const
-      {
-        __m128d p0 = c[3][0];
-        __m128d p1 = c[3][1];
-
-        for (std::size_t i = 0; i < 3; ++i)
-        {
-          __m128d vv = _mm_cvtps_pd (_mm_load_ps1 (&src[i]));
-          p0 = _mm_add_pd (_mm_mul_pd (vv, c[i][0]), p0);
-          p1 = _mm_add_pd (_mm_mul_pd (vv, c[i][1]), p1);
-        }
-
-        _mm_store_ps (tgt, _mm_movelh_ps (_mm_cvtpd_ps (p0), _mm_cvtpd_ps (p1)));
-      }
-
-    };
+  Transformer(const Eigen::Matrix4f& tf)
+  {
+    for (std::size_t i = 0; i < 4; ++i)
+      c[i] = _mm_load_ps (tf.col (i).data ());
+  }
 
-#else
+  void so3 (const float* src, float* tgt) const
+  {
+    __m128 p0 = _mm_mul_ps (_mm_load_ps1 (&src[0]), c[0]);
+    __m128 p1 = _mm_mul_ps (_mm_load_ps1 (&src[1]), c[1]);
+    __m128 p2 = _mm_mul_ps (_mm_load_ps1 (&src[2]), c[2]);
+    _mm_store_ps (tgt, _mm_add_ps(p0, _mm_add_ps(p1, p2)));
+  }
 
-  /** Optimized version for double-precision transform using AVX intrinsics. */
-  template<>
-  struct Transformer<double>
+  void se3 (const float* src, float* tgt) const
   {
-    __m256d c[4];
+    __m128 p0 = _mm_mul_ps (_mm_load_ps1 (&src[0]), c[0]);
+    __m128 p1 = _mm_mul_ps (_mm_load_ps1 (&src[1]), c[1]);
+    __m128 p2 = _mm_mul_ps (_mm_load_ps1 (&src[2]), c[2]);
+    _mm_store_ps (tgt, _mm_add_ps(p0, _mm_add_ps(p1, _mm_add_ps(p2, c[3]))));
+  }
+};
 
-    Transformer(const Eigen::Matrix4d& tf)
+#if !defined(__AVX__)
+
+/** Optimized version for double-precision transform using SSE2 intrinsics. */
+template<>
+struct Transformer<double>
+{
+  /// Columns of the transform matrix stored in XMM registers.
+  __m128d c[4][2];
+
+  Transformer(const Eigen::Matrix4d& tf)
+  {
+    for (std::size_t i = 0; i < 4; ++i)
     {
-      for (std::size_t i = 0; i < 4; ++i)
-        c[i] = _mm256_load_pd (tf.col (i).data ());
+      c[i][0] = _mm_load_pd (tf.col (i).data () + 0);
+      c[i][1] = _mm_load_pd (tf.col (i).data () + 2);
     }
+  }
+
+  void so3 (const float* src, float* tgt) const
+  {
+    __m128d xx = _mm_cvtps_pd (_mm_load_ps1 (&src[0]));
+    __m128d p0 = _mm_mul_pd (xx, c[0][0]);
+    __m128d p1 = _mm_mul_pd (xx, c[0][1]);
 
-    void so3 (const float* src, float* tgt) const
+    for (std::size_t i = 1; i < 3; ++i)
     {
-      __m256d p0 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[0])), c[0]);
-      __m256d p1 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[1])), c[1]);
-      __m256d p2 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[2])), c[2]);
-      _mm_store_ps (tgt, _mm256_cvtpd_ps (_mm256_add_pd(p0, _mm256_add_pd(p1, p2))));
+      __m128d vv = _mm_cvtps_pd (_mm_load_ps1 (&src[i]));
+      p0 = _mm_add_pd (_mm_mul_pd (vv, c[i][0]), p0);
+      p1 = _mm_add_pd (_mm_mul_pd (vv, c[i][1]), p1);
     }
 
-    void se3 (const float* src, float* tgt) const
+    _mm_store_ps (tgt, _mm_movelh_ps (_mm_cvtpd_ps (p0), _mm_cvtpd_ps (p1)));
+  }
+
+  void se3 (const float* src, float* tgt) const
+  {
+    __m128d p0 = c[3][0];
+    __m128d p1 = c[3][1];
+
+    for (std::size_t i = 0; i < 3; ++i)
     {
-      __m256d p0 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[0])), c[0]);
-      __m256d p1 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[1])), c[1]);
-      __m256d p2 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[2])), c[2]);
-      _mm_store_ps (tgt, _mm256_cvtpd_ps (_mm256_add_pd(p0, _mm256_add_pd(p1, _mm256_add_pd(p2, c[3])))));
+      __m128d vv = _mm_cvtps_pd (_mm_load_ps1 (&src[i]));
+      p0 = _mm_add_pd (_mm_mul_pd (vv, c[i][0]), p0);
+      p1 = _mm_add_pd (_mm_mul_pd (vv, c[i][1]), p1);
     }
 
-  };
+    _mm_store_ps (tgt, _mm_movelh_ps (_mm_cvtpd_ps (p0), _mm_cvtpd_ps (p1)));
+  }
+};
 
-#endif
-#endif
+#else
+
+/** Optimized version for double-precision transform using AVX intrinsics. */
+template<>
+struct Transformer<double>
+{
+  __m256d c[4];
 
+  Transformer(const Eigen::Matrix4d& tf)
+  {
+    for (std::size_t i = 0; i < 4; ++i)
+      c[i] = _mm256_load_pd (tf.col (i).data ());
   }
 
-}
+  void so3 (const float* src, float* tgt) const
+  {
+    __m256d p0 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[0])), c[0]);
+    __m256d p1 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[1])), c[1]);
+    __m256d p2 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[2])), c[2]);
+    _mm_store_ps (tgt, _mm256_cvtpd_ps (_mm256_add_pd(p0, _mm256_add_pd(p1, p2))));
+  }
+
+  void se3 (const float* src, float* tgt) const
+  {
+    __m256d p0 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[0])), c[0]);
+    __m256d p1 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[1])), c[1]);
+    __m256d p2 = _mm256_mul_pd (_mm256_cvtps_pd (_mm_load_ps1 (&src[2])), c[2]);
+    _mm_store_ps (tgt, _mm256_cvtpd_ps (_mm256_add_pd(p0, _mm256_add_pd(p1, _mm256_add_pd(p2, c[3])))));
+  }
+};
+
+#endif // !defined(__AVX__)
+#endif // defined(__SSE2__)
+
+} // namespace detail
+
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename Scalar> void
-pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                          pcl::PointCloud<PointT> &cloud_out,
-                          const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
-                          bool copy_all_fields)
+transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                     pcl::PointCloud<PointT> &cloud_out,
+                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
+                     bool copy_all_fields)
 {
   if (&cloud_in != &cloud_out)
   {
@@ -259,13 +260,13 @@ pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                          const std::vector<int> &indices,
-                          pcl::PointCloud<PointT> &cloud_out,
-                          const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
-                          bool copy_all_fields)
+transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                     const std::vector<int> &indices,
+                     pcl::PointCloud<PointT> &cloud_out,
+                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
+                     bool copy_all_fields)
 {
   std::size_t npts = indices.size ();
   // In order to transform the data, we need to remove NaNs
@@ -306,12 +307,12 @@ pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
-                                     pcl::PointCloud<PointT> &cloud_out,
-                                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
-                                     bool copy_all_fields)
+transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
+                                pcl::PointCloud<PointT> &cloud_out,
+                                const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
+                                bool copy_all_fields)
 {
   if (&cloud_in != &cloud_out)
   {
@@ -354,13 +355,13 @@ pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> void
-pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
-                                     const std::vector<int> &indices,
-                                     pcl::PointCloud<PointT> &cloud_out,
-                                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
-                                     bool copy_all_fields)
+transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
+                                const std::vector<int> &indices,
+                                pcl::PointCloud<PointT> &cloud_out,
+                                const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform,
+                                bool copy_all_fields)
 {
   std::size_t npts = indices.size ();
   // In order to transform the data, we need to remove NaNs
@@ -405,13 +406,13 @@ pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline void
-pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
-                          pcl::PointCloud<PointT> &cloud_out,
-                          const Eigen::Matrix<Scalar, 3, 1> &offset,
-                          const Eigen::Quaternion<Scalar> &rotation,
-                          bool copy_all_fields)
+transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                     pcl::PointCloud<PointT> &cloud_out,
+                     const Eigen::Matrix<Scalar, 3, 1> &offset,
+                     const Eigen::Quaternion<Scalar> &rotation,
+                     bool copy_all_fields)
 {
   Eigen::Translation<Scalar, 3> translation (offset);
   // Assemble an Eigen Transform
@@ -419,13 +420,13 @@ pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   transformPointCloud (cloud_in, cloud_out, t, copy_all_fields);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline void
-pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
-                                     pcl::PointCloud<PointT> &cloud_out,
-                                     const Eigen::Matrix<Scalar, 3, 1> &offset,
-                                     const Eigen::Quaternion<Scalar> &rotation,
-                                     bool copy_all_fields)
+transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
+                                pcl::PointCloud<PointT> &cloud_out,
+                                const Eigen::Matrix<Scalar, 3, 1> &offset,
+                                const Eigen::Quaternion<Scalar> &rotation,
+                                bool copy_all_fields)
 {
   Eigen::Translation<Scalar, 3> translation (offset);
   // Assemble an Eigen Transform
@@ -433,10 +434,9 @@ pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
   transformPointCloudWithNormals (cloud_in, cloud_out, t, copy_all_fields);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline PointT
-pcl::transformPoint (const PointT &point,
-                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform)
+transformPoint (const PointT &point, const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform)
 {
   PointT ret = point;
   pcl::detail::Transformer<Scalar> tf (transform.matrix ());
@@ -444,10 +444,9 @@ pcl::transformPoint (const PointT &point,
   return (ret);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> inline PointT
-pcl::transformPointWithNormal (const PointT &point,
-                     const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform)
+transformPointWithNormal (const PointT &point, const Eigen::Transform<Scalar, 3, Eigen::Affine> &transform)
 {
   PointT ret = point;
   pcl::detail::Transformer<Scalar> tf (transform.matrix ());
@@ -456,10 +455,10 @@ pcl::transformPointWithNormal (const PointT &point,
   return (ret);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT, typename Scalar> double
-pcl::getPrincipalTransformation (const pcl::PointCloud<PointT> &cloud,
-                                 Eigen::Transform<Scalar, 3, Eigen::Affine> &transform)
+getPrincipalTransformation (const pcl::PointCloud<PointT> &cloud,
+                            Eigen::Transform<Scalar, 3, Eigen::Affine> &transform)
 {
   EIGEN_ALIGN16 Eigen::Matrix<Scalar, 3, 3> covariance_matrix;
   Eigen::Matrix<Scalar, 4, 1> centroid;
@@ -479,3 +478,5 @@ pcl::getPrincipalTransformation (const pcl::PointCloud<PointT> &cloud,
   return (std::min (rel1, rel2));
 }
 
+} // namespace pcl
+
index fa8d931499d2845443511f0f92f799fea5b9e927..196bccf7f950e3956f215acab5bae36b214213b0 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PCL_COMMON_VECTOR_AVERAGE_IMPL_HPP_
-#define PCL_COMMON_VECTOR_AVERAGE_IMPL_HPP_
+#pragma once
+
+#include <pcl/common/vector_average.h>
+
 
 namespace pcl
 {
@@ -195,7 +197,4 @@ namespace pcl
     eigen33(covariance_, eigen_value, eigen_vector);
     eigen_vector1 = eigen_vector;
   }
-}  // END namespace
-
-#endif
-
+}  // namespace pcl
index eba6eaff5829539c42f74546a3a96a6f531dbacd..01f4a2c71e1a95622d87482dc44dec725485fd40 100644 (file)
@@ -76,7 +76,7 @@ namespace pcl
     * \ingroup common
     */
   template <typename PointT>
-  PCL_DEPRECATED("use getFieldIndex<PointT> (field_name, fields) instead")
+  PCL_DEPRECATED(1, 12, "use getFieldIndex<PointT> (field_name, fields) instead")
   inline int
   getFieldIndex (const pcl::PointCloud<PointT> &cloud, const std::string &field_name, 
                  std::vector<pcl::PCLPointField> &fields);
@@ -87,8 +87,8 @@ namespace pcl
     * \param[out] fields a vector to the original \a PCLPointField vector that the raw PointCloud message contains
     * \ingroup common
     */
-  template <typename PointT> inline int 
-  getFieldIndex (const std::string &field_name, 
+  template <typename PointT> inline int
+  getFieldIndex (const std::string &field_name,
                  std::vector<pcl::PCLPointField> &fields);
   /** \brief Get the index of a specified field (i.e., dimension/channel)
     * \tparam PointT datatype for which fields is being queries
@@ -106,7 +106,7 @@ namespace pcl
     * \ingroup common
     */
   template <typename PointT>
-  PCL_DEPRECATED("use getFields<PointT> () with return value instead")
+  PCL_DEPRECATED(1, 12, "use getFields<PointT> () with return value instead")
   inline void
   getFields (const pcl::PointCloud<PointT> &cloud, std::vector<pcl::PCLPointField> &fields);
 
@@ -116,8 +116,8 @@ namespace pcl
     * \ingroup common
     */
   template <typename PointT>
-  PCL_DEPRECATED("use getFields<PointT> () with return value instead")
-  inline void 
+  PCL_DEPRECATED(1, 12, "use getFields<PointT> () with return value instead")
+  inline void
   getFields (std::vector<pcl::PCLPointField> &fields);
 
   /** \brief Get the list of available fields (i.e., dimension/channel)
@@ -131,7 +131,7 @@ namespace pcl
     * \param[in] cloud the point cloud message
     * \ingroup common
     */
-  template <typename PointT> inline std::string 
+  template <typename PointT> inline std::string
   getFieldsList (const pcl::PointCloud<PointT> &cloud);
 
   /** \brief Get the available point cloud fields as a space separated string
@@ -288,8 +288,8 @@ namespace pcl
 
   /** \brief Concatenate two pcl::PCLPointCloud2
     *
-    * \warn This function subtly differs from the deprecated `concatenatePointloud`
-    * The difference is thatthis function will concatenate IFF the non-skip fields
+    * \warning This function subtly differs from the deprecated concatenatePointCloud()
+    * The difference is that this function will concatenate IFF the non-skip fields
     * are in the correct order and same in number. The deprecated function skipped
     * fields even if both clouds didn't agree on the number of output fields
     * \param[in] cloud1 the first input point cloud dataset
@@ -328,8 +328,8 @@ namespace pcl
     * \return true if successful, false otherwise (e.g., name/number of fields differs)
     * \ingroup common
     */
-  PCL_DEPRECATED("use pcl::concatenate() instead, but beware of subtle difference in behavior (see documentation)")
-  PCL_EXPORTS bool 
+  PCL_DEPRECATED(1, 12, "use pcl::concatenate() instead, but beware of subtle difference in behavior (see documentation)")
+  PCL_EXPORTS bool
   concatenatePointCloud (const pcl::PCLPointCloud2 &cloud1,
                          const pcl::PCLPointCloud2 &cloud2,
                          pcl::PCLPointCloud2 &cloud_out);
@@ -341,9 +341,9 @@ namespace pcl
     * \note Assumes unique indices.
     * \ingroup common
     */
-  PCL_EXPORTS void 
+  PCL_EXPORTS void
   copyPointCloud (const pcl::PCLPointCloud2 &cloud_in,
-                  const std::vector<int> &indices, 
+                  const std::vector<int> &indices,
                   pcl::PCLPointCloud2 &cloud_out);
 
   /** \brief Extract the indices of a given point cloud as a new point cloud
@@ -353,9 +353,9 @@ namespace pcl
     * \note Assumes unique indices.
     * \ingroup common
     */
-  PCL_EXPORTS void 
+  PCL_EXPORTS void
   copyPointCloud (const pcl::PCLPointCloud2 &cloud_in,
-                  const std::vector<int, Eigen::aligned_allocator<int> > &indices, 
+                  const std::vector<int, Eigen::aligned_allocator<int> > &indices,
                   pcl::PCLPointCloud2 &cloud_out);
 
   /** \brief Copy fields and point cloud data from \a cloud_in to \a cloud_out
@@ -363,7 +363,7 @@ namespace pcl
     * \param[out] cloud_out the resultant output point cloud dataset
     * \ingroup common
     */
-  PCL_EXPORTS void 
+  PCL_EXPORTS void
   copyPointCloud (const pcl::PCLPointCloud2 &cloud_in,
                   pcl::PCLPointCloud2 &cloud_out);
 
@@ -382,7 +382,7 @@ namespace pcl
     * \ingroup common
     */
   template <typename PointT, typename IndicesVectorAllocator = std::allocator<int>> void
-  copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
+  copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
                   const std::vector<int, IndicesVectorAllocator> &indices,
                   pcl::PointCloud<PointT> &cloud_out);
 
@@ -393,9 +393,9 @@ namespace pcl
     * \note Assumes unique indices.
     * \ingroup common
     */
-  template <typename PointT> void 
-  copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
-                  const PointIndices &indices, 
+  template <typename PointT> void
+  copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const PointIndices &indices,
                   pcl::PointCloud<PointT> &cloud_out);
 
   /** \brief Extract the indices of a given point cloud as a new point cloud
@@ -405,9 +405,9 @@ namespace pcl
     * \note Assumes unique indices.
     * \ingroup common
     */
-  template <typename PointT> void 
-  copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
-                  const std::vector<pcl::PointIndices> &indices, 
+  template <typename PointT> void
+  copyPointCloud (const pcl::PointCloud<PointT> &cloud_in,
+                  const std::vector<pcl::PointIndices> &indices,
                   pcl::PointCloud<PointT> &cloud_out);
 
   /** \brief Copy all the fields from a given point cloud into a new point cloud
@@ -415,8 +415,8 @@ namespace pcl
     * \param[out] cloud_out the resultant output point cloud dataset
     * \ingroup common
     */
-  template <typename PointInT, typename PointOutT> void 
-  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in, 
+  template <typename PointInT, typename PointOutT> void
+  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
                   pcl::PointCloud<PointOutT> &cloud_out);
 
   /** \brief Extract the indices of a given point cloud as a new point cloud
@@ -427,7 +427,7 @@ namespace pcl
     * \ingroup common
     */
   template <typename PointInT, typename PointOutT, typename IndicesVectorAllocator = std::allocator<int>> void
-  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in, 
+  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
                   const std::vector<int, IndicesVectorAllocator> &indices,
                   pcl::PointCloud<PointOutT> &cloud_out);
 
@@ -438,9 +438,9 @@ namespace pcl
     * \note Assumes unique indices.
     * \ingroup common
     */
-  template <typename PointInT, typename PointOutT> void 
-  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in, 
-                  const PointIndices &indices, 
+  template <typename PointInT, typename PointOutT> void
+  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
+                  const PointIndices &indices,
                   pcl::PointCloud<PointOutT> &cloud_out);
 
   /** \brief Extract the indices of a given point cloud as a new point cloud
@@ -450,9 +450,9 @@ namespace pcl
     * \note Assumes unique indices.
     * \ingroup common
     */
-  template <typename PointInT, typename PointOutT> void 
-  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in, 
-                  const std::vector<pcl::PointIndices> &indices, 
+  template <typename PointInT, typename PointOutT> void
+  copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
+                  const std::vector<pcl::PointIndices> &indices,
                   pcl::PointCloud<PointOutT> &cloud_out);
 
   /** \brief Copy a point cloud inside a larger one interpolating borders.
@@ -491,9 +491,9 @@ namespace pcl
     * \param[out] cloud_out the resultant output dataset created by the concatenation of all the fields in the input datasets
     * \ingroup common
     */
-  template <typename PointIn1T, typename PointIn2T, typename PointOutT> void 
-  concatenateFields (const pcl::PointCloud<PointIn1T> &cloud1_in, 
-                     const pcl::PointCloud<PointIn2T> &cloud2_in, 
+  template <typename PointIn1T, typename PointIn2T, typename PointOutT> void
+  concatenateFields (const pcl::PointCloud<PointIn1T> &cloud1_in,
+                     const pcl::PointCloud<PointIn2T> &cloud2_in,
                      pcl::PointCloud<PointOutT> &cloud_out);
 
   /** \brief Concatenate two datasets representing different fields.
@@ -517,7 +517,7 @@ namespace pcl
     * \param[out] out the resultant Eigen MatrixXf format containing XYZ0 / point
     * \ingroup common
     */
-  PCL_EXPORTS bool 
+  PCL_EXPORTS bool
   getPointCloudAsEigen (const pcl::PCLPointCloud2 &in, Eigen::MatrixXf &out);
 
   /** \brief Copy the XYZ dimensions from an Eigen MatrixXf into a pcl::PCLPointCloud2 message
@@ -526,45 +526,45 @@ namespace pcl
     * \note the method assumes that the PCLPointCloud2 message already has the fields set up properly !
     * \ingroup common
     */
-  PCL_EXPORTS bool 
+  PCL_EXPORTS bool
   getEigenAsPointCloud (Eigen::MatrixXf &in, pcl::PCLPointCloud2 &out);
-  
-  namespace io 
+
+  namespace io
   {
     /** \brief swap bytes order of a char array of length N
       * \param bytes char array to swap
       * \ingroup common
       */
-    template <std::size_t N> void 
+    template <std::size_t N> void
     swapByte (char* bytes);
 
    /** \brief specialization of swapByte for dimension 1
      * \param bytes char array to swap
      */
-    template <> inline void 
+    template <> inline void
     swapByte<1> (char* bytes) { bytes[0] = bytes[0]; }
 
-  
+
    /** \brief specialization of swapByte for dimension 2
      * \param bytes char array to swap
      */
-    template <> inline void 
+    template <> inline void
     swapByte<2> (char* bytes) { std::swap (bytes[0], bytes[1]); }
-  
+
    /** \brief specialization of swapByte for dimension 4
      * \param bytes char array to swap
      */
-    template <> inline void 
+    template <> inline void
     swapByte<4> (char* bytes)
     {
       std::swap (bytes[0], bytes[3]);
       std::swap (bytes[1], bytes[2]);
     }
-  
+
    /** \brief specialization of swapByte for dimension 8
      * \param bytes char array to swap
      */
-    template <> inline void 
+    template <> inline void
     swapByte<8> (char* bytes)
     {
       std::swap (bytes[0], bytes[7]);
@@ -572,11 +572,11 @@ namespace pcl
       std::swap (bytes[2], bytes[5]);
       std::swap (bytes[3], bytes[4]);
     }
-  
+
     /** \brief swaps byte of an arbitrary type T casting it to char*
       * \param value the data you want its bytes swapped
       */
-    template <typename T> void 
+    template <typename T> void
     swapByte (T& value)
     {
       pcl::io::swapByte<sizeof(T)> (reinterpret_cast<char*> (&value));
diff --git a/common/include/pcl/common/point_operators.h b/common/include/pcl/common/point_operators.h
deleted file mode 100644 (file)
index b32c86e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Software License Agreement (BSD License)
- *
- *  Point Cloud Library (PCL) - www.pointclouds.org
- *  Copyright (c) 2010-2011, Willow Garage, Inc.
- *  Copyright (c) 2012-, Open Perception, Inc.
- *
- *  All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions
- *  are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the following
- *     disclaimer in the documentation and/or other materials provided
- *     with the distribution.
- *   * Neither the name of the copyright holder(s) nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *  POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id$
- *
- */
-
-#pragma once
index ada6d97eb33ff53c43dfb1e209bee8076228a756..100744b297f5a5e9c820135fd0c05f4db9552b38 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/correspondence.h>
 
index 2e0bca6eb4b7842d54115f2556d82c65bc41c835..aae7e7241fc6cb2ce3f9fb858cde8c0e8c7d35e0 100644 (file)
@@ -64,7 +64,7 @@ namespace pcl
         
         /** Get the number of added vectors */
         inline unsigned int 
-        getNoOfSamples () { return no_of_samples_;}
+        getNoOfSamples () const { return no_of_samples_;}
         
         /** Add a new sample */
         inline void 
index 6c91b001cf2f4dc24ea45f0d2a66c131cbef232c..2390ffeb21f5f8927a35bd8c037a0916be5c09de 100644 (file)
@@ -56,5 +56,11 @@ namespace pcl
     {
       return (std::fabs (val1 - val2) < eps);
     }
-  }
-}
+
+   /** \brief Utility function to eliminate unused variable warnings. */
+    template<typename T> void
+    ignore(const T&)
+    {
+    }
+  } // namespace utils
+} // namespace pcl
index 26a5ba67727dbcfda2cd93253d65b64a0bf236af..3cd07635c140bea9164a442832893aa3dec17ea6 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/common/eigen.h>
 
index 041b7205f8dcb719e296367a8d84410c6773226f..db008eb313ef268e9fb1c396e677ac9513026609 100644 (file)
@@ -47,7 +47,7 @@
 #include <pcl/PCLPointCloud2.h>
 #include <pcl/PCLImage.h>
 #include <pcl/point_cloud.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <pcl/for_each_type.h>
 #include <pcl/exceptions.h>
 #include <pcl/console/print.h>
index ed7976361e0d7a9dbf5188e42e7877e2d51e8bce..dba2a50dde966e7a5f8806559b5db1827b8bd45c 100644 (file)
 #pragma once
 
 #ifdef __GNUC__
-#pragma GCC system_header 
+#pragma GCC system_header
 #endif
 
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <Eigen/StdVector>
 #include <Eigen/Geometry>
 #include <pcl/pcl_exports.h>
@@ -50,7 +50,7 @@
 
 namespace pcl
 {
-  /** \brief Correspondence represents a match between two entities (e.g., points, descriptors, etc). This is 
+  /** \brief Correspondence represents a match between two entities (e.g., points, descriptors, etc). This is
     * represented via the indices of a \a source point and a \a target point, and the distance between them.
     *
     * \author Dirk Holz, Radu B. Rusu, Bastian Steder
@@ -68,14 +68,14 @@ namespace pcl
       float distance = std::numeric_limits<float>::max();
       float weight;
     };
-    
-    /** \brief Standard constructor. 
+
+    /** \brief Standard constructor.
       * Sets \ref index_query to 0, \ref index_match to -1, and \ref distance to FLT_MAX.
       */
     inline Correspondence () = default;
 
     /** \brief Constructor. */
-    inline Correspondence (int _index_query, int _index_match, float _distance) : 
+    inline Correspondence (int _index_query, int _index_match, float _distance) :
       index_query (_index_query), index_match (_index_match), distance (_distance)
     {}
 
index 8f5823ca04894982c04224d568b172ec8be7cdb2..aaba2db3e8784b8585cf4f742fa47d49ca0717b5 100644 (file)
  *
  */
 
-#ifndef PCL_IMPL_POINT_TYPES_HPP_
-#define PCL_IMPL_POINT_TYPES_HPP_
+#pragma once
 
-#include <cstdint>
-#if defined __GNUC__
-#  pragma GCC system_header
-#endif
+#include <pcl/memory.h>                 // for PCL_MAKE_ALIGNED_OPERATOR_NEW
+#include <pcl/pcl_macros.h>             // for PCL_EXPORTS
+#include <pcl/PCLPointField.h>          // for PCLPointField
+#include <pcl/point_types.h>            // implementee
+#include <pcl/register_point_struct.h>  // for POINT_CLOUD_REGISTER_POINT_STRUCT, POINT_CLOUD_REGISTER_POINT_WRAPPER
 
-#include <algorithm>
-#include <ostream>
+#include <boost/mpl/and.hpp>            // for boost::mpl::and_
+#include <boost/mpl/bool.hpp>           // for boost::mpl::bool_
+#include <boost/mpl/contains.hpp>       // for boost::mpl::contains
+#include <boost/mpl/fold.hpp>           // for boost::mpl::fold
+#include <boost/mpl/or.hpp>             // for boost::mpl::or_
+#include <boost/mpl/placeholders.hpp>   // for boost::mpl::_1, boost::mpl::_2
+#include <boost/mpl/vector.hpp>         // for boost::mpl::vector
 
-#include <Eigen/Core>
+#include <Eigen/Core>                   // for MatrixMap
 
-#include <pcl/pcl_macros.h>
+#include <algorithm>                    // for copy_n, fill_n
+#include <cstdint>                      // for uint8_t, uint32_t
+#include <ostream>                      // for ostream, operator<<
+#include <type_traits>                  // for enable_if_t
 
 // Define all PCL point types
 #define PCL_POINT_TYPES         \
@@ -959,7 +967,7 @@ namespace pcl
     }
 
     inline PointXYZRGBNormal (float _curvature = 0.f):
-        PointXYZRGBNormal (0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, _curvature) {}
+        PointXYZRGBNormal (0.f, 0.f, 0.f, 0, 0, 0, 0.f, 0.f, 0.f, _curvature) {}
 
     inline PointXYZRGBNormal (float _x, float _y, float _z):
       PointXYZRGBNormal (_x, _y, _z, 0, 0, 0) {}
@@ -1014,9 +1022,9 @@ namespace pcl
       curvature = p.curvature;
       intensity = p.intensity;
     }
-    
+
     inline PointXYZINormal (float _intensity = 0.f): PointXYZINormal (0.f, 0.f, 0.f, _intensity) {}
-    
+
     inline PointXYZINormal (float _x, float _y, float _z, float _intensity = 0.f):
       PointXYZINormal (_x, _y, _z, _intensity, 0.f, 0.f, 0.f) {}
 
@@ -1066,7 +1074,7 @@ namespace pcl
     }
 
     inline PointXYZLNormal (std::uint32_t _label = 0): PointXYZLNormal (0.f, 0.f, 0.f, _label) {}
-    
+
     inline PointXYZLNormal (float _x, float _y, float _z, std::uint32_t _label = 0.f):
       PointXYZLNormal (_x, _y, _z, _label, 0.f, 0.f, 0.f) {}
 
@@ -1156,14 +1164,14 @@ namespace pcl
 
     inline PointWithViewpoint (): PointWithViewpoint (0.f, 0.f, 0.f) {}
 
-    PCL_DEPRECATED("Use ctor accepting all position (x, y, z) data")
+    PCL_DEPRECATED(1, 12, "Use ctor accepting all position (x, y, z) data")
     inline PointWithViewpoint (float _x, float _y = 0.f):
       PointWithViewpoint (_x, _y, 0.f) {}
 
-    PCL_DEPRECATED("Use ctor accepting all viewpoint (vp_x, vp_y, vp_z) data")
+    PCL_DEPRECATED(1, 12, "Use ctor accepting all viewpoint (vp_x, vp_y, vp_z) data")
     inline PointWithViewpoint (float _x, float _y, float _z, float _vp_x, float _vp_y = 0.f):
       PointWithViewpoint (_x, _y, _z, _vp_x, _vp_y, 0.f) {}
-    
+
     inline PointWithViewpoint (float _x, float _y, float _z): PointWithViewpoint (_x, _y, _z, 0.f, 0.f, 0.f) {}
 
     inline PointWithViewpoint (float _x, float _y, float _z, float _vp_x, float _vp_y, float _vp_z)
@@ -1202,7 +1210,7 @@ namespace pcl
     inline PrincipalRadiiRSD () = default;
 
     inline PrincipalRadiiRSD (float _r_min, float _r_max): r_min (_r_min), r_max (_r_max) {}
-    
+
     friend std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p);
   };
 
@@ -1457,9 +1465,9 @@ namespace pcl
 
     inline ReferenceFrame ()
     {
-      std::fill_n(x_axis, 3, 0);
-      std::fill_n(y_axis, 3, 0);
-      std::fill_n(z_axis, 3, 0);
+      std::fill_n(x_axis, 3, 0.f);
+      std::fill_n(y_axis, 3, 0.f);
+      std::fill_n(z_axis, 3, 0.f);
     }
 
     // @TODO: add other ctors
@@ -1625,7 +1633,7 @@ namespace pcl
     */
   struct BorderDescription
   {
-    int x = 0.f, y = 0.f;
+    int x = 0, y = 0;
     BorderTraits traits;
     //std::vector<const BorderDescription*> neighbors;
 
@@ -1710,7 +1718,7 @@ namespace pcl
 
     inline PointWithScale (): PointWithScale (0.f, 0.f, 0.f) {}
 
-    inline PointWithScale (float _x, float _y, float _z, float _scale = 1.f, 
+    inline PointWithScale (float _x, float _y, float _z, float _scale = 1.f,
                            float _angle = -1.f, float _response = 0.f, int _octave = 0)
     {
       x = _x; y = _y; z = _z;
@@ -1814,7 +1822,7 @@ namespace pcl
     friend std::ostream& operator << (std::ostream& os, const PointDEM& p);
   };
 
-  template <int N> std::ostream& 
+  template <int N> std::ostream&
   operator << (std::ostream& os, const Histogram<N>& p)
   {
     // make constexpr
@@ -1827,6 +1835,561 @@ namespace pcl
     }
     return (os);
   }
-} // End namespace
+} // namespace pcl
+
+// Register point structs and wrappers
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_RGB,
+    (std::uint32_t, rgba, rgba)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::RGB, pcl::_RGB)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Intensity,
+    (float, intensity, intensity)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Intensity, pcl::_Intensity)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Intensity8u,
+    (std::uint8_t, intensity, intensity)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Intensity8u, pcl::_Intensity8u)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Intensity32u,
+    (std::uint32_t, intensity, intensity)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Intensity32u, pcl::_Intensity32u)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZ,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZ, pcl::_PointXYZ)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBA,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (std::uint32_t, rgba, rgba)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBA, pcl::_PointXYZRGBA)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGB,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, rgb, rgb)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGB, pcl::_PointXYZRGB)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBL,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (std::uint32_t, rgba, rgba)
+    (std::uint32_t, label, label)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBL, pcl::_PointXYZRGBL)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZHSV,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, h, h)
+    (float, s, s)
+    (float, v, v)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZHSV, pcl::_PointXYZHSV)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXY,
+    (float, x, x)
+    (float, y, y)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointUV,
+    (float, u, u)
+    (float, v, v)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::InterestPoint,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, strength, strength)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZI,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, intensity, intensity)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZI, pcl::_PointXYZI)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZL,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (std::uint32_t, label, label)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Label,
+    (std::uint32_t, label, label)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Normal,
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+    (float, curvature, curvature)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Normal, pcl::_Normal)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Axis,
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Axis, pcl::_Axis)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointNormal,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+    (float, curvature, curvature)
+)
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBNormal,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, rgb, rgb)
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+    (float, curvature, curvature)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBNormal, pcl::_PointXYZRGBNormal)
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZINormal,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, intensity, intensity)
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+    (float, curvature, curvature)
+)
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZLNormal,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (std::uint32_t, label, label)
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+    (float, curvature, curvature)
+)
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointWithRange,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, range, range)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointWithViewpoint,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, vp_x, vp_x)
+    (float, vp_y, vp_y)
+    (float, vp_z, vp_z)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointWithViewpoint, pcl::_PointWithViewpoint)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::MomentInvariants,
+    (float, j1, j1)
+    (float, j2, j2)
+    (float, j3, j3)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalRadiiRSD,
+    (float, r_min, r_min)
+    (float, r_max, r_max)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Boundary,
+    (std::uint8_t, boundary_point, boundary_point)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalCurvatures,
+    (float, principal_curvature_x, principal_curvature_x)
+    (float, principal_curvature_y, principal_curvature_y)
+    (float, principal_curvature_z, principal_curvature_z)
+    (float, pc1, pc1)
+    (float, pc2, pc2)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHSignature125,
+    (float[125], histogram, pfh)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHRGBSignature250,
+    (float[250], histogram, pfhrgb)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFSignature,
+    (float, f1, f1)
+    (float, f2, f2)
+    (float, f3, f3)
+    (float, f4, f4)
+    (float, alpha_m, alpha_m)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::CPPFSignature,
+    (float, f1, f1)
+    (float, f2, f2)
+    (float, f3, f3)
+    (float, f4, f4)
+    (float, f5, f5)
+    (float, f6, f6)
+    (float, f7, f7)
+    (float, f8, f8)
+    (float, f9, f9)
+    (float, f10, f10)
+    (float, alpha_m, alpha_m)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFRGBSignature,
+    (float, f1, f1)
+    (float, f2, f2)
+    (float, f3, f3)
+    (float, f4, f4)
+    (float, r_ratio, r_ratio)
+    (float, g_ratio, g_ratio)
+    (float, b_ratio, b_ratio)
+    (float, alpha_m, alpha_m)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::NormalBasedSignature12,
+    (float[12], values, values)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ShapeContext1980,
+    (float[1980], descriptor, shape_context)
+    (float[9], rf, rf)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::UniqueShapeContext1960,
+    (float[1960], descriptor, shape_context)
+    (float[9], rf, rf)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT352,
+    (float[352], descriptor, shot)
+    (float[9], rf, rf)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT1344,
+    (float[1344], descriptor, shot)
+    (float[9], rf, rf)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::FPFHSignature33,
+    (float[33], histogram, fpfh)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::BRISKSignature512,
+    (float, scale, brisk_scale)
+    (float, orientation, brisk_orientation)
+    (unsigned char[64], descriptor, brisk_descriptor512)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::VFHSignature308,
+    (float[308], histogram, vfh)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::GRSDSignature21,
+    (float[21], histogram, grsd)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ESFSignature640,
+    (float[640], histogram, esf)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::GASDSignature512,
+    (float[512], histogram, gasd)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::GASDSignature984,
+    (float[984], histogram, gasd)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::GASDSignature7992,
+    (float[7992], histogram, gasd)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Narf36,
+    (float[36], descriptor, descriptor)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::GFPFHSignature16,
+    (float[16], histogram, gfpfh)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::IntensityGradient,
+    (float, gradient_x, gradient_x)
+    (float, gradient_y, gradient_y)
+    (float, gradient_z, gradient_z)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointWithScale,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, scale, scale)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::PointSurfel,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, normal_x, normal_x)
+    (float, normal_y, normal_y)
+    (float, normal_z, normal_z)
+    (std::uint32_t, rgba, rgba)
+    (float, radius, radius)
+    (float, confidence, confidence)
+    (float, curvature, curvature)
+)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_ReferenceFrame,
+    (float[3], x_axis, x_axis)
+    (float[3], y_axis, y_axis)
+    (float[3], z_axis, z_axis)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::ReferenceFrame, pcl::_ReferenceFrame)
+
+POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointDEM,
+    (float, x, x)
+    (float, y, y)
+    (float, z, z)
+    (float, intensity, intensity)
+    (float, intensity_variance, intensity_variance)
+    (float, height_variance, height_variance)
+)
+POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointDEM, pcl::_PointDEM)
 
+namespace pcl
+{
+
+// Allow float 'rgb' data to match to the newer uint32 'rgba' tag. This is so
+// you can load old 'rgb' PCD files into e.g. a PointCloud<PointXYZRGBA>.
+template<typename PointT>
+struct FieldMatches<PointT, ::pcl::fields::rgba>
+{
+  bool operator() (const pcl::PCLPointField& field)
+  {
+    if (field.name == "rgb")
+    {
+      // For fixing the alpha value bug #1141, the rgb field can also match
+      // uint32.
+      return ((field.datatype == pcl::PCLPointField::FLOAT32 ||
+               field.datatype == pcl::PCLPointField::UINT32) &&
+              field.count == 1);
+    }
+    else
+    {
+      return (field.name == traits::name<PointT, fields::rgba>::value &&
+              field.datatype == traits::datatype<PointT, fields::rgba>::value &&
+              field.count == traits::datatype<PointT, fields::rgba>::size);
+    }
+  }
+};
+template<typename PointT>
+struct FieldMatches<PointT, fields::rgb>
+{
+  bool operator() (const pcl::PCLPointField& field)
+  {
+    if (field.name == "rgba")
+    {
+      return (field.datatype == pcl::PCLPointField::UINT32 &&
+              field.count == 1);
+    }
+    else
+    {
+      // For fixing the alpha value bug #1141, rgb can also match uint32
+      return (field.name == traits::name<PointT, fields::rgb>::value &&
+              (field.datatype == traits::datatype<PointT, fields::rgb>::value ||
+               field.datatype == pcl::PCLPointField::UINT32) &&
+              field.count == traits::datatype<PointT, fields::rgb>::size);
+    }
+  }
+};
+
+
+// We're doing a lot of black magic with Boost here, so disable warnings in Maintainer mode, as we will never
+// be able to fix them anyway
+#if defined _MSC_VER
+  #pragma warning(disable: 4201)
 #endif
+
+namespace traits
+{
+
+  /** \brief Metafunction to check if a given point type has a given field.
+   *
+   *  Example usage at run-time:
+   *
+   *  \code
+   *  bool curvature_available = pcl::traits::has_field<PointT, pcl::fields::curvature>::value;
+   *  \endcode
+   *
+   *  Example usage at compile-time:
+   *
+   *  \code
+   *  BOOST_MPL_ASSERT_MSG ((pcl::traits::has_field<PointT, pcl::fields::label>::value),
+   *                        POINT_TYPE_SHOULD_HAVE_LABEL_FIELD,
+   *                        (PointT));
+   *  \endcode
+   */
+  template <typename PointT, typename Field>
+  struct has_field : boost::mpl::contains<typename pcl::traits::fieldList<PointT>::type, Field>::type
+  { };
+
+  /** Metafunction to check if a given point type has all given fields. */
+  template <typename PointT, typename Field>
+  struct has_all_fields : boost::mpl::fold<Field,
+                                           boost::mpl::bool_<true>,
+                                           boost::mpl::and_<boost::mpl::_1,
+                                                            has_field<PointT, boost::mpl::_2> > >::type
+  { };
+
+  /** Metafunction to check if a given point type has any of the given fields. */
+  template <typename PointT, typename Field>
+  struct has_any_field : boost::mpl::fold<Field,
+                                          boost::mpl::bool_<false>,
+                                          boost::mpl::or_<boost::mpl::_1,
+                                                          has_field<PointT, boost::mpl::_2> > >::type
+  { };
+
+  /** \brief Traits defined for ease of use with fields already registered before
+   *
+   * has_<fields to be detected>: struct with `value` datamember defined at compiletime
+   * has_<fields to be detected>_v: constexpr boolean
+   * Has<Fields to be detected>: concept modelling name alias for `enable_if`
+   */
+
+  /** Metafunction to check if a given point type has x and y fields. */
+  template <typename PointT>
+  struct has_xy : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x,
+                                                            pcl::fields::y> >
+  { };
+
+  template <typename PointT>
+  constexpr auto has_xy_v = has_xy<PointT>::value;
+
+  template <typename PointT>
+  using HasXY = std::enable_if_t<has_xy_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoXY = std::enable_if_t<!has_xy_v<PointT>, bool>;
+
+  /** Metafunction to check if a given point type has x, y, and z fields. */
+  template <typename PointT>
+  struct has_xyz : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x,
+                                                             pcl::fields::y,
+                                                             pcl::fields::z> >
+  { };
+
+  template <typename PointT>
+  constexpr auto has_xyz_v = has_xyz<PointT>::value;
+
+  template <typename PointT>
+  using HasXYZ = std::enable_if_t<has_xyz_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoXYZ = std::enable_if_t<!has_xyz_v<PointT>, bool>;
+
+  /** Metafunction to check if a given point type has normal_x, normal_y, and
+    * normal_z fields. */
+  template <typename PointT>
+  struct has_normal : has_all_fields<PointT, boost::mpl::vector<pcl::fields::normal_x,
+                                                                pcl::fields::normal_y,
+                                                                pcl::fields::normal_z> >
+  { };
+
+  template <typename PointT>
+  constexpr auto has_normal_v = has_normal<PointT>::value;
+
+  template <typename PointT>
+  using HasNormal = std::enable_if_t<has_normal_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoNormal = std::enable_if_t<!has_normal_v<PointT>, bool>;
+
+  /** Metafunction to check if a given point type has curvature field. */
+  template <typename PointT>
+  struct has_curvature : has_field<PointT, pcl::fields::curvature>
+  { };
+
+  template <typename PointT>
+  constexpr auto has_curvature_v = has_curvature<PointT>::value;
+
+  template <typename PointT>
+  using HasCurvature = std::enable_if_t<has_curvature_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoCurvature = std::enable_if_t<!has_curvature_v<PointT>, bool>;
+
+  /** Metafunction to check if a given point type has intensity field. */
+  template <typename PointT>
+  struct has_intensity : has_field<PointT, pcl::fields::intensity>
+  { };
+
+  template <typename PointT>
+  constexpr auto has_intensity_v = has_intensity<PointT>::value;
+
+  template <typename PointT>
+  using HasIntensity = std::enable_if_t<has_intensity_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoIntensity = std::enable_if_t<!has_intensity_v<PointT>, bool>;
+
+  /** Metafunction to check if a given point type has either rgb or rgba field. */
+  template <typename PointT>
+  struct has_color : has_any_field<PointT, boost::mpl::vector<pcl::fields::rgb,
+                                                              pcl::fields::rgba> >
+  { };
+
+  template <typename PointT>
+  constexpr auto has_color_v = has_color<PointT>::value;
+
+  template <typename PointT>
+  using HasColor = std::enable_if_t<has_color_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoColor = std::enable_if_t<!has_color_v<PointT>, bool>;
+
+  /** Metafunction to check if a given point type has label field. */
+  template <typename PointT>
+  struct has_label : has_field<PointT, pcl::fields::label>
+  { };
+
+  template <typename PointT>
+  constexpr auto has_label_v = has_label<PointT>::value;
+
+  template <typename PointT>
+  using HasLabel = std::enable_if_t<has_label_v<PointT>, bool>;
+
+  template <typename PointT>
+  using HasNoLabel = std::enable_if_t<!has_label_v<PointT>, bool>;
+}
+
+#if defined _MSC_VER
+  #pragma warning(default: 4201)
+#endif
+
+} // namespace pcl
+
index 30f6451038eb84a46b13931dacd47ade319a8fbd..488ec319965db328590a682841db41ac3cddaace 100644 (file)
  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
- *
  */
 
 #pragma once
 
+PCL_DEPRECATED_HEADER(1, 13, "Use <pcl/memory.h> instead.")
 
-#include <type_traits>
-#include <utility>
-
-#include <boost/make_shared.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <pcl/point_traits.h>
-
-
-namespace pcl
-{
-
-#ifdef DOXYGEN_ONLY
-
-/**
- * \brief Returns a pcl::shared_ptr compliant with type T's allocation policy.
- *
- * boost::allocate_shared or boost::make_shared will be invoked in case T has or
- * doesn't have a custom allocator, respectively.
- *
- * \see pcl::has_custom_allocator, PCL_MAKE_ALIGNED_OPERATOR_NEW
- * \tparam T Type of the object to create a pcl::shared_ptr of
- * \tparam Args Types for the arguments to pcl::make_shared
- * \param args List of arguments with which an instance of T will be constructed
- * \return pcl::shared_ptr of an instance of type T
- */
-template<typename T, typename ... Args>
-shared_ptr<T> make_shared(Args&&... args);
-
-#else
-
-template<typename T, typename ... Args>
-std::enable_if_t<has_custom_allocator<T>::value, shared_ptr<T>> make_shared(Args&&... args)
-{
-  return boost::allocate_shared<T>(Eigen::aligned_allocator<T>(), std::forward<Args> (args)...);
-}
-
-template<typename T, typename ... Args>
-std::enable_if_t<!has_custom_allocator<T>::value, shared_ptr<T>> make_shared(Args&&... args)
-{
-  return boost::make_shared<T>(std::forward<Args> (args)...);
-}
-
-#endif
+#include <pcl/memory.h>
 
-} // namespace pcl
diff --git a/common/include/pcl/memory.h b/common/include/pcl/memory.h
new file mode 100644 (file)
index 0000000..d42e47a
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2019-, Open Perception, Inc.
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of the copyright holder(s) nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+/**
+ * \file pcl/memory.h
+ *
+ * \brief Defines functions, macros and traits for allocating and using memory.
+ * \ingroup common
+ */
+
+#include <pcl/type_traits.h>  // for has_custom_allocator
+
+#include <Eigen/Core>  // for EIGEN_MAKE_ALIGNED_OPERATOR_NEW
+
+#include <memory>  // for std::allocate_shared, std::dynamic_pointer_cast, std::make_shared, std::shared_ptr, std::static_pointer_cast, std::weak_ptr
+#include <type_traits>  // for std::enable_if_t, std::false_type, std::true_type
+#include <utility>  // for std::forward
+
+/**
+ * \brief Macro to signal a class requires a custom allocator
+ *
+ *  It's an implementation detail to have pcl::has_custom_allocator work, a
+ *  thin wrapper over Eigen's own macro
+ *
+ * \see pcl::has_custom_allocator, pcl::make_shared
+ * \ingroup common
+ */
+#define PCL_MAKE_ALIGNED_OPERATOR_NEW \
+  EIGEN_MAKE_ALIGNED_OPERATOR_NEW \
+  using _custom_allocator_type_trait = void;
+
+
+namespace pcl
+{
+/**
+ * \brief Force ADL for `shared_ptr`
+ *
+ * For ease of switching from boost::shared_ptr to std::shared_ptr
+ *
+ * \see pcl::make_shared
+ */
+using std::shared_ptr;
+
+/**
+ * \brief Force ADL for `weak_ptr`
+ *
+ * For ease of switching from boost::weak_ptr to std::weak_ptr
+ */
+using std::weak_ptr;
+
+/** ADL doesn't work until C++20 for dynamic_pointer_cast since it requires an explicit Tparam */
+using std::dynamic_pointer_cast;
+
+/** ADL doesn't work until C++20 for static_pointer_cast since it requires an explicit Tparam */
+using std::static_pointer_cast;
+
+#ifdef DOXYGEN_ONLY
+
+/**
+ * \brief Returns a pcl::shared_ptr compliant with type T's allocation policy.
+ *
+ * std::allocate_shared or std::make_shared will be invoked in case T has or
+ * doesn't have a custom allocator, respectively.
+ *
+ * \note In MSVC < 1915 (before version 15.8) alignment was incorrectly set at
+ *   most at alignof(max_align_t). This bug was fixed in said version and is
+ *   acknowledged by defining _ENABLE_EXTENDED_ALIGNED_STORAGE. See #3752.
+ *
+ * \see pcl::has_custom_allocator, PCL_MAKE_ALIGNED_OPERATOR_NEW
+ * \tparam T Type of the object to create a pcl::shared_ptr of
+ * \tparam Args Types for the arguments to pcl::make_shared
+ * \param args List of arguments with which an instance of T will be constructed
+ * \return pcl::shared_ptr of an instance of type T
+ */
+template<typename T, typename ... Args>
+shared_ptr<T> make_shared(Args&&... args);
+
+#else
+
+template<typename T, typename ... Args>
+std::enable_if_t<has_custom_allocator<T>::value, shared_ptr<T>> make_shared(Args&&... args)
+{
+  return std::allocate_shared<T>(Eigen::aligned_allocator<T>(), std::forward<Args> (args)...);
+}
+
+template<typename T, typename ... Args>
+std::enable_if_t<!has_custom_allocator<T>::value, shared_ptr<T>> make_shared(Args&&... args)
+{
+  return std::make_shared<T>(std::forward<Args> (args)...);
+}
+
+#endif
+}
index ac13ca34486068198549c3e8a8fa4f44dd7b83be..6882aac73bf493f7fb857b5af17e855d22c9bdbc 100644 (file)
@@ -43,9 +43,9 @@
 #endif
 
 // Include PCL macros such as PCL_ERROR, PCL_MAKE_ALIGNED_OPERATOR_NEW, etc
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
-#include <boost/shared_ptr.hpp>
 #include <Eigen/StdVector>
 #include <Eigen/Core>
 
 #include <pcl/point_cloud.h>
 #include <pcl/PointIndices.h>
 #include <pcl/PCLPointCloud2.h>
+#include <pcl/types.h>
 
 namespace pcl
 {
   // definitions used everywhere
-  using Indices = std::vector<int>;
   using IndicesPtr = shared_ptr<Indices>;
   using IndicesConstPtr = shared_ptr<const Indices>;
 
@@ -83,11 +83,7 @@ namespace pcl
       PCLBase (const PCLBase& base);
 
       /** \brief Destructor. */
-      virtual ~PCLBase ()
-      {
-        input_.reset ();
-        indices_.reset ();
-      }
+      virtual ~PCLBase () = default;
 
       /** \brief Provide a pointer to the input dataset
         * \param[in] cloud the const boost shared pointer to a PointCloud message
@@ -196,11 +192,7 @@ namespace pcl
       PCLBase ();
 
       /** \brief destructor. */
-      virtual ~PCLBase()
-      {
-        input_.reset ();
-        indices_.reset ();
-      }
+      virtual ~PCLBase () = default;
 
       /** \brief Provide a pointer to the input dataset
         * \param cloud the const boost shared pointer to a PointCloud message
index b512dad569584eacfda08fe2f8ffa4ced58ae733..f888583a8ca1766d5dedc672e3a660eed7d9fef6 100644 (file)
@@ -56,7 +56,7 @@
 #endif
 
 #ifndef _USE_MATH_DEFINES
-#define _USE_MATH_DEFINES
+  #define _USE_MATH_DEFINES
 #endif
 #include <cmath>
 #include <cstdarg>
 #include <cstdint>
 #include <iostream>
 
-#include <boost/cstdint.hpp>
-#include <boost/smart_ptr/shared_ptr.hpp>
-
-//Eigen has an enum that clashes with X11 Success define, which is ultimately included by pcl
-#ifdef Success
-  #undef Success
+// We need to check for GCC version, because GCC releases before 9 were implementing an
+// OpenMP 3.1 data sharing rule, even OpenMP 4 is supported, so a plain OpenMP version 4 check
+// isn't enough (see https://www.gnu.org/software/gcc/gcc-9/porting_to.html#ompdatasharing)
+#if (defined _OPENMP && (_OPENMP <= 201307)) || (defined __GNUC__ && (__GNUC__ >= 6 && __GNUC__ < 9))
+  #define OPENMP_LEGACY_CONST_DATA_SHARING_RULE 1
+#else
+  #define OPENMP_LEGACY_CONST_DATA_SHARING_RULE 0
 #endif
-#include <Eigen/Core>
 
 #include <pcl/pcl_config.h>
 
-// It seems that __has_cpp_attribute doesn't work correctly
-// when compiling with some versions of nvcc so we
-// additionally check if nvcc is used before setting the
-// PCL_DEPRECATED macro to [[deprecated]].
-#if defined(__has_cpp_attribute) && __has_cpp_attribute(deprecated) && !defined(__CUDACC__)
-  #define PCL_DEPRECATED(message) [[deprecated(message)]]
-#elif defined(__GNUC__) || defined(__clang__)
-  #define PCL_DEPRECATED(message) __attribute__((deprecated(message)))
-#elif defined(_MSC_VER)
-  // Until Visual Studio 2013 you had to use __declspec(deprecated).
-  // However, we decided to ignore the deprecation for these version because
-  // of simplicity reasons. See PR #3634 for the details.
-  #define PCL_DEPRECATED(message)
+#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/preprocessor/control/if.hpp>
+#include <boost/preprocessor/stringize.hpp>
+
+// MSVC < 2019 have issues:
+// * can't short-circuiting logic in macros
+// * don't define standard macros
+// => this leads to annyoing C4067 warnings (see https://developercommunity.visualstudio.com/content/problem/327796/-has-cpp-attribute-emits-warning-is-wrong-highligh.html)
+#if defined(_MSC_VER)
+  // nvcc on msvc can't work with [[deprecated]]
+  #if !defined(__CUDACC__)
+    #define _PCL_DEPRECATED_IMPL(Message) [[deprecated(Message)]]
+  #else
+    #define _PCL_DEPRECATED_IMPL(Message)
+  #endif
+#elif __has_cpp_attribute(deprecated)
+  #define _PCL_DEPRECATED_IMPL(Message) [[deprecated(Message)]]
 #else
-  #warning "You need to implement PCL_DEPRECATED for this compiler"
-  #define PCL_DEPRECATED(message)
+  #warning "You need to implement _PCL_DEPRECATED_IMPL for this compiler"
+  #define _PCL_DEPRECATED_IMPL(Message)
 #endif
 
-namespace pcl
-{
-  /**
-   * \brief Alias for boost::shared_ptr
-   *
-   * For ease of switching from boost::shared_ptr to std::shared_ptr
-   *
-   * \see pcl::make_shared
-   * \tparam T Type of the object stored inside the shared_ptr
-   */
-  template <typename T>
-  using shared_ptr = boost::shared_ptr<T>;
-
-  using uint8_t PCL_DEPRECATED("use std::uint8_t instead of pcl::uint8_t") = std::uint8_t;
-  using int8_t PCL_DEPRECATED("use std::int8_t instead of pcl::int8_t") = std::int8_t;
-  using uint16_t PCL_DEPRECATED("use std::uint16_t instead of pcl::uint16_t") = std::uint16_t;
-  using int16_t PCL_DEPRECATED("use std::uint16_t instead of pcl::int16_t") = std::int16_t;
-  using uint32_t PCL_DEPRECATED("use std::uint32_t instead of pcl::uint32_t") = std::uint32_t;
-  using int32_t PCL_DEPRECATED("use std::int32_t instead of pcl::int32_t") = std::int32_t;
-  using uint64_t PCL_DEPRECATED("use std::uint64_t instead of pcl::uint64_t") = std::uint64_t;
-  using int64_t PCL_DEPRECATED("use std::int64_t instead of pcl::int64_t") = std::int64_t;
-  using int_fast16_t PCL_DEPRECATED("use std::int_fast16_t instead of pcl::int_fast16_t") = std::int_fast16_t;
-}
+// Macro for pragma operator
+#if (defined (__GNUC__) || defined(__clang__))
+  #define PCL_PRAGMA(x) _Pragma (#x)
+#elif _MSC_VER
+  #define PCL_PRAGMA(x) __pragma (#x)
+#else
+  #define PCL_PRAGMA
+#endif
+
+// Macro for emitting pragma warning for deprecated headers
+#if (defined (__GNUC__) || defined(__clang__))
+  #define _PCL_DEPRECATED_HEADER_IMPL(Message) PCL_PRAGMA (GCC warning Message)
+#elif _MSC_VER
+  #define _PCL_DEPRECATED_HEADER_IMPL(Message) PCL_PRAGMA (warning (Message))
+#else
+  #warning "You need to implement _PCL_DEPRECATED_HEADER_IMPL for this compiler"
+  #define _PCL_DEPRECATED_HEADER_IMPL(Message)
+#endif
 
-#if defined _WIN32 && defined _MSC_VER
+/**
+ * \brief A handy way to inform the user of the removal deadline
+ */
+#define _PCL_PREPARE_REMOVAL_MESSAGE(Major, Minor, Msg)                                 \
+  Msg " (It will be removed in PCL " BOOST_PP_STRINGIZE(Major.Minor) ")"
 
+/**
+ * \brief Tests for Minor < PCL_MINOR_VERSION
+ */
+#define _PCL_COMPAT_MINOR_VERSION(Minor, IfPass, IfFail)                                \
+  BOOST_PP_IF(BOOST_PP_LESS(PCL_MINOR_VERSION, Minor), IfPass, IfFail)
+
+/**
+ * \brief Tests for Major == PCL_MAJOR_VERSION
+ */
+#define _PCL_COMPAT_MAJOR_VERSION(Major, IfPass, IfFail)                                \
+  BOOST_PP_IF(BOOST_PP_EQUAL(PCL_MAJOR_VERSION, Major), IfPass, IfFail)
+
+/**
+ * \brief macro for compatibility across compilers and help remove old deprecated
+ *        items for the Major.Minor release
+ *
+ * \details compiler errors of `unneeded_deprecation` and `major_version_mismatch`
+ * are hints to the developer that those items can be safely removed.
+ * Behavior of PCL_DEPRECATED(1, 99, "Not needed anymore")
+ *   * till PCL 1.98: "Not needed anymore (It will be removed in PCL 1.99)"
+ *   * PCL 1.99 onwards: compiler error with "unneeded_deprecation"
+ *   * PCL 2.0 onwards: compiler error with "major_version_mismatch"
+ */
+#define PCL_DEPRECATED(Major, Minor, Message)                                          \
+  _PCL_COMPAT_MAJOR_VERSION(                                                           \
+      Major,                                                                           \
+      _PCL_COMPAT_MINOR_VERSION(                                                       \
+          Minor,                                                                       \
+          _PCL_DEPRECATED_IMPL(_PCL_PREPARE_REMOVAL_MESSAGE(Major, Minor, Message)),   \
+          unneeded_deprecation),                                                       \
+      major_version_mismatch)
+
+/**
+ * \brief macro for compatibility across compilers and help remove old deprecated
+ *        headers for the Major.Minor release
+ *
+ * \details compiler errors of `unneeded_header` and `major_version_mismatch`
+ * are hints to the developer that those items can be safely removed.
+ * Behavior of PCL_DEPRECATED_HEADER(1, 99, "Use file <newfile.h> instead.")
+ *   * till PCL 1.98: "This header is deprecated. Use file <newfile.h> instead. (It will be removed in PCL 1.99)"
+ *   * PCL 1.99 onwards: compiler error with "unneeded_header"
+ *   * PCL 2.0 onwards: compiler error with "major_version_mismatch"
+ */
+#define PCL_DEPRECATED_HEADER(Major, Minor, Message)                                   \
+  _PCL_COMPAT_MAJOR_VERSION(                                                           \
+      Major,                                                                           \
+      _PCL_COMPAT_MINOR_VERSION(                                                       \
+          Minor,                                                                       \
+          _PCL_DEPRECATED_HEADER_IMPL(_PCL_PREPARE_REMOVAL_MESSAGE(                    \
+              Major,                                                                   \
+              Minor,                                                                   \
+              "This header is deprecated. " Message)),                                 \
+          unneeded_header),                                                            \
+      major_version_mismatch)
+
+#if defined _WIN32
 // Define math constants, without including math.h, to prevent polluting global namespace with old math methods
 // Copied from math.h
-#ifndef _MATH_DEFINES_DEFINED
+// Check for M_2_SQRTPI since the cmath header on mingw-w64 doesn't seem to define
+// _MATH_DEFINES_DEFINED when included with _USE_MATH_DEFINES
+#if !defined _MATH_DEFINES_DEFINED && !defined M_2_SQRTPI
   #define _MATH_DEFINES_DEFINED
 
   #define M_E        2.71828182845904523536   // e
@@ -140,27 +202,28 @@ namespace pcl
   #define M_SQRT1_2  0.707106781186547524401  // 1/sqrt(2)
 #endif
 
-// Stupid. This should be removed when all the PCL dependencies have min/max fixed.
-#ifndef NOMINMAX
-# define NOMINMAX
-#endif
-
-# define __PRETTY_FUNCTION__ __FUNCTION__
-# define __func__ __FUNCTION__
+#if defined _MSC_VER
+  // Stupid. This should be removed when all the PCL dependencies have min/max fixed.
+  #ifndef NOMINMAX
+    #define NOMINMAX
+  #endif
 
-#endif //defined _WIN32 && defined _MSC_VER
+  #define __PRETTY_FUNCTION__ __FUNCTION__
+  #define __func__ __FUNCTION__
+#endif
+#endif // defined _WIN32
 
 
 template<typename T>
-PCL_DEPRECATED("use std::isnan instead of pcl_isnan")
+PCL_DEPRECATED(1, 12, "use std::isnan instead of pcl_isnan")
 bool pcl_isnan (T&& x) { return std::isnan (std::forward<T> (x)); }
 
 template<typename T>
-PCL_DEPRECATED("use std::isfinite instead of pcl_isfinite")
+PCL_DEPRECATED(1, 12, "use std::isfinite instead of pcl_isfinite")
 bool pcl_isfinite (T&& x) { return std::isfinite (std::forward<T> (x)); }
 
 template<typename T>
-PCL_DEPRECATED("use std::isinf instead of pcl_isinf")
+PCL_DEPRECATED(1, 12, "use std::isinf instead of pcl_isinf")
 bool pcl_isinf (T&& x) { return std::isinf (std::forward<T> (x)); }
 
 
@@ -283,24 +346,6 @@ pcl_round (float number)
     #define PCLAPI(rettype) PCL_EXTERN_C PCL_EXPORTS rettype PCL_CDECL
 #endif
 
-// Macro for pragma operator
-#if (defined (__GNUC__) || defined(__clang__))
-  #define PCL_PRAGMA(x) _Pragma (#x)
-#elif _MSC_VER
-  #define PCL_PRAGMA(x) __pragma (#x)
-#else
-  #define PCL_PRAGMA
-#endif
-
-// Macro for emitting pragma warning
-#if (defined (__GNUC__) || defined(__clang__))
-  #define PCL_PRAGMA_WARNING(x) PCL_PRAGMA (GCC warning x)
-#elif _MSC_VER
-  #define PCL_PRAGMA_WARNING(x) PCL_PRAGMA (warning (x))
-#else
-  #define PCL_PRAGMA_WARNING
-#endif
-
 //for clang cf. http://clang.llvm.org/docs/LanguageExtensions.html
 #ifndef __has_extension
   #define __has_extension(x) 0 // Compatibility with pre-3.0 compilers.
@@ -377,19 +422,6 @@ aligned_free (void* ptr)
 #endif
 }
 
-/**
- * \brief Macro to signal a class requires a custom allocator
- *
- *  It's an implementation detail to have pcl::has_custom_allocator work, a
- *  thin wrapper over Eigen's own macro
- *
- * \see pcl::has_custom_allocator, pcl::make_shared
- * \ingroup common
- */
-#define PCL_MAKE_ALIGNED_OPERATOR_NEW \
-  EIGEN_MAKE_ALIGNED_OPERATOR_NEW \
-  using _custom_allocator_type_trait = void;
-
 /**
  * \brief Macro to add a no-op or a fallthrough attribute based on compiler feature
  *
index b6e8266c703c0b3a9f42c905c1cfbe9b7abab3c1..7462ee4ef965637ea38768e5b0bed88b32d9c4a1 100644 (file)
 #include <Eigen/Geometry>
 #include <pcl/PCLHeader.h>
 #include <pcl/exceptions.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
-#include <pcl/point_traits.h>
-
-#include <pcl/make_shared.h>
+#include <pcl/type_traits.h>
 
 #include <algorithm>
 #include <utility>
@@ -138,7 +137,7 @@ namespace pcl
   namespace detail
   {
     template <typename PointT>
-    PCL_DEPRECATED("use createMapping() instead")
+    PCL_DEPRECATED(1, 12, "use createMapping() instead")
     shared_ptr<pcl::MsgFieldMap>&
     getMapping (pcl::PointCloud<PointT>& p);
   } // namespace detail
@@ -186,6 +185,20 @@ namespace pcl
         */
       PointCloud () = default;
 
+      /** \brief Copy constructor.
+        * \param[in] pc the cloud to copy into this
+        * \todo Erase once mapping_ is removed.
+        */
+      // Ignore unknown pragma warning on MSVC (4996)
+      #pragma warning(push)
+      #pragma warning(disable: 4068)
+      // Ignore deprecated warning on clang compilers
+      #pragma clang diagnostic push
+      #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+      PointCloud (const PointCloud<PointT> &pc) = default;
+      #pragma clang diagnostic pop
+      #pragma warning(pop)
+
       /** \brief Copy constructor from point cloud subset
         * \param[in] pc the cloud to copy into this
         * \param[in] indices the subset to copy
@@ -321,7 +334,6 @@ namespace pcl
       }
 
       /** \brief Return an Eigen MatrixXf (assumes float values) mapped to the specified dimensions of the PointCloud.
-        * \anchor getMatrixXfMap
         * \note This method is for advanced users only! Use with care!
         *
         * \attention Since 1.4.0, Eigen matrices are forced to Row Major to increase the efficiency of the algorithms in PCL
@@ -345,7 +357,6 @@ namespace pcl
       }
 
       /** \brief Return an Eigen MatrixXf (assumes float values) mapped to the specified dimensions of the PointCloud.
-        * \anchor getMatrixXfMap
         * \note This method is for advanced users only! Use with care!
         *
         * \attention Since 1.4.0, Eigen matrices are forced to Row Major to increase the efficiency of the algorithms in PCL
@@ -368,22 +379,24 @@ namespace pcl
           return (Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(const_cast<PointT*>(&points[0]))+offset, dim, points.size (), Eigen::OuterStride<> (stride)));
       }
 
-      /** \brief Return an Eigen MatrixXf (assumes float values) mapped to the PointCloud.
-        * \note This method is for advanced users only! Use with care!
-        * \attention PointT types are most of the time aligned, so the offsets are not continuous!
-        * See \ref getMatrixXfMap for more information.
-        */
+      /**
+       * \brief Return an Eigen MatrixXf (assumes float values) mapped to the PointCloud.
+       * \note This method is for advanced users only! Use with care!
+       * \attention PointT types are most of the time aligned, so the offsets are not continuous!
+       * \overload Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > pcl::PointCloud::getMatrixXfMap ()
+       */
       inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
       getMatrixXfMap ()
       {
         return (getMatrixXfMap (sizeof (PointT) / sizeof (float),  sizeof (PointT) / sizeof (float), 0));
       }
 
-      /** \brief Return an Eigen MatrixXf (assumes float values) mapped to the PointCloud.
-        * \note This method is for advanced users only! Use with care!
-        * \attention PointT types are most of the time aligned, so the offsets are not continuous!
-        * See \ref getMatrixXfMap for more information.
-        */
+      /**
+       * \brief Return an Eigen MatrixXf (assumes float values) mapped to the PointCloud.
+       * \note This method is for advanced users only! Use with care!
+       * \attention PointT types are most of the time aligned, so the offsets are not continuous!
+       * \overload const Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > pcl::PointCloud::getMatrixXfMap () const
+       */
       inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
       getMatrixXfMap () const
       {
@@ -605,8 +618,10 @@ namespace pcl
       makeShared () const { return Ptr (new PointCloud<PointT> (*this)); }
 
     protected:
-      // This is motivated by ROS integration. Users should not need to access mapping_.
-      PCL_DEPRECATED("rewrite your code to avoid using this protected field") shared_ptr<MsgFieldMap> mapping_;
+      /** \brief This is motivated by ROS integration. Users should not need to access mapping_.
+        * \todo Once mapping_ is removed, erase the explicitly defined copy constructor in PointCloud.
+        */
+      PCL_DEPRECATED(1, 12, "rewrite your code to avoid using this protected field") shared_ptr<MsgFieldMap> mapping_;
 
       friend shared_ptr<MsgFieldMap>& detail::getMapping<PointT>(pcl::PointCloud<PointT> &p);
 
index 0a24ad82891eddac9b8b2496150ce112f407b3a9..4bcabcfd1f2596f9ea72953694e7f4744fe9b641 100644 (file)
@@ -43,6 +43,7 @@
 #include <vector>
 
 #include <pcl/point_types.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/for_each_type.h>
 
index 1ff6235e85e20e6f653bb7474f4a6dda806724e0..f29592a552931619c41d473f6755afeb4d3009df 100644 (file)
 
 #pragma once
 
-#ifdef __GNUC__
-#pragma GCC system_header
-#endif
+PCL_DEPRECATED_HEADER(1, 13, "Use <pcl/type_traits.h> instead.")
 
-#include "pcl/pcl_macros.h"
-
-#include <pcl/PCLPointField.h>
-#include <boost/mpl/assert.hpp>
-
-// This is required for the workaround at line 109
-#ifdef _MSC_VER
-#include <Eigen/Core>
-#include <Eigen/src/StlSupport/details.h>
-#endif
-
-#include <type_traits>
-
-namespace pcl
-{
-  namespace deprecated
-  {
-    /** \class DeprecatedType
-    * \brief A dummy type to aid in template parameter deprecation
-    */
-    struct T {};
-  }
-
-  namespace fields
-  {
-    // Tag types get put in this namespace
-  }
-
-  namespace traits
-  {
-    // Metafunction to return enum value representing a type
-    template<typename T> struct asEnum {};
-    template<> struct asEnum<std::int8_t>   { static const std::uint8_t value = pcl::PCLPointField::INT8;    };
-    template<> struct asEnum<std::uint8_t>  { static const std::uint8_t value = pcl::PCLPointField::UINT8;   };
-    template<> struct asEnum<std::int16_t>  { static const std::uint8_t value = pcl::PCLPointField::INT16;   };
-    template<> struct asEnum<std::uint16_t> { static const std::uint8_t value = pcl::PCLPointField::UINT16;  };
-    template<> struct asEnum<std::int32_t>  { static const std::uint8_t value = pcl::PCLPointField::INT32;   };
-    template<> struct asEnum<std::uint32_t> { static const std::uint8_t value = pcl::PCLPointField::UINT32;  };
-    template<> struct asEnum<float>    { static const std::uint8_t value = pcl::PCLPointField::FLOAT32; };
-    template<> struct asEnum<double>   { static const std::uint8_t value = pcl::PCLPointField::FLOAT64; };
-
-    // Metafunction to return type of enum value
-    template<int> struct asType {};
-    template<> struct asType<pcl::PCLPointField::INT8>    { using type = std::int8_t; };
-    template<> struct asType<pcl::PCLPointField::UINT8>   { using type = std::uint8_t; };
-    template<> struct asType<pcl::PCLPointField::INT16>   { using type = std::int16_t; };
-    template<> struct asType<pcl::PCLPointField::UINT16>  { using type = std::uint16_t; };
-    template<> struct asType<pcl::PCLPointField::INT32>   { using type = std::int32_t; };
-    template<> struct asType<pcl::PCLPointField::UINT32>  { using type = std::uint32_t; };
-    template<> struct asType<pcl::PCLPointField::FLOAT32> { using type = float; };
-    template<> struct asType<pcl::PCLPointField::FLOAT64> { using type = double; };
-
-    // Metafunction to decompose a type (possibly of array of any number of dimensions) into
-    // its scalar type and total number of elements.
-    template<typename T> struct decomposeArray
-    {
-      using type = std::remove_all_extents_t<T>;
-      static const std::uint32_t value = sizeof (T) / sizeof (type);
-    };
-
-    // For non-POD point types, this is specialized to return the corresponding POD type.
-    template<typename PointT>
-    struct POD
-    {
-      using type = PointT;
-    };
-
-#ifdef _MSC_VER
-
-    /* Sometimes when calling functions like `copyPoint()` or `copyPointCloud`
-     * without explicitly specifying point types, MSVC deduces them to be e.g.
-     * `Eigen::internal::workaround_msvc_stl_support<pcl::PointXYZ>` instead of
-     * plain `pcl::PointXYZ`. Subsequently these types are passed to meta-
-     * functions like `has_field` or `fieldList` and make them choke. This hack
-     * makes use of the fact that internally `fieldList` always applies `POD` to
-     * its argument type. This specialization therefore allows to unwrap the
-     * contained point type. */
-    template<typename PointT>
-    struct POD<Eigen::internal::workaround_msvc_stl_support<PointT> >
-    {
-      using type = PointT;
-    };
-
-#endif
-
-    // name
-    /* This really only depends on Tag, but we go through some gymnastics to avoid ODR violations.
-       We template it on the point type PointT to avoid ODR violations when registering multiple
-       point types with shared tags.
-       The dummy parameter is so we can partially specialize name on PointT and Tag but leave it
-       templated on dummy. Each specialization declares a static char array containing the tag
-       name. The definition of the static member would conflict when linking multiple translation
-       units that include the point type registration. But when the static member definition is
-       templated (on dummy), we sidestep the ODR issue.
-    */
-    template<class PointT, typename Tag, int dummy = 0>
-    struct name : name<typename POD<PointT>::type, Tag, dummy>
-    {
-      // Contents of specialization:
-      // static const char value[];
-
-      // Avoid infinite compile-time recursion
-      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
-                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
-    };
-
-    // offset
-    template<class PointT, typename Tag>
-    struct offset : offset<typename POD<PointT>::type, Tag>
-    {
-      // Contents of specialization:
-      // static const std::size_t value;
-
-      // Avoid infinite compile-time recursion
-      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
-                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
-    };
-
-    // datatype
-    template<class PointT, typename Tag>
-    struct datatype : datatype<typename POD<PointT>::type, Tag>
-    {
-      // Contents of specialization:
-      // using type = ...;
-      // static const std::uint8_t value;
-      // static const std::uint32_t size;
-
-      // Avoid infinite compile-time recursion
-      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
-                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
-    };
-
-    // fields
-    template<typename PointT>
-    struct fieldList : fieldList<typename POD<PointT>::type>
-    {
-      // Contents of specialization:
-      // using type = boost::mpl::vector<...>;
-
-      // Avoid infinite compile-time recursion
-      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
-                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
-    };
-  } //namespace traits
-
-  // Return true if the PCLPointField matches the expected name and data type.
-  // Written as a struct to allow partially specializing on Tag.
-  template<typename PointT, typename Tag>
-  struct FieldMatches
-  {
-    bool operator() (const pcl::PCLPointField& field)
-    {
-      return (field.name == traits::name<PointT, Tag>::value &&
-              field.datatype == traits::datatype<PointT, Tag>::value &&
-              (field.count == traits::datatype<PointT, Tag>::size ||
-               ((field.count == 0) && (traits::datatype<PointT, Tag>::size == 1 /* see bug #821 */))));
-    }
-  };
-
-  /** \brief A helper functor that can copy a specific value if the given field exists.
-    *
-    * \note In order to actually copy the value an instance of this functor should be passed
-    * to a pcl::for_each_type loop. See the example below.
-    *
-    * \code
-    * PointInT p;
-    * bool exists;
-    * float value;
-    * using FieldList = typename pcl::traits::fieldList<PointInT>::type;
-    * pcl::for_each_type<FieldList> (pcl::CopyIfFieldExists<PointT, float> (p, "intensity", exists, value));
-    * \endcode
-    */
-  template <typename PointInT, typename OutT>
-  struct CopyIfFieldExists
-  {
-    using Pod = typename traits::POD<PointInT>::type;
-
-    /** \brief Constructor.
-      * \param[in] pt the input point
-      * \param[in] field the name of the field
-      * \param[out] exists set to true if the field exists, false otherwise
-      * \param[out] value the copied field value
-      */
-    CopyIfFieldExists (const PointInT &pt,
-                       const std::string &field,
-                       bool &exists,
-                       OutT &value)
-      : pt_ (reinterpret_cast<const Pod&>(pt)), name_ (field), exists_ (exists), value_ (value)
-    {
-      exists_ = false;
-    }
-
-    /** \brief Constructor.
-      * \param[in] pt the input point
-      * \param[in] field the name of the field
-      * \param[out] value the copied field value
-      */
-    CopyIfFieldExists (const PointInT &pt,
-                       const std::string &field,
-                       OutT &value)
-      : pt_ (reinterpret_cast<const Pod&>(pt)), name_ (field), exists_ (exists_tmp_), value_ (value)
-    {
-    }
-
-    /** \brief Operator. Data copy happens here. */
-    template <typename Key> inline void
-    operator() ()
-    {
-      if (name_ == pcl::traits::name<PointInT, Key>::value)
-      {
-        exists_ = true;
-        using T = typename pcl::traits::datatype<PointInT, Key>::type;
-        const std::uint8_t* data_ptr = reinterpret_cast<const std::uint8_t*>(&pt_) + pcl::traits::offset<PointInT, Key>::value;
-        value_ = static_cast<OutT> (*reinterpret_cast<const T*>(data_ptr));
-      }
-    }
-
-    private:
-      const Pod &pt_;
-      const std::string &name_;
-      bool &exists_;
-      // Bogus entry
-      bool exists_tmp_;
-      OutT &value_;
-  };
-
-  /** \brief A helper functor that can set a specific value in a field if the field exists.
-    *
-    * \note In order to actually set the value an instance of this functor should be passed
-    * to a pcl::for_each_type loop. See the example below.
-    *
-    * \code
-    * PointT p;
-    * using FieldList = typename pcl::traits::fieldList<PointT>::type;
-    * pcl::for_each_type<FieldList> (pcl::SetIfFieldExists<PointT, float> (p, "intensity", 42.0f));
-    * \endcode
-    */
-  template <typename PointOutT, typename InT>
-  struct SetIfFieldExists
-  {
-    using Pod = typename traits::POD<PointOutT>::type;
-
-    /** \brief Constructor.
-      * \param[in] pt the input point
-      * \param[in] field the name of the field
-      * \param[out] value the value to set
-      */
-    SetIfFieldExists (PointOutT &pt,
-                      const std::string &field,
-                      const InT &value)
-      : pt_ (reinterpret_cast<Pod&>(pt)), name_ (field), value_ (value)
-    {
-    }
-
-    /** \brief Operator. Data copy happens here. */
-    template <typename Key> inline void
-    operator() ()
-    {
-      if (name_ == pcl::traits::name<PointOutT, Key>::value)
-      {
-        using T = typename pcl::traits::datatype<PointOutT, Key>::type;
-        std::uint8_t* data_ptr = reinterpret_cast<std::uint8_t*>(&pt_) + pcl::traits::offset<PointOutT, Key>::value;
-        *reinterpret_cast<T*>(data_ptr) = static_cast<T> (value_);
-      }
-    }
-
-    private:
-      Pod &pt_;
-      const std::string &name_;
-      const InT &value_;
-  };
-
-  /** \brief Set the value at a specified field in a point
-    * \param[out] pt the point to set the value to
-    * \param[in] field_offset the offset of the field
-    * \param[in] value the value to set
-    */
-  template <typename PointT, typename ValT> inline void
-  setFieldValue (PointT &pt, std::size_t field_offset, const ValT &value)
-  {
-    std::uint8_t* data_ptr = reinterpret_cast<std::uint8_t*>(&pt) + field_offset;
-    *reinterpret_cast<ValT*>(data_ptr) = value;
-  }
-
-  /** \brief Get the value at a specified field in a point
-    * \param[in] pt the point to get the value from
-    * \param[in] field_offset the offset of the field
-    * \param[out] value the value to retrieve
-    */
-  template <typename PointT, typename ValT> inline void
-  getFieldValue (const PointT &pt, std::size_t field_offset, ValT &value)
-  {
-    const std::uint8_t* data_ptr = reinterpret_cast<const std::uint8_t*>(&pt) + field_offset;
-    value = *reinterpret_cast<const ValT*>(data_ptr);
-  }
-
-  template <typename ...> using void_t = void; // part of std in c++17
-
-#ifdef DOXYGEN_ONLY
-
-  /**
-   * \brief Tests at compile time if type T has a custom allocator
-   *
-   * \see pcl::make_shared, PCL_MAKE_ALIGNED_OPERATOR_NEW
-   * \tparam T Type of the object to test
-   */
-  template <typename T> struct has_custom_allocator;
-
-#else
-
-  template <typename, typename = void_t<>> struct has_custom_allocator : std::false_type {};
-  template <typename T> struct has_custom_allocator<T, void_t<typename T::_custom_allocator_type_trait>> : std::true_type {};
-
-#endif
-}
+#include <pcl/type_traits.h>
index 02c4d2bb196ffaab560f445f038a5d0a825a32c0..1d47ba2edb080b1445e1f8f94e1fdf9e0019c6cf 100644 (file)
 
 #pragma once
 
-#include <pcl/pcl_macros.h>
 #include <bitset>
-#include <pcl/register_point_struct.h>
-#include <boost/mpl/contains.hpp>
-#include <boost/mpl/fold.hpp>
-#include <boost/mpl/vector.hpp>
+
 
 /**
   * \file pcl/point_types.h
   * \ingroup common
   */
 
-// We're doing a lot of black magic with Boost here, so disable warnings in Maintainer mode, as we will never
-// be able to fix them anyway
+// Allow nameless structs/unions
 #if defined _MSC_VER
   #pragma warning(disable: 4201)
 #endif
-//#pragma warning(push, 1)
-#if defined __GNUC__
-#  pragma GCC system_header
-#endif
 
 /** @{*/
 namespace pcl
@@ -259,17 +250,17 @@ namespace pcl
     * \ingroup common
     */
   struct FPFHSignature33;
-  
+
   /** \brief Members: float vfh[308]
     * \ingroup common
     */
   struct VFHSignature308;
-  
+
   /** \brief Members: float grsd[21]
     * \ingroup common
     */
   struct GRSDSignature21;
-  
+
   /** \brief Members: float esf[640]
     * \ingroup common
     */
@@ -352,563 +343,7 @@ namespace pcl
     * \ingroup common
     */
   struct PointDEM;
-}
-
-/** @} */
-
-#include <pcl/impl/point_types.hpp>  // Include struct definitions
-
-// ==============================
-// =====POINT_CLOUD_REGISTER=====
-// ==============================
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_RGB,
-    (std::uint32_t, rgba, rgba)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::RGB, pcl::_RGB)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Intensity,
-    (float, intensity, intensity)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Intensity, pcl::_Intensity)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Intensity8u,
-    (std::uint8_t, intensity, intensity)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Intensity8u, pcl::_Intensity8u)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Intensity32u,
-    (std::uint32_t, intensity, intensity)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Intensity32u, pcl::_Intensity32u)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZ,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZ, pcl::_PointXYZ)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBA,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (std::uint32_t, rgba, rgba)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBA, pcl::_PointXYZRGBA)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGB,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, rgb, rgb)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGB, pcl::_PointXYZRGB)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBL,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (std::uint32_t, rgba, rgba)
-    (std::uint32_t, label, label)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBL, pcl::_PointXYZRGBL)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZHSV,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, h, h)
-    (float, s, s)
-    (float, v, v)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZHSV, pcl::_PointXYZHSV)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXY,
-    (float, x, x)
-    (float, y, y)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointUV,
-    (float, u, u)
-    (float, v, v)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::InterestPoint,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, strength, strength)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZI,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, intensity, intensity)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZI, pcl::_PointXYZI)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZL,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (std::uint32_t, label, label)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Label,
-    (std::uint32_t, label, label)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Normal,
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-    (float, curvature, curvature)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Normal, pcl::_Normal)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_Axis,
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::Axis, pcl::_Axis)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointNormal,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-    (float, curvature, curvature)
-)
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBNormal,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, rgb, rgb)
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-    (float, curvature, curvature)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBNormal, pcl::_PointXYZRGBNormal)
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZINormal,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, intensity, intensity)
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-    (float, curvature, curvature)
-)
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZLNormal,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (std::uint32_t, label, label)
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-    (float, curvature, curvature)
-)
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointWithRange,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, range, range)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointWithViewpoint,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, vp_x, vp_x)
-    (float, vp_y, vp_y)
-    (float, vp_z, vp_z)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointWithViewpoint, pcl::_PointWithViewpoint)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::MomentInvariants,
-    (float, j1, j1)
-    (float, j2, j2)
-    (float, j3, j3)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalRadiiRSD,
-    (float, r_min, r_min)
-    (float, r_max, r_max)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Boundary,
-    (std::uint8_t, boundary_point, boundary_point)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalCurvatures,
-    (float, principal_curvature_x, principal_curvature_x)
-    (float, principal_curvature_y, principal_curvature_y)
-    (float, principal_curvature_z, principal_curvature_z)
-    (float, pc1, pc1)
-    (float, pc2, pc2)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHSignature125,
-    (float[125], histogram, pfh)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHRGBSignature250,
-    (float[250], histogram, pfhrgb)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFSignature,
-    (float, f1, f1)
-    (float, f2, f2)
-    (float, f3, f3)
-    (float, f4, f4)
-    (float, alpha_m, alpha_m)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::CPPFSignature,
-    (float, f1, f1)
-    (float, f2, f2)
-    (float, f3, f3)
-    (float, f4, f4)
-    (float, f5, f5)
-    (float, f6, f6)
-    (float, f7, f7)
-    (float, f8, f8)
-    (float, f9, f9)
-    (float, f10, f10)
-    (float, alpha_m, alpha_m)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFRGBSignature,
-    (float, f1, f1)
-    (float, f2, f2)
-    (float, f3, f3)
-    (float, f4, f4)
-    (float, r_ratio, r_ratio)
-    (float, g_ratio, g_ratio)
-    (float, b_ratio, b_ratio)
-    (float, alpha_m, alpha_m)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::NormalBasedSignature12,
-    (float[12], values, values)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ShapeContext1980,
-    (float[1980], descriptor, shape_context)
-    (float[9], rf, rf)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::UniqueShapeContext1960,
-    (float[1960], descriptor, shape_context)
-    (float[9], rf, rf)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT352,
-    (float[352], descriptor, shot)
-    (float[9], rf, rf)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT1344,
-    (float[1344], descriptor, shot)
-    (float[9], rf, rf)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::FPFHSignature33,
-    (float[33], histogram, fpfh)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::BRISKSignature512,
-    (float, scale, brisk_scale)
-    (float, orientation, brisk_orientation)
-    (unsigned char[64], descriptor, brisk_descriptor512)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::VFHSignature308,
-    (float[308], histogram, vfh)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::GRSDSignature21,
-    (float[21], histogram, grsd)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ESFSignature640,
-    (float[640], histogram, esf)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::GASDSignature512,
-    (float[512], histogram, gasd)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::GASDSignature984,
-    (float[984], histogram, gasd)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::GASDSignature7992,
-    (float[7992], histogram, gasd)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Narf36,
-    (float[36], descriptor, descriptor)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::GFPFHSignature16,
-    (float[16], histogram, gfpfh)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::IntensityGradient,
-    (float, gradient_x, gradient_x)
-    (float, gradient_y, gradient_y)
-    (float, gradient_z, gradient_z)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointWithScale,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, scale, scale)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::PointSurfel,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, normal_x, normal_x)
-    (float, normal_y, normal_y)
-    (float, normal_z, normal_z)
-    (std::uint32_t, rgba, rgba)
-    (float, radius, radius)
-    (float, confidence, confidence)
-    (float, curvature, curvature)
-)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_ReferenceFrame,
-    (float[3], x_axis, x_axis)
-    (float[3], y_axis, y_axis)
-    (float[3], z_axis, z_axis)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::ReferenceFrame, pcl::_ReferenceFrame)
-
-POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointDEM,
-    (float, x, x)
-    (float, y, y)
-    (float, z, z)
-    (float, intensity, intensity)
-    (float, intensity_variance, intensity_variance)
-    (float, height_variance, height_variance)
-)
-POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointDEM, pcl::_PointDEM)
-
-namespace pcl 
-{
-  // Allow float 'rgb' data to match to the newer uint32 'rgba' tag. This is so
-  // you can load old 'rgb' PCD files into e.g. a PointCloud<PointXYZRGBA>.
-  template<typename PointT>
-  struct FieldMatches<PointT, fields::rgba>
-  {
-    bool operator() (const pcl::PCLPointField& field)
-    {
-      if (field.name == "rgb")
-      {
-        // For fixing the alpha value bug #1141, the rgb field can also match
-        // uint32.
-        return ((field.datatype == pcl::PCLPointField::FLOAT32 ||
-                 field.datatype == pcl::PCLPointField::UINT32) &&
-                field.count == 1);
-      }
-      else
-      {
-        return (field.name == traits::name<PointT, fields::rgba>::value &&
-                field.datatype == traits::datatype<PointT, fields::rgba>::value &&
-                field.count == traits::datatype<PointT, fields::rgba>::size);
-      }
-    }
-  };
-  template<typename PointT>
-  struct FieldMatches<PointT, fields::rgb>
-  {
-    bool operator() (const pcl::PCLPointField& field)
-    {
-      if (field.name == "rgba")
-      {
-        return (field.datatype == pcl::PCLPointField::UINT32 &&
-                field.count == 1);
-      }
-      else
-      {
-        // For fixing the alpha value bug #1141, rgb can also match uint32
-        return (field.name == traits::name<PointT, fields::rgb>::value &&
-                (field.datatype == traits::datatype<PointT, fields::rgb>::value ||
-                 field.datatype == pcl::PCLPointField::UINT32) &&
-                field.count == traits::datatype<PointT, fields::rgb>::size);
-      }
-    }
-  };
-
-  namespace traits
-  {
-
-    /** \brief Metafunction to check if a given point type has a given field.
-     *
-     *  Example usage at run-time:
-     *
-     *  \code
-     *  bool curvature_available = pcl::traits::has_field<PointT, pcl::fields::curvature>::value;
-     *  \endcode
-     *
-     *  Example usage at compile-time:
-     *
-     *  \code
-     *  BOOST_MPL_ASSERT_MSG ((pcl::traits::has_field<PointT, pcl::fields::label>::value),
-     *                        POINT_TYPE_SHOULD_HAVE_LABEL_FIELD,
-     *                        (PointT));
-     *  \endcode
-     */
-    template <typename PointT, typename Field>
-    struct has_field : boost::mpl::contains<typename pcl::traits::fieldList<PointT>::type, Field>::type
-    { };
-
-    /** Metafunction to check if a given point type has all given fields. */
-    template <typename PointT, typename Field>
-    struct has_all_fields : boost::mpl::fold<Field,
-                                             boost::mpl::bool_<true>,
-                                             boost::mpl::and_<boost::mpl::_1,
-                                                              has_field<PointT, boost::mpl::_2> > >::type
-    { };
-
-    /** Metafunction to check if a given point type has any of the given fields. */
-    template <typename PointT, typename Field>
-    struct has_any_field : boost::mpl::fold<Field,
-                                            boost::mpl::bool_<false>,
-                                            boost::mpl::or_<boost::mpl::_1,
-                                                            has_field<PointT, boost::mpl::_2> > >::type
-    { };
-
-    /** \brief Traits defined for ease of use with fields already registered before
-     *
-     * has_<fields to be detected>: struct with `value` datamember defined at compiletime
-     * has_<fields to be detected>_v: constexpr boolean
-     * Has<Fields to be detected>: concept modelling name alias for `enable_if`
-     */
-
-    /** Metafunction to check if a given point type has x and y fields. */
-    template <typename PointT>
-    struct has_xy : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x,
-                                                              pcl::fields::y> >
-    { };
-
-    template <typename PointT>
-    constexpr auto has_xy_v = has_xy<PointT>::value;
-
-    template <typename PointT>
-    using HasXY = std::enable_if_t<has_xy_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoXY = std::enable_if_t<!has_xy_v<PointT>, bool>;
-
-    /** Metafunction to check if a given point type has x, y, and z fields. */
-    template <typename PointT>
-    struct has_xyz : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x,
-                                                               pcl::fields::y,
-                                                               pcl::fields::z> >
-    { };
-
-    template <typename PointT>
-    constexpr auto has_xyz_v = has_xyz<PointT>::value;
-
-    template <typename PointT>
-    using HasXYZ = std::enable_if_t<has_xyz_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoXYZ = std::enable_if_t<!has_xyz_v<PointT>, bool>;
-
-    /** Metafunction to check if a given point type has normal_x, normal_y, and
-      * normal_z fields. */
-    template <typename PointT>
-    struct has_normal : has_all_fields<PointT, boost::mpl::vector<pcl::fields::normal_x,
-                                                                  pcl::fields::normal_y,
-                                                                  pcl::fields::normal_z> >
-    { };
-
-    template <typename PointT>
-    constexpr auto has_normal_v = has_normal<PointT>::value;
-
-    template <typename PointT>
-    using HasNormal = std::enable_if_t<has_normal_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoNormal = std::enable_if_t<!has_normal_v<PointT>, bool>;
-
-    /** Metafunction to check if a given point type has curvature field. */
-    template <typename PointT>
-    struct has_curvature : has_field<PointT, pcl::fields::curvature>
-    { };
-
-    template <typename PointT>
-    constexpr auto has_curvature_v = has_curvature<PointT>::value;
-
-    template <typename PointT>
-    using HasCurvature = std::enable_if_t<has_curvature_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoCurvature = std::enable_if_t<!has_curvature_v<PointT>, bool>;
-
-    /** Metafunction to check if a given point type has intensity field. */
-    template <typename PointT>
-    struct has_intensity : has_field<PointT, pcl::fields::intensity>
-    { };
-
-    template <typename PointT>
-    constexpr auto has_intensity_v = has_intensity<PointT>::value;
-
-    template <typename PointT>
-    using HasIntensity = std::enable_if_t<has_intensity_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoIntensity = std::enable_if_t<!has_intensity_v<PointT>, bool>;
-
-    /** Metafunction to check if a given point type has either rgb or rgba field. */
-    template <typename PointT>
-    struct has_color : has_any_field<PointT, boost::mpl::vector<pcl::fields::rgb,
-                                                                pcl::fields::rgba> >
-    { };
-
-    template <typename PointT>
-    constexpr auto has_color_v = has_color<PointT>::value;
-
-    template <typename PointT>
-    using HasColor = std::enable_if_t<has_color_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoColor = std::enable_if_t<!has_color_v<PointT>, bool>;
-
-    /** Metafunction to check if a given point type has label field. */
-    template <typename PointT>
-    struct has_label : has_field<PointT, pcl::fields::label>
-    { };
-
-    template <typename PointT>
-    constexpr auto has_label_v = has_label<PointT>::value;
-
-    template <typename PointT>
-    using HasLabel = std::enable_if_t<has_label_v<PointT>, bool>;
-
-    template <typename PointT>
-    using HasNoLabel = std::enable_if_t<!has_label_v<PointT>, bool>;
-  }
-
 } // namespace pcl
+/** @} */
 
-// Not strictly required, merely to preserve API for PCL users < 1.4
-#include <pcl/common/point_tests.h>
-
-#if defined _MSC_VER
-  #pragma warning(default: 4201)
-#endif
-//#pragma warning(pop)
+#include <pcl/impl/point_types.hpp>
index cea6249a43e0f6ed90db52ce6995f3bab02eda05..0a0a979bfe3ccf3c02ac998721ba2afad1bd2731 100644 (file)
@@ -36,7 +36,7 @@
 
 /**
   * \file bearing_angle_image.h
-  * \Created on: July 07, 2012
+  * Created on: July 07, 2012
   */
 
 #pragma once
index 03f2ee8b11679b9a9af7569b8bef85a2a7a83c6e..70f80e397eac6c474384db95cab9e58855ec7f10 100644 (file)
  *
  */
 
-#ifndef PCL_RANGE_IMAGE_IMPL_HPP_
-#define PCL_RANGE_IMAGE_IMPL_HPP_
+#pragma once
+
+#include <pcl/range_image/range_image.h>
 
 #include <pcl/pcl_macros.h>
 #include <pcl/common/distances.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
 
 namespace pcl
 {
@@ -1250,6 +1253,4 @@ RangeImage::integrateFarRanges (const PointCloudType& far_ranges)
   }
 }
 
-}  // namespace end
-#endif
-
+}  // namespace pcl
index 30dda5d9818e914a087804cc1526f61a34518fa3..2bf58dc6233a0203d1a8810cc82ff37983170501 100644 (file)
  *
  */
 
-#ifndef PCL_RANGE_IMAGE_PLANAR_IMPL_HPP_
-#define PCL_RANGE_IMAGE_PLANAR_IMPL_HPP_
+#pragma once
 
-#include <pcl/pcl_macros.h>
 #include <pcl/common/eigen.h>
+#include <pcl/range_image/range_image_planar.h>
+#include <pcl/pcl_macros.h>
 
 namespace pcl
 {
@@ -116,7 +116,5 @@ RangeImagePlanar::getImagePoint (const Eigen::Vector3f& point, float& image_x, f
   image_y = center_y_ + focal_length_y_*transformedPoint[1]/transformedPoint[2] - static_cast<float> (image_offset_y_);
 }
 
-}  // namespace end
-
-#endif
+}  // namespace pcl
 
index 2c7857528f702df2e94c61edd7add103ef96c4cd..4d0677b2b2ca995dfd98c06064cda727f235d649 100644 (file)
  *
  */
 
-#include <pcl/pcl_macros.h>
+#pragma once
+
 #include <pcl/common/eigen.h>
+#include <pcl/range_image/range_image_spherical.h>
+#include <pcl/pcl_macros.h>
+
 
 namespace pcl
 {
@@ -75,4 +79,5 @@ RangeImageSpherical::getImagePointFromAngles (float angle_x, float angle_y, floa
   image_x = (angle_x + static_cast<float> (M_PI))*angular_resolution_x_reciprocal_ - static_cast<float> (image_offset_x_);
   image_y = (angle_y + 0.5f*static_cast<float> (M_PI))*angular_resolution_y_reciprocal_ - static_cast<float> (image_offset_y_);
 }
-}  // namespace end
+}  // namespace pcl
+
index 106188b7a435ea36a0c8a458e46176b9ed88ec85..49f460d0d48aaf46958bd8b0eb34b5c50f3b75d3 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/point_cloud.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
@@ -47,7 +48,7 @@
 namespace pcl
 {
   /** \brief RangeImage is derived from pcl/PointCloud and provides functionalities with focus on situations where
-    *  a 3D scene was captured from a specific view point. 
+    *  a 3D scene was captured from a specific view point.
     * \author Bastian Steder
     * \ingroup range_image
     */
@@ -59,24 +60,24 @@ namespace pcl
       using VectorOfEigenVector3f = std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> >;
       using Ptr = shared_ptr<RangeImage>;
       using ConstPtr = shared_ptr<const RangeImage>;
-      
+
       enum CoordinateFrame
       {
         CAMERA_FRAME = 0,
         LASER_FRAME  = 1
       };
 
-      
+
       // =====CONSTRUCTOR & DESTRUCTOR=====
       /** Constructor */
       PCL_EXPORTS RangeImage ();
       /** Destructor */
       PCL_EXPORTS virtual ~RangeImage () = default;
-      
+
       // =====STATIC VARIABLES=====
       /** The maximum number of openmp threads that can be used in this class */
       static int max_no_of_threads;
-      
+
       // =====STATIC METHODS=====
       /** \brief Get the size of a certain area when seen from the given pose
         * \param viewer_pose an affine matrix defining the pose of the viewer
@@ -85,16 +86,16 @@ namespace pcl
         * \return the size of the area as viewed according to \a viewer_pose
         */
       static inline float
-      getMaxAngleSize (const Eigen::Affine3f& viewer_pose, const Eigen::Vector3f& center, 
+      getMaxAngleSize (const Eigen::Affine3f& viewer_pose, const Eigen::Vector3f& center,
                        float radius);
-      
+
       /** \brief Get Eigen::Vector3f from PointWithRange
         * \param point the input point
         * \return an Eigen::Vector3f representation of the input point
         */
       static inline Eigen::Vector3f
       getEigenVector3f (const PointWithRange& point);
-      
+
       /** \brief Get the transformation that transforms the given coordinate frame into CAMERA_FRAME
         * \param coordinate_frame the input coordinate frame
         * \param transformation the resulting transformation that warps \a coordinate_frame into CAMERA_FRAME
@@ -102,31 +103,31 @@ namespace pcl
       PCL_EXPORTS static void
       getCoordinateFrameTransformation (RangeImage::CoordinateFrame coordinate_frame,
                                         Eigen::Affine3f& transformation);
-      
-      /** \brief Get the average viewpoint of a point cloud where each point carries viewpoint information as 
+
+      /** \brief Get the average viewpoint of a point cloud where each point carries viewpoint information as
         * vp_x, vp_y, vp_z
         * \param point_cloud the input point cloud
         * \return the average viewpoint (as an Eigen::Vector3f)
         */
       template <typename PointCloudTypeWithViewpoints> static Eigen::Vector3f
       getAverageViewPoint (const PointCloudTypeWithViewpoints& point_cloud);
-      
+
       /** \brief Check if the provided data includes far ranges and add them to far_ranges
         * \param point_cloud_data a PCLPointCloud2 message containing the input cloud
         * \param far_ranges the resulting cloud containing those points with far ranges
         */
       PCL_EXPORTS static void
       extractFarRanges (const pcl::PCLPointCloud2& point_cloud_data, PointCloud<PointWithViewpoint>& far_ranges);
-      
+
       // =====METHODS=====
       /** \brief Get a boost shared pointer of a copy of this */
-      inline Ptr 
-      makeShared () { return Ptr (new RangeImage (*this)); } 
-      
+      inline Ptr
+      makeShared () { return Ptr (new RangeImage (*this)); }
+
       /** \brief Reset all values to an empty range image */
-      PCL_EXPORTS void 
+      PCL_EXPORTS void
       reset ();
-      
+
       /** \brief Create the depth image from a point cloud
         * \param point_cloud the input point cloud
         * \param angular_resolution the angular difference (in radians) between the individual pixels in the image
@@ -147,7 +148,7 @@ namespace pcl
           const Eigen::Affine3f& sensor_pose = Eigen::Affine3f::Identity (),
           CoordinateFrame coordinate_frame=CAMERA_FRAME, float noise_level=0.0f,
           float min_range=0.0f, int border_size=0);
-      
+
       /** \brief Create the depth image from a point cloud
         * \param point_cloud the input point cloud
         * \param angular_resolution_x the angular difference (in radians) between the
@@ -172,8 +173,8 @@ namespace pcl
           const Eigen::Affine3f& sensor_pose = Eigen::Affine3f::Identity (),
           CoordinateFrame coordinate_frame=CAMERA_FRAME,
           float noise_level=0.0f, float min_range=0.0f, int border_size=0);
-      
-      /** \brief Create the depth image from a point cloud, getting a hint about the size of the scene for 
+
+      /** \brief Create the depth image from a point cloud, getting a hint about the size of the scene for
         * faster calculation.
         * \param point_cloud the input point cloud
         * \param angular_resolution the angle (in radians) between each sample in the depth image
@@ -194,8 +195,8 @@ namespace pcl
                                          const Eigen::Affine3f& sensor_pose = Eigen::Affine3f::Identity (),
                                          CoordinateFrame coordinate_frame=CAMERA_FRAME,
                                          float noise_level=0.0f, float min_range=0.0f, int border_size=0);
-      
-      /** \brief Create the depth image from a point cloud, getting a hint about the size of the scene for 
+
+      /** \brief Create the depth image from a point cloud, getting a hint about the size of the scene for
         * faster calculation.
         * \param point_cloud the input point cloud
         * \param angular_resolution_x the angular difference (in radians) between the
@@ -220,8 +221,8 @@ namespace pcl
                                          const Eigen::Affine3f& sensor_pose = Eigen::Affine3f::Identity (),
                                          CoordinateFrame coordinate_frame=CAMERA_FRAME,
                                          float noise_level=0.0f, float min_range=0.0f, int border_size=0);
-      
-      /** \brief Create the depth image from a point cloud, using the average viewpoint of the points 
+
+      /** \brief Create the depth image from a point cloud, using the average viewpoint of the points
         * (vp_x,vp_y,vp_z in the point type) in the point cloud as sensor pose (assuming a rotation of (0,0,0)).
         * \param point_cloud the input point cloud
         * \param angular_resolution the angle (in radians) between each sample in the depth image
@@ -234,15 +235,15 @@ namespace pcl
         * \param min_range the minimum visible range (defaults to 0)
         * \param border_size the border size (defaults to 0)
         * \note If wrong_coordinate_system is true, the sensor pose will be rotated to change from a coordinate frame
-        * with x to the front, y to the left and z to the top to the coordinate frame we use here (x to the right, y 
+        * with x to the front, y to the left and z to the top to the coordinate frame we use here (x to the right, y
         * to the bottom and z to the front) */
       template <typename PointCloudTypeWithViewpoints> void
       createFromPointCloudWithViewpoints (const PointCloudTypeWithViewpoints& point_cloud, float angular_resolution,
                                           float max_angle_width, float max_angle_height,
                                           CoordinateFrame coordinate_frame=CAMERA_FRAME, float noise_level=0.0f,
                                           float min_range=0.0f, int border_size=0);
-      
-      /** \brief Create the depth image from a point cloud, using the average viewpoint of the points 
+
+      /** \brief Create the depth image from a point cloud, using the average viewpoint of the points
         * (vp_x,vp_y,vp_z in the point type) in the point cloud as sensor pose (assuming a rotation of (0,0,0)).
         * \param point_cloud the input point cloud
         * \param angular_resolution_x the angular difference (in radians) between the
@@ -258,7 +259,7 @@ namespace pcl
         * \param min_range the minimum visible range (defaults to 0)
         * \param border_size the border size (defaults to 0)
         * \note If wrong_coordinate_system is true, the sensor pose will be rotated to change from a coordinate frame
-        * with x to the front, y to the left and z to the top to the coordinate frame we use here (x to the right, y 
+        * with x to the front, y to the left and z to the top to the coordinate frame we use here (x to the right, y
         * to the bottom and z to the front) */
       template <typename PointCloudTypeWithViewpoints> void
       createFromPointCloudWithViewpoints (const PointCloudTypeWithViewpoints& point_cloud,
@@ -266,7 +267,7 @@ namespace pcl
                                           float max_angle_width, float max_angle_height,
                                           CoordinateFrame coordinate_frame=CAMERA_FRAME, float noise_level=0.0f,
                                           float min_range=0.0f, int border_size=0);
-      
+
       /** \brief Create an empty depth image (filled with unobserved points)
         * \param[in] angular_resolution the angle (in radians) between each sample in the depth image
         * \param[in] sensor_pose an affine matrix defining the pose of the sensor (defaults to  Eigen::Affine3f::Identity () )
@@ -277,8 +278,8 @@ namespace pcl
       void
       createEmpty (float angular_resolution, const Eigen::Affine3f& sensor_pose=Eigen::Affine3f::Identity (),
                    RangeImage::CoordinateFrame coordinate_frame=CAMERA_FRAME, float angle_width=pcl::deg2rad (360.0f),
-                   float angle_height=pcl::deg2rad (180.0f));     
-      
+                   float angle_height=pcl::deg2rad (180.0f));
+
       /** \brief Create an empty depth image (filled with unobserved points)
         * \param angular_resolution_x the angular difference (in radians) between the
         *                             individual pixels in the image in the x-direction
@@ -294,7 +295,7 @@ namespace pcl
                    const Eigen::Affine3f& sensor_pose=Eigen::Affine3f::Identity (),
                    RangeImage::CoordinateFrame coordinate_frame=CAMERA_FRAME, float angle_width=pcl::deg2rad (360.0f),
                    float angle_height=pcl::deg2rad (180.0f));
-      
+
       /** \brief Integrate the given point cloud into the current range image using a z-buffer
         * \param point_cloud the input point cloud
         * \param noise_level - The distance in meters inside of which the z-buffer will not use the minimum,
@@ -304,17 +305,16 @@ namespace pcl
         * \param top    returns the minimum y pixel position in the image where a point was added
         * \param right  returns the maximum x pixel position in the image where a point was added
         * \param bottom returns the maximum y pixel position in the image where a point was added
-        * \param top returns the minimum y position in the image where a point was added
         * \param left   returns the minimum x pixel position in the image where a point was added
         */
       template <typename PointCloudType> void
       doZBuffer (const PointCloudType& point_cloud, float noise_level,
                  float min_range, int& top, int& right, int& bottom, int& left);
-      
+
       /** \brief Integrates the given far range measurements into the range image */
       template <typename PointCloudType> void
       integrateFarRanges (const PointCloudType& far_ranges);
-      
+
       /** \brief Cut the range image to the minimal size so that it still contains all actual range readings.
         * \param border_size allows increase from the minimal size by the specified number of pixels (defaults to 0)
         * \param top if positive, this value overrides the position of the top edge (defaults to -1)
@@ -324,52 +324,52 @@ namespace pcl
         */
       PCL_EXPORTS void
       cropImage (int border_size=0, int top=-1, int right=-1, int bottom=-1, int left=-1);
-      
-      /** \brief Get all the range values in one float array of size width*height  
+
+      /** \brief Get all the range values in one float array of size width*height
         * \return a pointer to a new float array containing the range values
         * \note This method allocates a new float array; the caller is responsible for freeing this memory.
         */
       PCL_EXPORTS float*
       getRangesArray () const;
-      
+
       /** Getter for the transformation from the world system into the range image system
        *  (the sensor coordinate frame) */
       inline const Eigen::Affine3f&
       getTransformationToRangeImageSystem () const { return (to_range_image_system_); }
-      
+
       /** Setter for the transformation from the range image system
        *  (the sensor coordinate frame) into the world system */
-      inline void 
+      inline void
       setTransformationToRangeImageSystem (const Eigen::Affine3f& to_range_image_system);
-      
+
       /** Getter for the transformation from the range image system
        *  (the sensor coordinate frame) into the world system */
       inline const Eigen::Affine3f&
       getTransformationToWorldSystem () const { return to_world_system_;}
-      
+
       /** Getter for the angular resolution of the range image in x direction in radians per pixel.
        *  Provided for downwards compatibility */
       inline float
       getAngularResolution () const { return angular_resolution_x_;}
-      
+
       /** Getter for the angular resolution of the range image in x direction in radians per pixel. */
       inline float
       getAngularResolutionX () const { return angular_resolution_x_;}
-      
+
       /** Getter for the angular resolution of the range image in y direction in radians per pixel. */
       inline float
       getAngularResolutionY () const { return angular_resolution_y_;}
-      
+
       /** Getter for the angular resolution of the range image in x and y direction (in radians). */
       inline void
       getAngularResolution (float& angular_resolution_x, float& angular_resolution_y) const;
-      
+
       /** \brief Set the angular resolution of the range image
         * \param angular_resolution the new angular resolution in x and y direction (in radians per pixel)
         */
       inline void
       setAngularResolution (float angular_resolution);
-      
+
       /** \brief Set the angular resolution of the range image
         * \param angular_resolution_x the new angular resolution in x direction (in radians per pixel)
         * \param angular_resolution_y the new angular resolution in y direction (in radians per pixel)
@@ -377,7 +377,7 @@ namespace pcl
       inline void
       setAngularResolution (float angular_resolution_x, float angular_resolution_y);
 
-      
+
       /** \brief Return the 3D point with range at the given image position
         * \param image_x the x coordinate
         * \param image_y the y coordinate
@@ -389,15 +389,15 @@ namespace pcl
       /** \brief Non-const-version of getPoint */
       inline PointWithRange&
       getPoint (int image_x, int image_y);
-      
+
       /** Return the 3d point with range at the given image position */
       inline const PointWithRange&
       getPoint (float image_x, float image_y) const;
-      
+
       /** Non-const-version of the above */
       inline PointWithRange&
       getPoint (float image_x, float image_y);
-      
+
       /** \brief Return the 3D point with range at the given image position.  This methd performs no error checking
         * to make sure the specified image position is inside of the image!
         * \param image_x the x coordinate
@@ -414,11 +414,11 @@ namespace pcl
       /** Same as above */
       inline void
       getPoint (int image_x, int image_y, Eigen::Vector3f& point) const;
-      
+
       /** Same as above */
       inline void
       getPoint (int index, Eigen::Vector3f& point) const;
-      
+
       /** Same as above */
       inline const Eigen::Map<const Eigen::Vector3f>
       getEigenVector3f (int x, int y) const;
@@ -426,7 +426,7 @@ namespace pcl
       /** Same as above */
       inline const Eigen::Map<const Eigen::Vector3f>
       getEigenVector3f (int index) const;
-      
+
       /** Return the 3d point with range at the given index (whereas index=y*width+x) */
       inline const PointWithRange&
       getPoint (int index) const;
@@ -444,11 +444,11 @@ namespace pcl
       /** Calculate the 3D point according to the given image point and the range value at the closest pixel */
       inline void
       calculate3DPoint (float image_x, float image_y, Eigen::Vector3f& point) const;
-      
+
       /** Recalculate all 3D point positions according to their pixel position and range */
       PCL_EXPORTS void
       recalculate3DPointPositions ();
-      
+
       /** Get imagePoint from 3D point in world coordinates */
       inline virtual void
       getImagePoint (const Eigen::Vector3f& point, float& image_x, float& image_y, float& range) const;
@@ -456,27 +456,27 @@ namespace pcl
       /** Same as above */
       inline void
       getImagePoint (const Eigen::Vector3f& point, int& image_x, int& image_y, float& range) const;
-      
+
       /** Same as above */
       inline void
       getImagePoint (const Eigen::Vector3f& point, float& image_x, float& image_y) const;
-      
+
       /** Same as above */
       inline void
       getImagePoint (const Eigen::Vector3f& point, int& image_x, int& image_y) const;
-      
+
       /** Same as above */
       inline void
       getImagePoint (float x, float y, float z, float& image_x, float& image_y, float& range) const;
-      
+
       /** Same as above */
       inline void
       getImagePoint (float x, float y, float z, float& image_x, float& image_y) const;
-      
+
       /** Same as above */
       inline void
       getImagePoint (float x, float y, float z, int& image_x, int& image_y) const;
-      
+
       /** point_in_image will be the point in the image at the position the given point would be. Returns
        * the range of the given point. */
       inline float
@@ -487,31 +487,31 @@ namespace pcl
        *  (Return value is point_in_image.range-given_point.range) */
       inline float
       getRangeDifference (const Eigen::Vector3f& point) const;
-      
+
       /** Get the image point corresponding to the given angles */
       inline void
       getImagePointFromAngles (float angle_x, float angle_y, float& image_x, float& image_y) const;
-      
+
       /** Get the angles corresponding to the given image point */
       inline void
       getAnglesFromImagePoint (float image_x, float image_y, float& angle_x, float& angle_y) const;
-      
+
       /** Transforms an image point in float values to an image point in int values */
       inline void
       real2DToInt2D (float x, float y, int& xInt, int& yInt) const;
-      
+
       /** Check if a point is inside of the image */
       inline bool
       isInImage (int x, int y) const;
-      
+
       /** Check if a point is inside of the image and has a finite range */
       inline bool
       isValid (int x, int y) const;
-      
+
       /** Check if a point has a finite range */
       inline bool
       isValid (int index) const;
-      
+
       /** Check if a point is inside of the image and has either a finite range or a max reading (range=INFINITY) */
       inline bool
       isObserved (int x, int y) const;
@@ -519,28 +519,28 @@ namespace pcl
       /** Check if a point is a max range (range=INFINITY) - please check isInImage or isObserved first! */
       inline bool
       isMaxRange (int x, int y) const;
-      
+
       /** Calculate the normal of an image point using the neighbors with a maximum pixel distance of radius.
        *  step_size determines how many pixels are used. 1 means all, 2 only every second, etc..
        *  Returns false if it was unable to calculate a normal.*/
       inline bool
       getNormal (int x, int y, int radius, Eigen::Vector3f& normal, int step_size=1) const;
-      
+
       /** Same as above, but only the no_of_nearest_neighbors points closest to the given point are considered. */
       inline bool
       getNormalForClosestNeighbors (int x, int y, int radius, const PointWithRange& point,
                                     int no_of_nearest_neighbors, Eigen::Vector3f& normal, int step_size=1) const;
-      
+
       /** Same as above */
       inline bool
       getNormalForClosestNeighbors (int x, int y, int radius, const Eigen::Vector3f& point,
                                     int no_of_nearest_neighbors, Eigen::Vector3f& normal,
                                     Eigen::Vector3f* point_on_plane=nullptr, int step_size=1) const;
-      
+
       /** Same as above, using default values */
       inline bool
       getNormalForClosestNeighbors (int x, int y, Eigen::Vector3f& normal, int radius=2) const;
-      
+
       /** Same as above but extracts some more data and can also return the extracted
        * information for all neighbors in radius if normal_all_neighbors is not NULL */
       inline bool
@@ -551,11 +551,11 @@ namespace pcl
                              Eigen::Vector3f* normal_all_neighbors=nullptr,
                              Eigen::Vector3f* mean_all_neighbors=nullptr,
                              Eigen::Vector3f* eigen_values_all_neighbors=nullptr) const;
-      
+
       // Return the squared distance to the n-th neighbors of the point at x,y
       inline float
       getSquaredDistanceOfNthNeighbor (int x, int y, int radius, int n, int step_size) const;
-      
+
       /** Calculate the impact angle based on the sensor position and the two given points - will return
        * -INFINITY if one of the points is unobserved */
       inline float
@@ -563,7 +563,7 @@ namespace pcl
       //! Same as above
       inline float
       getImpactAngle (int x1, int y1, int x2, int y2) const;
-      
+
       /** Extract a local normal (with a heuristic not to include background points) and calculate the impact
        *  angle based on this */
       inline float
@@ -577,7 +577,7 @@ namespace pcl
        *  Will return -INFINITY if no normal could be calculated */
       inline float
       getNormalBasedAcutenessValue (int x, int y, int radius) const;
-      
+
       /** Calculate a score [0,1] that tells how acute the impact angle is (1.0f - getImpactAngle/90deg)
        *  will return -INFINITY if one of the points is unobserved */
       inline float
@@ -585,60 +585,60 @@ namespace pcl
       //! Same as above
       inline float
       getAcutenessValue (int x1, int y1, int x2, int y2) const;
-      
+
       /** Calculate getAcutenessValue for every point */
       PCL_EXPORTS void
       getAcutenessValueImages (int pixel_distance, float*& acuteness_value_image_x,
                                float*& acuteness_value_image_y) const;
-      
+
       /** Calculates, how much the surface changes at a point. Pi meaning a flat suface and 0.0f
        *  would be a needle point */
       //inline float
       //  getSurfaceChange (const PointWithRange& point, const PointWithRange& neighbor1,
       //                   const PointWithRange& neighbor2) const;
-      
+
       /** Calculates, how much the surface changes at a point. 1 meaning a 90deg angle and 0 a flat suface */
       PCL_EXPORTS float
       getSurfaceChange (int x, int y, int radius) const;
-      
+
       /** Uses the above function for every point in the image */
       PCL_EXPORTS float*
       getSurfaceChangeImage (int radius) const;
-      
+
       /** Calculates, how much the surface changes at a point. Returns an angle [0.0f, PI] for x and y direction.
        *  A return value of -INFINITY means that a point was unobserved. */
       inline void
       getSurfaceAngleChange (int x, int y, int radius, float& angle_change_x, float& angle_change_y) const;
-      
+
       /** Uses the above function for every point in the image */
       PCL_EXPORTS void
       getSurfaceAngleChangeImages (int radius, float*& angle_change_image_x, float*& angle_change_image_y) const;
-      
+
       /** Calculates the curvature in a point using pca */
       inline float
       getCurvature (int x, int y, int radius, int step_size) const;
-      
+
       //! Get the sensor position
       inline const Eigen::Vector3f
       getSensorPos () const;
-      
+
       /** Sets all -INFINITY values to INFINITY */
       PCL_EXPORTS void
       setUnseenToMaxRange ();
-      
+
       //! Getter for image_offset_x_
       inline int
       getImageOffsetX () const { return image_offset_x_;}
       //! Getter for image_offset_y_
       inline int
       getImageOffsetY () const { return image_offset_y_;}
-      
+
       //! Setter for image offsets
       inline void
       setImageOffsets (int offset_x, int offset_y) { image_offset_x_=offset_x; image_offset_y_=offset_y;}
 
-      
+
+
       /** Get a sub part of the complete image as a new range image.
         * \param sub_image_image_offset_x - The x coordinate of the top left pixel of the sub image.
         *                         This is always according to absolute 0,0 meaning -180°,-90°
@@ -655,30 +655,30 @@ namespace pcl
       virtual void
       getSubImage (int sub_image_image_offset_x, int sub_image_image_offset_y, int sub_image_width,
                    int sub_image_height, int combine_pixels, RangeImage& sub_image) const;
-      
+
       //! Get a range image with half the resolution
-      virtual void 
+      virtual void
       getHalfImage (RangeImage& half_image) const;
-      
+
       //! Find the minimum and maximum range in the image
       PCL_EXPORTS void
       getMinMaxRanges (float& min_range, float& max_range) const;
-      
+
       //! This function sets the sensor pose to 0 and transforms all point positions to this local coordinate frame
       PCL_EXPORTS void
       change3dPointsToLocalCoordinateFrame ();
-      
+
       /** Calculate a range patch as the z values of the coordinate frame given by pose.
        *  The patch will have size pixel_size x pixel_size and each pixel
        *  covers world_size/pixel_size meters in the world
        *  You are responsible for deleting the structure afterwards! */
       PCL_EXPORTS float*
       getInterpolatedSurfaceProjection (const Eigen::Affine3f& pose, int pixel_size, float world_size) const;
-      
+
       //! Same as above, but using the local coordinate frame defined by point and the viewing direction
       PCL_EXPORTS float*
       getInterpolatedSurfaceProjection (const Eigen::Vector3f& point, int pixel_size, float world_size) const;
-      
+
       //! Get the local coordinate frame with 0,0,0 in point, upright and Z as the viewing direction
       inline Eigen::Affine3f
       getTransformationToViewerCoordinateFrame (const Eigen::Vector3f& point) const;
@@ -694,21 +694,21 @@ namespace pcl
       PCL_EXPORTS bool
       getNormalBasedUprightTransformation (const Eigen::Vector3f& point,
                                            float max_dist, Eigen::Affine3f& transformation) const;
-      
+
       /** Get the integral image of the range values (used for fast blur operations).
        *  You are responsible for deleting it after usage! */
       PCL_EXPORTS void
       getIntegralImage (float*& integral_image, int*& valid_points_num_image) const;
-      
+
       /** Get a blurred version of the range image using box filters on the provided integral image*/
       PCL_EXPORTS void     // Template necessary so that this function also works in derived classes
       getBlurredImageUsingIntegralImage (int blur_radius, float* integral_image, int* valid_points_num_image,
                                          RangeImage& range_image) const;
-      
+
       /** Get a blurred version of the range image using box filters */
       PCL_EXPORTS virtual void     // Template necessary so that this function also works in derived classes
       getBlurredImage (int blur_radius, RangeImage& range_image) const;
-      
+
       /** Get the squared euclidean distance between the two image points.
        *  Returns -INFINITY if one of the points was not observed */
       inline float
@@ -716,12 +716,12 @@ namespace pcl
       //! Doing the above for some steps in the given direction and averaging
       inline float
       getAverageEuclideanDistance (int x, int y, int offset_x, int offset_y, int max_steps) const;
-      
+
       //! Project all points on the local plane approximation, thereby smoothing the surface of the scan
       PCL_EXPORTS void
       getRangeImageWithSmoothedSurface (int radius, RangeImage& smoothed_range_image) const;
       //void getLocalNormals (int radius) const;
-      
+
       /** Calculates the average 3D position of the no_of_points points described by the start
        *  point x,y in the direction delta.
        *  Returns a max range point (range=INFINITY) if the first point is max range and an
@@ -729,31 +729,31 @@ namespace pcl
       inline void
       get1dPointAverage (int x, int y, int delta_x, int delta_y, int no_of_points,
                          PointWithRange& average_point) const;
-      
+
       /** Calculates the overlap of two range images given the relative transformation
        *  (from the given image to *this) */
       PCL_EXPORTS float
       getOverlap (const RangeImage& other_range_image, const Eigen::Affine3f& relative_transformation,
                   int search_radius, float max_distance, int pixel_step=1) const;
-      
+
       /** Get the viewing direction for the given point */
       inline bool
       getViewingDirection (int x, int y, Eigen::Vector3f& viewing_direction) const;
-      
+
       /** Get the viewing direction for the given point */
       inline void
       getViewingDirection (const Eigen::Vector3f& point, Eigen::Vector3f& viewing_direction) const;
-      
+
       /** Return a newly created Range image.
        *  Can be reimplemented in derived classes like RangeImagePlanar to return an image of the same type. */
-      PCL_EXPORTS virtual RangeImage* 
+      PCL_EXPORTS virtual RangeImage*
       getNew () const { return new RangeImage; }
 
       /** Copy other to *this. Necessary for use in virtual functions that need to copy derived RangeImage classes (like RangeImagePlanar) */
       PCL_EXPORTS virtual void
       copyTo (RangeImage& other) const;
 
-      
+
       // =====MEMBER VARIABLES=====
       // BaseClass:
       //   roslib::Header header;
@@ -763,7 +763,7 @@ namespace pcl
       //   bool is_dense;
 
       static bool debug; /**< Just for... well... debugging purposes. :-) */
-      
+
     protected:
       // =====PROTECTED MEMBER VARIABLES=====
       Eigen::Affine3f to_range_image_system_;  /**< Inverse of to_world_system_ */
@@ -778,7 +778,7 @@ namespace pcl
                                                 *   an image of full size (360x180 degrees) */
       PointWithRange unobserved_point;         /**< This point is used to be able to return
                                                 *   a reference to a non-existing point */
-      
+
       // =====PROTECTED METHODS=====
 
 
@@ -794,11 +794,11 @@ namespace pcl
       /** Query the asin lookup table */
       static inline float
       asinLookUp (float value);
-      
+
       /** Query the std::atan2 lookup table */
       static inline float
       atan2LookUp (float y, float x);
-     
+
       /** Query the cos lookup table */
       static inline float
       cosLookUp (float value);
index 32ac7a0065fa63be12d89418654dc5239e9e2365..b190a338637e7850a1e2646beb2dea763c8115b1 100644 (file)
@@ -53,7 +53,7 @@
 //https://bugreports.qt-project.org/browse/QTBUG-22829
 #ifndef Q_MOC_RUN
 #include <pcl/pcl_macros.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <boost/mpl/vector.hpp>
 #include <boost/preprocessor/seq/enum.hpp>
 #include <boost/preprocessor/seq/for_each.hpp>
diff --git a/common/include/pcl/type_traits.h b/common/include/pcl/type_traits.h
new file mode 100644 (file)
index 0000000..765f414
--- /dev/null
@@ -0,0 +1,361 @@
+/*
+ * Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2020-, Open Perception, Inc.
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of the copyright holder(s) nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#include <boost/mpl/assert.hpp>
+
+// This is required for the workaround at line 109
+#ifdef _MSC_VER
+#include <Eigen/Core>
+#include <Eigen/src/StlSupport/details.h>
+#endif
+
+#include <string>
+#include <type_traits>
+
+#include <cstdint>
+
+namespace pcl
+{
+  namespace deprecated
+  {
+    /** \class DeprecatedType
+    * \brief A dummy type to aid in template parameter deprecation
+    */
+    struct T {};
+  }
+
+  namespace fields
+  {
+    // Tag types get put in this namespace
+  }
+
+  namespace traits
+  {
+    namespace detail {
+    /**
+     * \brief Enumeration for different numerical types
+     *
+     * \details struct used to enable scope and implicit conversion to int
+     */
+    struct PointFieldTypes {
+        static const std::uint8_t INT8 = 1,    UINT8 = 2,
+                                  INT16 = 3,   UINT16 = 4,
+                                  INT32 = 5,   UINT32 = 6,
+                                  FLOAT32 = 7, FLOAT64 = 8;
+    };
+    }
+
+    // Metafunction to return enum value representing a type
+    template<typename T> struct asEnum {};
+    template<> struct asEnum<std::int8_t>   { static const std::uint8_t value = detail::PointFieldTypes::INT8;    };
+    template<> struct asEnum<std::uint8_t>  { static const std::uint8_t value = detail::PointFieldTypes::UINT8;   };
+    template<> struct asEnum<std::int16_t>  { static const std::uint8_t value = detail::PointFieldTypes::INT16;   };
+    template<> struct asEnum<std::uint16_t> { static const std::uint8_t value = detail::PointFieldTypes::UINT16;  };
+    template<> struct asEnum<std::int32_t>  { static const std::uint8_t value = detail::PointFieldTypes::INT32;   };
+    template<> struct asEnum<std::uint32_t> { static const std::uint8_t value = detail::PointFieldTypes::UINT32;  };
+    template<> struct asEnum<float>    { static const std::uint8_t value = detail::PointFieldTypes::FLOAT32; };
+    template<> struct asEnum<double>   { static const std::uint8_t value = detail::PointFieldTypes::FLOAT64; };
+
+    template<typename T>
+    static constexpr std::uint8_t asEnum_v = asEnum<T>::value;
+
+    // Metafunction to return type of enum value
+    template<int> struct asType {};
+    template<> struct asType<detail::PointFieldTypes::INT8>    { using type = std::int8_t; };
+    template<> struct asType<detail::PointFieldTypes::UINT8>   { using type = std::uint8_t; };
+    template<> struct asType<detail::PointFieldTypes::INT16>   { using type = std::int16_t; };
+    template<> struct asType<detail::PointFieldTypes::UINT16>  { using type = std::uint16_t; };
+    template<> struct asType<detail::PointFieldTypes::INT32>   { using type = std::int32_t; };
+    template<> struct asType<detail::PointFieldTypes::UINT32>  { using type = std::uint32_t; };
+    template<> struct asType<detail::PointFieldTypes::FLOAT32> { using type = float; };
+    template<> struct asType<detail::PointFieldTypes::FLOAT64> { using type = double; };
+
+    template<int index>
+    using asType_t = typename asType<index>::type;
+
+    // Metafunction to decompose a type (possibly of array of any number of dimensions) into
+    // its scalar type and total number of elements.
+    template<typename T> struct decomposeArray
+    {
+      using type = std::remove_all_extents_t<T>;
+      static const std::uint32_t value = sizeof (T) / sizeof (type);
+    };
+
+    // For non-POD point types, this is specialized to return the corresponding POD type.
+    template<typename PointT>
+    struct POD
+    {
+      using type = PointT;
+    };
+
+#ifdef _MSC_VER
+
+    /* Sometimes when calling functions like `copyPoint()` or `copyPointCloud`
+     * without explicitly specifying point types, MSVC deduces them to be e.g.
+     * `Eigen::internal::workaround_msvc_stl_support<pcl::PointXYZ>` instead of
+     * plain `pcl::PointXYZ`. Subsequently these types are passed to meta-
+     * functions like `has_field` or `fieldList` and make them choke. This hack
+     * makes use of the fact that internally `fieldList` always applies `POD` to
+     * its argument type. This specialization therefore allows to unwrap the
+     * contained point type. */
+    template<typename PointT>
+    struct POD<Eigen::internal::workaround_msvc_stl_support<PointT> >
+    {
+      using type = PointT;
+    };
+
+#endif
+
+    // name
+    /* This really only depends on Tag, but we go through some gymnastics to avoid ODR violations.
+       We template it on the point type PointT to avoid ODR violations when registering multiple
+       point types with shared tags.
+       The dummy parameter is so we can partially specialize name on PointT and Tag but leave it
+       templated on dummy. Each specialization declares a static char array containing the tag
+       name. The definition of the static member would conflict when linking multiple translation
+       units that include the point type registration. But when the static member definition is
+       templated (on dummy), we sidestep the ODR issue.
+    */
+    template<class PointT, typename Tag, int dummy = 0>
+    struct name : name<typename POD<PointT>::type, Tag, dummy>
+    {
+      // Contents of specialization:
+      // static const char value[];
+
+      // Avoid infinite compile-time recursion
+      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
+                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
+    };
+
+    // offset
+    template<class PointT, typename Tag>
+    struct offset : offset<typename POD<PointT>::type, Tag>
+    {
+      // Contents of specialization:
+      // static const std::size_t value;
+
+      // Avoid infinite compile-time recursion
+      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
+                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
+    };
+
+    // datatype
+    template<class PointT, typename Tag>
+    struct datatype : datatype<typename POD<PointT>::type, Tag>
+    {
+      // Contents of specialization:
+      // using type = ...;
+      // static const std::uint8_t value;
+      // static const std::uint32_t size;
+
+      // Avoid infinite compile-time recursion
+      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
+                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
+    };
+
+    // fields
+    template<typename PointT>
+    struct fieldList : fieldList<typename POD<PointT>::type>
+    {
+      // Contents of specialization:
+      // using type = boost::mpl::vector<...>;
+
+      // Avoid infinite compile-time recursion
+      BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
+                           POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
+    };
+  } //namespace traits
+
+  /** \brief A helper functor that can copy a specific value if the given field exists.
+    *
+    * \note In order to actually copy the value an instance of this functor should be passed
+    * to a pcl::for_each_type loop. See the example below.
+    *
+    * \code
+    * PointInT p;
+    * bool exists;
+    * float value;
+    * using FieldList = typename pcl::traits::fieldList<PointInT>::type;
+    * pcl::for_each_type<FieldList> (pcl::CopyIfFieldExists<PointT, float> (p, "intensity", exists, value));
+    * \endcode
+    */
+  template <typename PointInT, typename OutT>
+  struct CopyIfFieldExists
+  {
+    using Pod = typename traits::POD<PointInT>::type;
+
+    /** \brief Constructor.
+      * \param[in] pt the input point
+      * \param[in] field the name of the field
+      * \param[out] exists set to true if the field exists, false otherwise
+      * \param[out] value the copied field value
+      */
+    CopyIfFieldExists (const PointInT &pt,
+                       const std::string &field,
+                       bool &exists,
+                       OutT &value)
+      : pt_ (reinterpret_cast<const Pod&>(pt)), name_ (field), exists_ (exists), value_ (value)
+    {
+      exists_ = false;
+    }
+
+    /** \brief Constructor.
+      * \param[in] pt the input point
+      * \param[in] field the name of the field
+      * \param[out] value the copied field value
+      */
+    CopyIfFieldExists (const PointInT &pt,
+                       const std::string &field,
+                       OutT &value)
+      : pt_ (reinterpret_cast<const Pod&>(pt)), name_ (field), exists_ (exists_tmp_), value_ (value)
+    {
+    }
+
+    /** \brief Operator. Data copy happens here. */
+    template <typename Key> inline void
+    operator() ()
+    {
+      if (name_ == pcl::traits::name<PointInT, Key>::value)
+      {
+        exists_ = true;
+        using T = typename pcl::traits::datatype<PointInT, Key>::type;
+        const std::uint8_t* data_ptr = reinterpret_cast<const std::uint8_t*>(&pt_) + pcl::traits::offset<PointInT, Key>::value;
+        value_ = static_cast<OutT> (*reinterpret_cast<const T*>(data_ptr));
+      }
+    }
+
+    private:
+      const Pod &pt_;
+      const std::string &name_;
+      bool &exists_;
+      // Bogus entry
+      bool exists_tmp_;
+      OutT &value_;
+  };
+
+  /** \brief A helper functor that can set a specific value in a field if the field exists.
+    *
+    * \note In order to actually set the value an instance of this functor should be passed
+    * to a pcl::for_each_type loop. See the example below.
+    *
+    * \code
+    * PointT p;
+    * using FieldList = typename pcl::traits::fieldList<PointT>::type;
+    * pcl::for_each_type<FieldList> (pcl::SetIfFieldExists<PointT, float> (p, "intensity", 42.0f));
+    * \endcode
+    */
+  template <typename PointOutT, typename InT>
+  struct SetIfFieldExists
+  {
+    using Pod = typename traits::POD<PointOutT>::type;
+
+    /** \brief Constructor.
+      * \param[in] pt the input point
+      * \param[in] field the name of the field
+      * \param[out] value the value to set
+      */
+    SetIfFieldExists (PointOutT &pt,
+                      const std::string &field,
+                      const InT &value)
+      : pt_ (reinterpret_cast<Pod&>(pt)), name_ (field), value_ (value)
+    {
+    }
+
+    /** \brief Operator. Data copy happens here. */
+    template <typename Key> inline void
+    operator() ()
+    {
+      if (name_ == pcl::traits::name<PointOutT, Key>::value)
+      {
+        using T = typename pcl::traits::datatype<PointOutT, Key>::type;
+        std::uint8_t* data_ptr = reinterpret_cast<std::uint8_t*>(&pt_) + pcl::traits::offset<PointOutT, Key>::value;
+        *reinterpret_cast<T*>(data_ptr) = static_cast<T> (value_);
+      }
+    }
+
+    private:
+      Pod &pt_;
+      const std::string &name_;
+      const InT &value_;
+  };
+
+  /** \brief Set the value at a specified field in a point
+    * \param[out] pt the point to set the value to
+    * \param[in] field_offset the offset of the field
+    * \param[in] value the value to set
+    */
+  template <typename PointT, typename ValT> inline void
+  setFieldValue (PointT &pt, std::size_t field_offset, const ValT &value)
+  {
+    std::uint8_t* data_ptr = reinterpret_cast<std::uint8_t*>(&pt) + field_offset;
+    *reinterpret_cast<ValT*>(data_ptr) = value;
+  }
+
+  /** \brief Get the value at a specified field in a point
+    * \param[in] pt the point to get the value from
+    * \param[in] field_offset the offset of the field
+    * \param[out] value the value to retrieve
+    */
+  template <typename PointT, typename ValT> inline void
+  getFieldValue (const PointT &pt, std::size_t field_offset, ValT &value)
+  {
+    const std::uint8_t* data_ptr = reinterpret_cast<const std::uint8_t*>(&pt) + field_offset;
+    value = *reinterpret_cast<const ValT*>(data_ptr);
+  }
+
+  template <typename ...> using void_t = void; // part of std in c++17
+
+#ifdef DOXYGEN_ONLY
+
+  /**
+   * \brief Tests at compile time if type T has a custom allocator
+   *
+   * \see pcl::make_shared, PCL_MAKE_ALIGNED_OPERATOR_NEW
+   * \tparam T Type of the object to test
+   */
+  template <typename T> struct has_custom_allocator;
+
+#else
+
+  template <typename, typename = void_t<>> struct has_custom_allocator : std::false_type {};
+  template <typename T> struct has_custom_allocator<T, void_t<typename T::_custom_allocator_type_trait>> : std::true_type {};
+
+#endif
+}
+
diff --git a/common/include/pcl/types.h b/common/include/pcl/types.h
new file mode 100644 (file)
index 0000000..5f83f73
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2020-, OpenPerception
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of the copyright holder(s) nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+/**
+ * \file pcl/types.h
+ *
+ * \brief Defines basic non-point types used by PCL
+ * \ingroup common
+ */
+
+#include <pcl/pcl_macros.h>
+
+#include <vector>
+
+#include <cstdint>
+
+namespace pcl
+{
+  using uint8_t PCL_DEPRECATED(1, 12, "use std::uint8_t instead of pcl::uint8_t") = std::uint8_t;
+  using int8_t PCL_DEPRECATED(1, 12, "use std::int8_t instead of pcl::int8_t") = std::int8_t;
+  using uint16_t PCL_DEPRECATED(1, 12, "use std::uint16_t instead of pcl::uint16_t") = std::uint16_t;
+  using int16_t PCL_DEPRECATED(1, 12, "use std::uint16_t instead of pcl::int16_t") = std::int16_t;
+  using uint32_t PCL_DEPRECATED(1, 12, "use std::uint32_t instead of pcl::uint32_t") = std::uint32_t;
+  using int32_t PCL_DEPRECATED(1, 12, "use std::int32_t instead of pcl::int32_t") = std::int32_t;
+  using uint64_t PCL_DEPRECATED(1, 12, "use std::uint64_t instead of pcl::uint64_t") = std::uint64_t;
+  using int64_t PCL_DEPRECATED(1, 12, "use std::int64_t instead of pcl::int64_t") = std::int64_t;
+  using int_fast16_t PCL_DEPRECATED(1, 12, "use std::int_fast16_t instead of pcl::int_fast16_t") = std::int_fast16_t;
+
+// temporary macros for customization. Only use for PCL < 1.12
+// Aim is to remove macros and instead allow multiple index types to coexist together
+#ifndef PCL_INDEX_SIZE
+#if PCL_MINOR_VERSION <= 11
+// sizeof returns bytes, while we measure size by bits in the template
+#define PCL_INDEX_SIZE (sizeof(int) * 8)
+#else
+#define PCL_INDEX_SIZE 32
+#endif  // PCL_MINOR_VERSION
+#endif  // PCL_INDEX_SIZE
+
+#ifndef PCL_INDEX_SIGNED
+#define PCL_INDEX_SIGNED true
+#endif
+
+  namespace detail {
+    /**
+     * \brief int_type::type refers to an integral type that satisfies template parameters
+     * \tparam Bits number of bits in the integral type
+     * \tparam Signed signed or unsigned nature of the type
+     */
+    template <std::size_t Bits, bool Signed = true>
+    struct int_type { using type = void; };
+
+    /**
+     * \brief helper type to use for `int_type::type`
+     * \see int_type
+     */
+    template <std::size_t Bits, bool Signed = true>
+    using int_type_t = typename int_type<Bits, Signed>::type;
+
+    template <>
+    struct int_type<8, true> { using type = std::int8_t; };
+    template <>
+    struct int_type<8, false> { using type = std::uint8_t; };
+    template <>
+    struct int_type<16, true> { using type = std::int16_t; };
+    template <>
+    struct int_type<16, false> { using type = std::uint16_t; };
+    template <>
+    struct int_type<32, true> { using type = std::int32_t; };
+    template <>
+    struct int_type<32, false> { using type = std::uint32_t; };
+    template <>
+    struct int_type<64, true> { using type = std::int64_t; };
+    template <>
+    struct int_type<64, false> { using type = std::uint64_t; };
+
+    /**
+     * \brief number of bits in PCL's index type
+     *
+     * For PCL 1.11, please use PCL_INDEX_SIZE to choose a size best suited for your needs.
+     * PCL 1.12 will come with default 32, along with client code compile time choice
+     *
+     * PCL 1.11 has a default size = sizeof(int)
+     */
+    constexpr std::uint8_t index_type_size = PCL_INDEX_SIZE;
+
+    /**
+     * \brief signed/unsigned nature of PCL's index type
+     * For PCL 1.11, please use PCL_INDEX_SIGNED to choose a type best suited for your needs.
+     * PCL 1.12 will come with default signed, along with client code compile time choice
+     * Default: signed
+     */
+    constexpr bool index_type_signed = PCL_INDEX_SIGNED;
+}  // namespace detail
+
+  /**
+   * \brief Type used for an index in PCL
+   *
+   * Default index_t = int for PCL 1.11, std::int32_t for PCL >= 1.12
+   */
+  using index_t = detail::int_type_t<detail::index_type_size, detail::index_type_signed>;
+  static_assert(!std::is_void<index_t>::value, "`index_t` can't have type `void`");
+
+  /**
+   * \brief Type used for indices in PCL
+   */
+  using Indices = std::vector<index_t>;
+}  // namespace pcl
+
index a108856fbeaf81745a8428ac10b6eba607420c27..a996887d9496875050fd4c702aa9259ea86d1c98 100644 (file)
@@ -255,7 +255,17 @@ void kf_work(
         int k;
 
         // execute the p different work units in different threads
-#       pragma omp parallel for
+// We cannot use OPENMP_LEGACY_CONST_DATA_SHARING_RULE here, because we cannot include
+// pcl_macros.h in this file as this is a C file.
+#if (defined _OPENMP && (_OPENMP <= 201307)) || (defined __GNUC__ && (__GNUC__ >= 6 && __GNUC__ < 9))
+#pragma omp parallel for \
+  default(none) \
+  shared(f, factors, Fout, in_stride)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(f, factors, Fout, fstride, in_stride, m, p, st)
+#endif
         for (k=0;k<p;++k) 
             kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st);
         // all threads have joined by this point
index 63464c1b81bc93da66df75a34a6d169e304baffc..0125cf0bdd937740547473d4673ca0a6ec378f8b 100644 (file)
@@ -138,7 +138,8 @@ pcl::GaussianKernel::convolveRows (const pcl::PointCloud<float>& input,
   assert (kernel.size () % 2 == 1);
   std::size_t kernel_width = kernel.size () -1;
   std::size_t radius = kernel.size () / 2;
-  const pcl::PointCloud<float>* input_;
+  std::unique_ptr<const pcl::PointCloud<float>> copied_input;
+  const pcl::PointCloud<float>* unaliased_input;
   if (&input != &output)
   {
     if (output.height < input.height || output.width < input.width)
@@ -147,32 +148,30 @@ pcl::GaussianKernel::convolveRows (const pcl::PointCloud<float>& input,
       output.height = input.height;
       output.points.resize (input.height * input.width);
     }
-    input_ = &input;
+    unaliased_input = &input;
   }
   else
-    input_ = new pcl::PointCloud<float>(input);
+  {
+    copied_input = std::make_unique<pcl::PointCloud<float>>(input);
+    unaliased_input = copied_input.get();
+  }
   
   std::size_t i;
-  for (std::size_t j = 0; j < input_->height; j++)
+  for (std::size_t j = 0; j < unaliased_input->height; j++)
   {
     for (i = 0 ; i < radius ; i++)
       output (i,j) = 0;
 
-    for ( ; i < input_->width - radius ; i++)  
+    for ( ; i < unaliased_input->width - radius ; i++)
     {
       output (i,j) = 0;
       for (int k = static_cast<int>(kernel_width), l = static_cast<int>(i - radius); k >= 0 ; k--, l++)
-        output (i,j) += (*input_) (l,j) * kernel[k];
+        output (i,j) += (*unaliased_input) (l,j) * kernel[k];
     }
 
-    for ( ; i < input_->width ; i++)
+    for ( ; i < unaliased_input->width ; i++)
       output (i,j) = 0;
   }
-
-  if (&input == &output)
-  {
-    delete input_;
-  }
 }
 
 void 
@@ -183,37 +182,39 @@ pcl::GaussianKernel::convolveCols (const pcl::PointCloud<float>& input,
   assert (kernel.size () % 2 == 1);
   std::size_t kernel_width = kernel.size () -1;
   std::size_t radius = kernel.size () / 2;
-  const pcl::PointCloud<float>* input_;
+  std::unique_ptr<const pcl::PointCloud<float>> copied_input;
+  const pcl::PointCloud<float>* unaliased_input;
   if (&input != &output)
   {
     if (output.height < input.height || output.width < input.width)
     {
       output.width = input.width;
       output.height = input.height;
-      output.resize (input.width * input.height);
+      output.points.resize (input.height * input.width);
     }
-    input_ = &input;
+    unaliased_input = &input;
   }
   else
-    input_ = new pcl::PointCloud<float> (input);
+  {
+    copied_input = std::make_unique<pcl::PointCloud<float>>(input);
+    unaliased_input = copied_input.get();
+  }
 
   std::size_t j;
-  for (std::size_t i = 0; i < input_->width; i++)
+  for (std::size_t i = 0; i < unaliased_input->width; i++)
   {
     for (j = 0 ; j < radius ; j++)
       output (i,j) = 0;
 
-    for ( ; j < input_->height - radius ; j++)  {
+    for ( ; j < unaliased_input->height - radius ; j++)  {
       output (i,j) = 0;
       for (int k = static_cast<int>(kernel_width), l = static_cast<int>(j - radius) ; k >= 0 ; k--, l++)
       {
-        output (i,j) += (*input_) (i,l) * kernel[k];
+        output (i,j) += (*unaliased_input) (i,l) * kernel[k];
       }
     }
 
-    for ( ; j < input_->height ; j++)
+    for ( ; j < unaliased_input->height ; j++)
       output (i,j) = 0;
   }
-  if (&input == &output)
-    delete input_;
 }
index cd501d0089394bca7c78e70434f853f15d6b41bd..40425c7b93038b576898435243d65b0bf670bdfa 100644 (file)
@@ -868,8 +868,13 @@ RangeImage::getOverlap (const RangeImage& other_range_image, const Eigen::Affine
   
   float max_distance_squared = max_distance*max_distance;
   
-  # pragma omp parallel for num_threads (max_no_of_threads) default (shared) schedule (dynamic, 1) \
-                        reduction (+ : valid_points_counter) reduction (+ : hits_counter)
+#pragma omp parallel for \
+  default(none) \
+  shared(max_distance_squared, other_range_image, pixel_step, relative_transformation, search_radius) \
+  schedule(dynamic, 1) \
+  reduction(+ : valid_points_counter) \
+  reduction(+ : hits_counter) \
+  num_threads(max_no_of_threads)
   for (int other_y=0; other_y<int (other_range_image.height); other_y+=pixel_step)
   {
     for (int other_x=0; other_x<int (other_range_image.width); other_x+=pixel_step)
index 9754c40565e899d0336c818303fdc00304167e54..1b9f075ad5ae9b26405888434f482bc2eefe5633 100644 (file)
  *
  */
 
-#include <pcl_cuda/io/cloud_to_pcl.h>
-#include <pcl_cuda/io/debayering.h>
-#include <pcl_cuda/time_cpu.h>
+#include <pcl/memory.h>
+#include <pcl/cuda/io/cloud_to_pcl.h>
+#include <pcl/cuda/io/debayering.h>
+#include <pcl/cuda/time_cpu.h>
 #include <pcl/io/kinect_grabber.h>
 
 #include <opencv2/opencv.hpp>
 
-#include <boost/shared_ptr.hpp>
-
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 class SimpleKinectTool
 {
   public:
@@ -75,7 +75,7 @@ class SimpleKinectTool
 
       std::function<void (const openni_wrapper::Image::Ptr& image)> f = std::bind (&SimpleKinectTool::cloud_cb_, this, _1);
 
-      boost::signals2::connection c = interface->registerCallback (f);
+      interface->registerCallback (f);
 
       interface->start ();
       
index 89b848838ed8348020b6968398bc9c32db7b80d3..18840374bbfcdf92164a9d14b5a0513af293e426 100644 (file)
  *
  */
 
-#include <pcl_cuda/io/cloud_to_pcl.h>
-#include <pcl_cuda/io/disparity_to_cloud.h>
-#include <pcl_cuda/sample_consensus/sac_model_plane.h>
-#include <pcl_cuda/sample_consensus/ransac.h>
-#include <pcl_cuda/time_cpu.h>
-
-#include <pcl/io/openni_grabber.h>
+#include <pcl/memory.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
+#include <pcl/cuda/io/cloud_to_pcl.h>
+#include <pcl/cuda/io/disparity_to_cloud.h>
+#include <pcl/cuda/sample_consensus/ransac.h>
+#include <pcl/cuda/sample_consensus/sac_model_plane.h>
+#include <pcl/cuda/time_cpu.h>
+#include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
 
-#include <boost/shared_ptr.hpp>
-
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 class SimpleKinectTool
 {
   public:
@@ -79,7 +78,7 @@ class SimpleKinectTool
 
       std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&SimpleKinectTool::cloud_cb_, this, _1, _2, _3);
 
-      boost::signals2::connection c = interface->registerCallback (f);
+      interface->registerCallback (f);
 
       //viewer.runOnVisualizationThread (fn, "viz_cb");
       interface->start ();
index 9072db83984e6dba4854ef88ad3fe809945be6d7..834fdf1be874a73f9ad2fb2c47050f9cf8cdd9da 100644 (file)
  *
  */
 
-#include <pcl_cuda/io/cloud_to_pcl.h>
-#include <pcl_cuda/io/extract_indices.h>
-#include <pcl_cuda/io/disparity_to_cloud.h>
-#include <pcl_cuda/sample_consensus/sac_model_1point_plane.h>
-#include <pcl_cuda/sample_consensus/multi_ransac.h>
-#include <pcl_cuda/segmentation/connected_components.h>
-#include <pcl_cuda/time_cpu.h>
-#include <pcl_cuda/time_gpu.h>
-
+#include <pcl/memory.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 #include <pcl/common/transform.h>
+#include <pcl/cuda/io/cloud_to_pcl.h>
+#include <pcl/cuda/io/disparity_to_cloud.h>
+#include <pcl/cuda/io/extract_indices.h>
+#include <pcl/cuda/sample_consensus/multi_ransac.h>
+#include <pcl/cuda/sample_consensus/sac_model_1point_plane.h>
+#include <pcl/cuda/segmentation/connected_components.h>
+#include <pcl/cuda/time_cpu.h>
+#include <pcl/cuda/time_gpu.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/visualization/point_cloud_handlers.h>
 #include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
+#include <pcl/visualization/point_cloud_handlers.h>
 
-#include <opencv2/opencv.hpp>
-#include <opencv2/gpu/gpu.hpp>
+#include <boost/filesystem.hpp>
 
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 
-#include <boost/filesystem.hpp>
-#include <boost/shared_ptr.hpp>
+#include <opencv2/opencv.hpp>
+#include <opencv2/gpu/gpu.hpp>
 
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 using namespace pcl_cuda;
 
 template <template <typename> class Storage>
@@ -239,18 +239,17 @@ class MultiRansac
       //cudaDeviceSetCacheConfig (cudaFuncCachePreferL1);
       pcl::OpenNIGrabber interface {};
 
-      boost::signals2::connection c;
       if (use_device)
       {
         std::cerr << "[RANSAC] Using GPU..." << std::endl;
         std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&MultiRansac::cloud_cb<pcl_cuda::Device>, this, _1, _2, _3);
-        c = interface.registerCallback (f);
+        interface.registerCallback (f);
       }
       else
       {
         std::cerr << "[RANSAC] Using CPU..." << std::endl;
         std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&MultiRansac::cloud_cb<pcl_cuda::Host>, this, _1, _2, _3);
-        c = interface.registerCallback (f);
+        interface.registerCallback (f);
       }
 
       if (use_viewer)
index de659d2d684839558af5988d8f35074275320489..b9c942d97caefaf77670b679842415fcbb074f9b 100644 (file)
  *
  */
 
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 #include <pcl/cuda/features/normal_3d.h>
 #include <pcl/cuda/time_cpu.h>
 #include <pcl/cuda/time_gpu.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/pcl_macros.h>
 
 #include <opencv2/opencv.hpp>
 #include <opencv2/gpu/gpu.hpp>
 
-#include <boost/shared_ptr.hpp>
-
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 using namespace pcl::cuda;
 
 class NormalEstimation
index def05ff4b7b054d72fd80a0d3bd72fb628c3ced8..e344b72364a65c775810617b7f2070050e11ecd7 100644 (file)
@@ -250,18 +250,17 @@ class MultiRansac
       //cudaDeviceSetCacheConfig (cudaFuncCachePreferL1);
       pcl::OpenNIGrabber interface {};
 
-      boost::signals2::connection c;
       if (use_device)
       {
         std::cerr << "[RANSAC] Using GPU..." << std::endl;
         std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&MultiRansac::cloud_cb<Device>, this, _1, _2, _3);
-        c = interface.registerCallback (f);
+        interface.registerCallback (f);
       }
       else
       {
         std::cerr << "[RANSAC] Using CPU..." << std::endl;
         std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&MultiRansac::cloud_cb<Host>, this, _1, _2, _3);
-        c = interface.registerCallback (f);
+        interface.registerCallback (f);
       }
 
       if (use_viewer)
index 85f27a710a05fc1964ab332391ae2d625075c83a..0effead638ce45add2a4e6a59a9ad2cdb4d9b304 100644 (file)
  *
  */
 
-#include <pcl_cuda/time_cpu.h>
-#include <pcl_cuda/time_gpu.h>
-#include <pcl_cuda/io/cloud_to_pcl.h>
-#include <pcl_cuda/io/extract_indices.h>
-#include <pcl_cuda/io/disparity_to_cloud.h>
-#include <pcl_cuda/io/host_device.h>
-#include <pcl_cuda/sample_consensus/sac_model_1point_plane.h>
-#include <pcl_cuda/sample_consensus/ransac.h>
-
+#include <pcl/memory.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+#include <pcl/cuda/time_cpu.h>
+#include <pcl/cuda/time_gpu.h>
+#include <pcl/cuda/io/cloud_to_pcl.h>
+#include <pcl/cuda/io/disparity_to_cloud.h>
+#include <pcl/cuda/io/extract_indices.h>
+#include <pcl/cuda/io/host_device.h>
+#include <pcl/cuda/sample_consensus/ransac.h>
+#include <pcl/cuda/sample_consensus/sac_model_1point_plane.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-
-#include <boost/shared_ptr.hpp>
 
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 using namespace pcl_cuda;
 
 class SimpleKinectTool
@@ -98,8 +97,8 @@ class SimpleKinectTool
         }
         else
         {
-          typename SampleConsensusModel1PointPlane<Storage>::IndicesPtr inliers_stencil;
-          inliers_stencil = sac.getInliersStencil ();
+          //typename SampleConsensusModel1PointPlane<Storage>::IndicesPtr inliers_stencil;
+          //inliers_stencil = sac.getInliersStencil ();
 
       //    OpenNIRGB color;
       //    color.r = 253; color.g = 0; color.b = 0;
@@ -158,7 +157,6 @@ class SimpleKinectTool
     run (bool use_device)
     {
 #if 1
-      pcl::Grabber* filegrabber = 0;
 
       float frames_per_second = 1;
       bool repeat = false;
index 0227d0f919f1ba43a44ce66305b712f7a520f389..b7debcc3a2ee27d9335f8551d3aaaac1a2598305 100644 (file)
  *
  */
 
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 #include <pcl/cuda/features/normal_3d.h>
 #include <pcl/cuda/time_cpu.h>
 #include <pcl/cuda/time_gpu.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/pcl_macros.h>
 
 #include <opencv2/highgui/highgui.hpp>
 #include <opencv2/highgui/highgui_c.h>
 #include <opencv2/gpu/gpu.hpp>
 
-#include <boost/shared_ptr.hpp>
-
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 using namespace pcl::cuda;
 
 template <template <typename> class Storage>
@@ -288,7 +288,6 @@ class Segmentation
               }
               std::vector<int> planes_inlier_counts = sac.getAllInlierCounts ();
               std::vector<float4> coeffs = sac.getAllModelCoefficients ();
-              std::vector<float3> centroids = sac.getAllModelCentroids ();
               std::cerr << "Found " << planes_inlier_counts.size () << " planes" << std::endl;
 
               for (unsigned int i = 0; i < planes.size (); i++)
@@ -357,7 +356,6 @@ class Segmentation
     {
       if (use_file)
       {
-        pcl::Grabber* filegrabber = 0;
 
         float frames_per_second = 1;
         bool repeat = false;
@@ -389,18 +387,17 @@ class Segmentation
       {
         pcl::OpenNIGrabber grabber {};
 
-        boost::signals2::connection c;
         if (use_device)
         {
           std::cerr << "[Segmentation] Using GPU..." << std::endl;
           std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&Segmentation::cloud_cb<Device>, this, _1, _2, _3);
-          c = grabber.registerCallback (f);
+          grabber.registerCallback (f);
         }
         else
         {
 //          std::cerr << "[Segmentation] Using CPU..." << std::endl;
 //          std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&Segmentation::cloud_cb<Host>, this, _1, _2, _3);
-//          c = grabber.registerCallback (f);
+//          grabber.registerCallback (f);
         }
 
         viewer.runOnVisualizationThread (std::bind(&Segmentation::viz_cb, this, _1), "viz_cb");
index af410b771c8d45014450477eb19c11e551f01368..341e0cd32ff928172e3f0422f89eee62368498c2 100644 (file)
  *
  */
 
-#include <pcl/cuda/features/normal_3d.h>
+#include <pcl/memory.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 #include <pcl/cuda/time_cpu.h>
 #include <pcl/cuda/time_gpu.h>
+#include <pcl/cuda/features/normal_3d.h>
 #include <pcl/cuda/io/cloud_to_pcl.h>
-#include <pcl/cuda/io/extract_indices.h>
 #include <pcl/cuda/io/disparity_to_cloud.h>
+#include <pcl/cuda/io/extract_indices.h>
 #include <pcl/cuda/io/host_device.h>
 #include <pcl/cuda/segmentation/connected_components.h>
 #include <pcl/cuda/segmentation/mssegmentation.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 
 #include <opencv2/highgui/highgui.hpp>
 #include <opencv2/gpu/gpu.hpp>
 
-#include <boost/shared_ptr.hpp>
-
-#include <iostream>
 #include <fstream>
 #include <functional>
+#include <iostream>
 #include <mutex>
 
+
 using namespace pcl::cuda;
 
 template <template <typename> class Storage>
@@ -262,18 +262,17 @@ class Segmentation
       {
         pcl::OpenNIGrabber grabber {};
 
-        boost::signals2::connection c;
         if (use_device)
         {
           std::cerr << "[Segmentation] Using GPU..." << std::endl;
           std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&Segmentation::cloud_cb<Device>, this, _1, _2, _3);
-          c = grabber.registerCallback (f);
+          grabber.registerCallback (f);
         }
         else
         {
 //          std::cerr << "[Segmentation] Using CPU..." << std::endl;
 //          std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&Segmentation::cloud_cb<Host>, this, _1, _2, _3);
-//          c = grabber.registerCallback (f);
+//          grabber.registerCallback (f);
         }
 
         viewer.runOnVisualizationThread (std::bind(&Segmentation::viz_cb, this, _1), "viz_cb");
index 3ed5934690af54a214bb85828fc3e66a1340eb6c..aa741349f938ac13436e1d84bc7971d95cede559 100644 (file)
  *
  */
 
+#include <pcl/memory.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 #include <pcl/cuda/io/cloud_to_pcl.h>
 #include <pcl/cuda/io/disparity_to_cloud.h>
 #include <pcl/cuda/time_cpu.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-
-#include <boost/shared_ptr.hpp>
 
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 using pcl::cuda::PointCloudAOS;
 using pcl::cuda::Device;
 using pcl::cuda::Host;
@@ -80,7 +80,7 @@ class SimpleKinectTool
 
       std::function<void (const openni_wrapper::Image::Ptr& image, const openni_wrapper::DepthImage::Ptr& depth_image, float)> f = std::bind (&SimpleKinectTool::cloud_cb_, this, _1, _2, _3);
 
-      boost::signals2::connection c = interface->registerCallback (f);
+      interface->registerCallback (f);
 
       //viewer.runOnVisualizationThread (fn, "viz_cb");
       interface->start ();
index 646c840a3fcc96d5caba869aa9bb59e989efce96..0cb5db9dee6066d7c234ec92dff320da18ae5a8c 100644 (file)
  *
  */
 
+#include <pcl/memory.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
 #include <pcl/cuda/io/cloud_to_pcl.h>
 #include <pcl/cuda/io/disparity_to_cloud.h>
 #include <pcl/cuda/time_cpu.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-
-#include <boost/shared_ptr.hpp>
 
 #include <functional>
 #include <iostream>
 #include <mutex>
 
+
 using pcl::cuda::PointCloudAOS;
 using pcl::cuda::Device;
 
index ae606c19d09569e2685120c3eeb7b92eb5b4445d..1f63a38862dfbc6341d73a5527a53e950c54c51e 100644 (file)
@@ -64,7 +64,7 @@ namespace cuda
     inline __host__ __device__ RGB (char _r, char _g, char _b, char _alpha) :
                                        r(_r), g(_g), b(_b), alpha(_alpha) {}
 
-    inline __host__ __device__ bool operator == (const RGB &rhs)
+    inline __host__ __device__ bool operator == (const RGB &rhs) const
     {
       return (r == rhs.r && g == rhs.g && b == rhs.b && alpha == rhs.alpha);
     }
index a69fd331734f8030243ef0fb609e17f700b5f2b2..124d14510d10943847dac99618cc5296a194bb1f 100644 (file)
 
 #pragma once
 
-#include <boost/shared_ptr.hpp>
+#include <pcl/memory.h>
 #include <pcl/cuda/point_cloud.h>
 
+
 namespace pcl
 {
 namespace cuda
index fb78b70fbb7b10efa477c603a5aba5571ef1e883..c152e0f7eff60d895925467af0306768f8e46f42 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <pcl/cuda/point_types.h>
 #include <pcl/cuda/thrust.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 namespace pcl
 {
index 86fb9baa6b18216b61beaeef55a5db21d3863507..500dfd62a02c172e4e67d301de48d1a29941a7db 100644 (file)
@@ -246,8 +246,6 @@ namespace pcl
       if ((int)nearestNeighbors.size () == k_arg)
       {
         double squared_radius;
-        unsigned int pointCountRadiusSearch;
-        unsigned int pointCountCircleSearch;
 
         squared_radius = std::min<double>(nearestNeighbors.back ().squared_distance_, squaredMaxSearchRadius);
 
@@ -259,8 +257,6 @@ namespace pcl
         leftY *=leftY;
         rightY *= rightY;
 
-        pointCountRadiusSearch = (rightX-leftX)*(rightY-leftY);
-
         // search for maximum distance between search point to window borders in 2-D search window
         int maxSearchDistance = 0;
         maxSearchDistance = std::max<int> (maxSearchDistance, leftX + leftY);
@@ -271,70 +267,44 @@ namespace pcl
         maxSearchDistance +=1;
         maxSearchDistance *=maxSearchDistance;
 
-        pointCountCircleSearch= (int)(PI*(double)(maxSearchDistance*maxSearchDistance));
-
-        if (1){//(pointCountCircleSearch<pointCountRadiusSearch) {
+        // check for nearest neighbors within window
+        while ((radiusSearchLookup_Iterator != radiusSearchLookup_.end ())
+            && ((*radiusSearchLookup_Iterator).squared_distance_ <= maxSearchDistance))
+        {
+          // select point from organized point cloud
+          x = x_pos + (*radiusSearchLookup_Iterator).x_diff_;
+          y = y_pos + (*radiusSearchLookup_Iterator).y_diff_;
+          ++radiusSearchLookup_Iterator;
 
-          // check for nearest neighbors within window
-          while ((radiusSearchLookup_Iterator != radiusSearchLookup_.end ())
-              && ((*radiusSearchLookup_Iterator).squared_distance_ <= maxSearchDistance))
+          if ((x >= 0) && (y >= 0) && (x < (int)input_->width) && (y < (int)input_->height))
           {
-            // select point from organized point cloud
-            x = x_pos + (*radiusSearchLookup_Iterator).x_diff_;
-            y = y_pos + (*radiusSearchLookup_Iterator).y_diff_;
-            ++radiusSearchLookup_Iterator;
+            idx = y * (int)input_->width + x;
+            const PointT& point = input_->points[idx];
 
-            if ((x >= 0) && (y >= 0) && (x < (int)input_->width) && (y < (int)input_->height))
+            if ((point.x == point.x) && // check for NaNs
+                (point.y == point.y) && (point.z == point.z))
             {
-              idx = y * (int)input_->width + x;
-              const PointT& point = input_->points[idx];
+              double squared_distance;
 
-              if ((point.x == point.x) && // check for NaNs
-                  (point.y == point.y) && (point.z == point.z))
-              {
-                double squared_distance;
+              const double point_dist_x = point.x - p_q_arg.x;
+              const double point_dist_y = point.y - p_q_arg.y;
+              const double point_dist_z = point.z - p_q_arg.z;
 
-                const double point_dist_x = point.x - p_q_arg.x;
-                const double point_dist_y = point.y - p_q_arg.y;
-                const double point_dist_z = point.z - p_q_arg.z;
+              // calculate squared distance
+              squared_distance = (point_dist_x * point_dist_x + point_dist_y * point_dist_y + point_dist_z
+                  * point_dist_z);
 
-                // calculate squared distance
-                squared_distance = (point_dist_x * point_dist_x + point_dist_y * point_dist_y + point_dist_z
-                    * point_dist_z);
-
-                if ( squared_distance<=squared_radius )
-                {
-                  // add candidate
-                  nearestNeighborCandidate newCandidate;
-                  newCandidate.index_ = idx;
-                  newCandidate.squared_distance_ = squared_distance;
+              if ( squared_distance<=squared_radius )
+              {
+                // add candidate
+                nearestNeighborCandidate newCandidate;
+                newCandidate.index_ = idx;
+                newCandidate.squared_distance_ = squared_distance;
 
-                  nearestNeighbors.push_back (newCandidate);
-                }
+                nearestNeighbors.push_back (newCandidate);
               }
             }
           }
-        } else {
-          std::vector<int> k_radius_indices;
-          std::vector<float> k_radius_distances;
-
-          nearestNeighbors.clear();
-
-          k_radius_indices.reserve (k_arg*2);
-          k_radius_distances.reserve (k_arg*2);
-
-          radiusSearch (p_q_arg, sqrt(squared_radius),k_radius_indices , k_radius_distances);
-
-          std::cout << k_radius_indices.size () <<std::endl;
-
-          for (std::size_t i = 0; i < k_radius_indices.size (); i++)
-          {
-            nearestNeighborCandidate newCandidate;
-            newCandidate.index_ = k_radius_indices[i];
-            newCandidate.squared_distance_ = k_radius_distances[i];
-
-            nearestNeighbors.push_back (newCandidate);
-          }
         }
 
         std::sort (nearestNeighbors.begin (), nearestNeighbors.end ());
index 57d14ff64b96137b2f080e2fdb65ce51fed86e62..f92db88201f96a8097d28628d29b30eeb67f1651 100644 (file)
@@ -3,7 +3,12 @@ if(NOT SPHINX_FOUND)
 endif()
 
 add_custom_target(advanced ALL
-                  COMMAND "${SPHINX_EXECUTABLE}" -b html -a -d "${SPHINX_CACHE_DIR}" -D html_file_suffix=".${SPHINX_HTML_FILE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/content" html)
+                  COMMAND "${SPHINX_EXECUTABLE}"
+                    -b html
+                    -d "${SPHINX_CACHE_DIR}"
+                    -Dversion="${PCL_VERSION_PRETTY}"
+                    -Drelease="${PCL_VERSION_PRETTY}"
+                    "${CMAKE_CURRENT_SOURCE_DIR}/content" html)
 add_dependencies(advanced doc)
 set_target_properties(advanced PROPERTIES FOLDER "Documentation (Advanced)")
 install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
@@ -11,4 +16,4 @@ install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
         COMPONENT doc)
 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/content/files"
         DESTINATION "${DOC_INSTALL_DIR}/advanced"
-        COMPONENT doc)
\ No newline at end of file
+        COMPONENT doc)
diff --git a/doc/advanced/content/_templates/layout.html b/doc/advanced/content/_templates/layout.html
deleted file mode 100644 (file)
index 0516be5..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-<title>Documentation - Point Cloud Library (PCL)</title>
-</head>
-{% extends "!layout.html" %}
-
-{% block extrahead %}
-<?php
-define('MODX_CORE_PATH', '/var/www/pointclouds.org/core/');
-define('MODX_CONFIG_KEY', 'config');
-
-require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
-require_once MODX_CORE_PATH.'model/modx/modx.class.php';
-$modx = new modX();
-$modx->initialize('web');
-
-$snip = $modx->runSnippet("getSiteNavigation", array('id'=>5, 'phLevels'=>'sitenav.level0,sitenav.level1', 'showPageNav'=>'n'));
-$chunkOutput = $modx->getChunk("site-header", array('sitenav'=>$snip));
-$bodytag = str_replace("[[+showSubmenus:notempty=`", "", $chunkOutput);
-$bodytag = str_replace("`]]", "", $bodytag);
-echo $bodytag;
-echo "\n";
-?>
-<div id="pagetitle">
-<h1>Documentation</h1>
-<a id="donate" href="http://www.openperception.org/support/"><img src="/assets/images/donate-button.png" alt="Donate to the Open Perception foundation"/></a>
-</div>
-<div id="page-content">
-{% endblock %}
-
-{% block relbar1 %}{% endblock %}
-{% block relbar2 %}{% endblock %}
-{% block rootrellink %}{% endblock %}
-
-{% block sidebarsearch %}{% endblock %}
-
-{% block footer %}
-</div> <!-- #page-content -->
-
-<?php
-$chunkOutput = $modx->getChunk("site-footer");
-echo $chunkOutput;
-?>
-{% endblock %}
-</html>
-
index 22a3803d199639ff9384b345800c1ec7dcda31b9..2753d7ee96d06318931a1851ffe9036aba70de60 100644 (file)
@@ -1,15 +1,13 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os
-
 # -- General configuration -----------------------------------------------------
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.imgmath', 'sphinxcontrib.doxylink.doxylink']
 
 # Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ['_templates']
 
 # The suffix of source filenames.
 source_suffix = '.rst'
@@ -18,7 +16,7 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'PCL'
+project = u'Point Cloud Library'
 copyright = ''
 
 # The version info for the project you're documenting, acts as replacement for
@@ -71,7 +69,7 @@ pygments_style = 'sphinx'
 
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'sphinxdoc'
+html_theme = 'sphinx_rtd_theme'
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
@@ -106,7 +104,7 @@ html_static_path = ['_static']
 html_use_modindex = False
 
 # If false, no index is generated.
-html_use_index = False
+html_use_index = True
 
 # If true, the index is split into individual pages for each letter.
 html_split_index = False
@@ -121,13 +119,8 @@ html_show_sourcelink = False
 
 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
 html_file_suffix = '.html'
-
-html_sidebars = {
-    '**': [],
-    'using/windows': [],
-}
-html_show_copyright = False
-html_show_sphinx = False
+html_show_copyright = True
+html_show_sphinx = True
 html_add_permalinks = None
 needs_sphinx = '1.0'
 file_insertion_enabled = True
index 325fe48a34e8caaef3ad70509eba4ead51712c40..aafbe48692b24b7d9d982b00e8a8164181564697 100644 (file)
@@ -167,27 +167,20 @@ variant of the GNU style formatting.
 2.1. Namespaces
 ^^^^^^^^^^^^^^^
 
-In a header file, the contets of a namespace should be indented, e.g.:
+In both header and implementation files, namespaces are to be explicitly
+declared, and their contents should not be indented, like clang-format
+enforces in the Formatting CI job, e.g.:
 
 .. code-block:: cpp
 
   namespace pcl
   {
-    class Foo
-    {
-      ...
-    };
-  }
-
-In an implementation file, the namespace must be added to each individual
-method or function definition, e.g.:
-
-.. code-block:: cpp
 
-  void
-  pcl::Foo::bar ()
+  class Foo
   {
     ...
+  };
+
   }
 
 
@@ -281,19 +274,6 @@ function/method, e.g.:
    int 
    exampleMethod (int example_arg);
 
-If multiple namespaces are declared within header files, always use **2
-spaces** to indent them, e.g.:
-
-.. code-block:: cpp
-
-   namespace foo
-   {
-     namespace bar
-     {
-        void
-        method (int my_var);
-      }
-   }
 
 Class and struct members are indented by **2 spaces**. Access qualifiers (public, private and protected) are put at the
 indentation level of the class body and members affected by these qualifiers are indented by one more level, i.e. 2 spaces. E.g.:
@@ -302,79 +282,98 @@ indentation level of the class body and members affected by these qualifiers are
 
    namespace foo
    {
-     class Bar
-     {
-       int i;
-       public:
-         int j;
-       protected:
-         void
-         baz ();
-     }
+
+   class Bar
+   {
+     int i;
+     public:
+       int j;
+     protected:
+       void
+       baz ();
+   };
    }
 
 
 2.6. Automatic code formatting
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-The following set of rules can be automatically used by various different IDEs,
-editors, etc.
+We currently use clang-format-10 as the tool for auto-formatting our C++ code.
+Please note that different versions of clang-format can result in slightly different outputs.
 
-2.6.1. Emacs
-""""""""""""
+The style rules mentioned in this document are enforced via `PCL's .clang-format file
+<https://github.com/PointCloudLibrary/pcl/blob/master/.clang-format>`_.
+The style files which were previously distributed should now be considered deprecated.
 
-You can use the following `PCL C/C++ style file
-<https://raw.githubusercontent.com/PointCloudLibrary/pcl/master/doc/advanced/content/files/pcl-c-style.el>`_,
-download it to some known location and then:
+For the integration of clang-format with various text editors and IDE's, refer to this `page
+<https://clang.llvm.org/docs/ClangFormat.html>`_.
 
-* open .emacs 
-* add the following before any C/C++ custom hooks
+Details about the style options used can be found `here
+<https://clang.llvm.org/docs/ClangFormatStyleOptions.html>`_.
 
-::
+2.6.1. Script usage
+"""""""""""""""""""
 
-   (load-file "/location/to/pcl-c-style.el")
-   (add-hook 'c-mode-common-hook 'pcl-set-c-style)
+PCL also creates a build target 'format' to format the whitelisted directories using clang-format.
 
-2.6.2. Uncrustify
-"""""""""""""""""
+Command line usage:
 
-You can find a semi-finished config for `Uncrustify <http://uncrustify.sourceforge.net/>`_ `here
-<http://dev.pointclouds.org/attachments/download/537/uncrustify.cfg>`_
+.. code-block:: shell
 
-2.6.3 Eclipse
-"""""""""""""
+   $ make format
 
-| You can find a PCL code style file for Eclipse `on GitHub <https://github.com/PointCloudLibrary/pcl/tree/master/doc/advanced/content/files>`_.
-| To add the new formatting style go to: Windows > Preferences > C/C++ > Code Style > Formatter
 
-| To format portion of codes, select the code and press Ctrl + Shift + F.
-| If you want to format the whole code in your project go to the tree and right click on the project: Source > Format.
+2.7. Includes
+^^^^^^^^^^^^^
 
-Note that the Eclipse formatter style is configured to wrap all arguments in a function, feel free to re-arange the arguments if you feel the need; for example,
-this improves readability:
+For consistent usage, headers should be included in the following order with alphabetical grouping ensured:
 
-.. code-block:: cpp
+1.  PCL headers
 
-   int
-   displayPoint (float x, float y, float z,
-                 float r, float g, float b
-                );
+    i.  All modular PCL includes, except main includes of common module.
+        
+        Examples:
 
-This eclipse formatter fails to add a space before brackets when using PCL macros:
+        .. code-block:: cpp
 
-.. code-block:: cpp
+           #include <pcl/common/common.h>
+           #include <pcl/simulation/camera.h>
+           #include <pcl/ml/dt/decision_forest.h>
 
-   PCL_ERROR("Text\n");
+    #.  The main PCL includes of common module. These are the header files in the ``pcl/common/include/pcl/`` directory.
+    
+        Examples:
 
-should be
+        .. code-block:: cpp
 
-.. code-block:: cpp
+           #include <pcl/memory.h>
+           #include <pcl/pcl_macros.h>
+           #include <pcl/point_cloud.h>
 
-   PCL_ERROR ("Text\n");
+2.  Major 3rd-Party components of tests and modules
 
-.. note::
+    i.  gtest
+    #.  boost
+    #.  Eigen
+    #.  flann
+3.  Major 3rd-Party components of apps
+
+    i.  Qt
+    #.  ui-files
+    #.  vtk
+4.  Minor 3rd-Party components
+
+    i.  librealsense
+    #.  ros/message_filters
+    #.  opencv/opencv2
+    #.  tide
+    #.  thrust
+    #.  OpenGL, GL & GLUT
+5.  C++ standard library headers (alphabetical)
+6.  Others
+
+This style can also be enforced via clang-format. For usage instructions, refer `2.6. Automatic code formatting`_.
 
-   This style sheet is not perfect, please mention errors on the user mailing list and feel free to patch!
 
 3. Structuring
 ==============
@@ -410,3 +409,18 @@ For the compute, filter, segment, etc. type methods the following rules apply:
   size.
 * The output arguments will always be passed by reference.
 
+3.3. Object declaration
+^^^^^^^^^^^^^^^^^^^^^^^
+
+3.3.1 Use of auto
+"""""""""""""""""
+* For Iterators auto must be used as much as possible 
+* In all the other cases auto can be used at the author's discretion
+* Use const auto references by default in range loops. Drop the const if the item needs to be modified.
+
+3.3.2 Type qualifiers of variables
+""""""""""""""""""""""""""""""""""
+* Declare variables const when they don't need to be modified.
+* Use const references whenever you don't need a copy of the variable. 
+* Use of unsigned variables if the value is sure to not go negative by 
+  use and by definition of the variable
diff --git a/doc/doxygen/.gitignore b/doc/doxygen/.gitignore
new file mode 100644 (file)
index 0000000..695b5ed
--- /dev/null
@@ -0,0 +1 @@
+pcl.tag
index 831bbe8e4d124a0603e59efb27b92eb66951884a..c2eff7b03b3cfaf94091723c7ac9245da7183d6e 100644 (file)
@@ -37,11 +37,28 @@ endif()
 
 set(STRIPPED_HEADERS "${PCL_SOURCE_DIR}/${PCL_MODULES_NAMES}/include")
 string(REPLACE ";" "/include \\\n                         ${PCL_SOURCE_DIR}/" STRIPPED_HEADERS "${STRIPPED_HEADERS}")
-set(DOC_SOURCE_DIR "\"${PCL_SOURCE_DIR}\"\\")
+set(DOC_SOURCE_DIR "${PCL_SOURCE_DIR}")
 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html")
 set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/doxyfile")
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in" "${doxyfile}")
-add_custom_target(doc ALL "${DOXYGEN_EXECUTABLE}" "${doxyfile}")
+
+# The following process to use a stamp file is customized from the CMake 3.16.5 `doxygen_add_docs` command
+set(STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/doc.stamp")
+add_custom_command(
+    VERBATIM
+    OUTPUT ${STAMP_FILE}
+    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}
+    COMMAND "${DOXYGEN_EXECUTABLE}" "${doxyfile}"
+    COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_FILE}
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    DEPENDS "${doxyfile}" ${DOC_SOURCE_DIR}
+    COMMENT "Generate stamp file for target doc"
+)
+add_custom_target(doc ALL
+    DEPENDS ${STAMP_FILE}
+    SOURCES ${DOC_SOURCE_DIR}
+)
+
 set_target_properties(doc PROPERTIES FOLDER "Documentation (Doxygen)")
 if(DOCUMENTATION_HTML_HELP STREQUAL YES)
   install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
index 1f876f3f2e738237fda427e4a2d9b952839bf212..fb8e54bd737cf67387459a53d173f08f3e555db2 100644 (file)
@@ -8,6 +8,7 @@ PROJECT_BRIEF          =
 PROJECT_LOGO           =
 OUTPUT_DIRECTORY       = "@CMAKE_CURRENT_BINARY_DIR@"
 CREATE_SUBDIRS         = NO
+ALLOW_UNICODE_NAMES    = NO
 OUTPUT_LANGUAGE        = English
 BRIEF_MEMBER_DESC      = YES
 REPEAT_BRIEF           = YES
@@ -42,11 +43,14 @@ OPTIMIZE_FOR_FORTRAN   = NO
 OPTIMIZE_OUTPUT_VHDL   = NO
 EXTENSION_MAPPING      =
 MARKDOWN_SUPPORT       = YES
+TOC_INCLUDE_HEADINGS   = 5
+AUTOLINK_SUPPORT       = YES
 BUILTIN_STL_SUPPORT    = NO
 CPP_CLI_SUPPORT        = NO
 SIP_SUPPORT            = NO
 IDL_PROPERTY_SUPPORT   = YES
 DISTRIBUTE_GROUP_DOC   = NO
+GROUP_NESTED_COMPOUNDS = NO
 SUBGROUPING            = YES
 INLINE_GROUPED_CLASSES = NO
 INLINE_SIMPLE_STRUCTS  = NO
@@ -70,7 +74,9 @@ HIDE_IN_BODY_DOCS      = NO
 INTERNAL_DOCS          = NO
 CASE_SENSE_NAMES       = NO
 HIDE_SCOPE_NAMES       = NO
+HIDE_COMPOUND_REFERENCE= NO
 SHOW_INCLUDE_FILES     = YES
+SHOW_GROUPED_MEMB_INC  = YES
 FORCE_LOCAL_INCLUDES   = NO
 INLINE_INFO            = YES
 SORT_MEMBER_DOCS       = YES
@@ -79,10 +85,10 @@ SORT_MEMBERS_CTORS_1ST = NO
 SORT_GROUP_NAMES       = NO
 SORT_BY_SCOPE_NAME     = NO
 STRICT_PROTO_MATCHING  = NO
-GENERATE_TODOLIST      = NO
+GENERATE_TODOLIST      = YES
 GENERATE_TESTLIST      = NO
 GENERATE_BUGLIST       = NO
-GENERATE_DEPRECATEDLIST= NO
+GENERATE_DEPRECATEDLIST= YES
 ENABLED_SECTIONS       =
 MAX_INITIALIZER_LINES  = 30
 SHOW_USED_FILES        = YES
@@ -93,18 +99,19 @@ LAYOUT_FILE            = "@PCL_SOURCE_DIR@/doc/doxygen/doxygen_layout.xml"
 CITE_BIB_FILES         =
 
 #---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
+# Configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 QUIET                  = YES
 WARNINGS               = YES
 WARN_IF_UNDOCUMENTED   = YES
 WARN_IF_DOC_ERROR      = YES
 WARN_NO_PARAMDOC       = NO
+WARN_AS_ERROR          = NO
 WARN_FORMAT            = "$file:$line: $text "
 WARN_LOGFILE           =
 
 #---------------------------------------------------------------------------
-# configuration options related to the input files
+# Configuration options related to the input files
 #---------------------------------------------------------------------------
 INPUT                  = "@PCL_SOURCE_DIR@" \
                          "@PCL_SOURCE_DIR@/doc/doxygen"
@@ -137,9 +144,10 @@ INPUT_FILTER           =
 FILTER_PATTERNS        =
 FILTER_SOURCE_FILES    = NO
 FILTER_SOURCE_PATTERNS =
+USE_MDFILE_AS_MAINPAGE =
 
 #---------------------------------------------------------------------------
-# configuration options related to source browsing
+# Configuration options related to source browsing
 #---------------------------------------------------------------------------
 SOURCE_BROWSER         = YES
 INLINE_SOURCES         = NO
@@ -147,18 +155,19 @@ STRIP_CODE_COMMENTS    = NO
 REFERENCED_BY_RELATION = YES
 REFERENCES_RELATION    = YES
 REFERENCES_LINK_SOURCE = YES
+SOURCE_TOOLTIPS        = YES
 USE_HTAGS              = NO
 VERBATIM_HEADERS       = YES
 
 #---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
+# Configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 ALPHABETICAL_INDEX     = YES
 COLS_IN_ALPHA_INDEX    = 5
 IGNORE_PREFIX          =
 
 #---------------------------------------------------------------------------
-# configuration options related to the HTML output
+# Configuration options related to the HTML output
 #---------------------------------------------------------------------------
 GENERATE_HTML          = YES
 HTML_OUTPUT            = html
@@ -166,12 +175,14 @@ HTML_FILE_EXTENSION    = .html
 HTML_HEADER            =
 HTML_FOOTER            = @PCL_SOURCE_DIR@/doc/doxygen/footer.html
 HTML_STYLESHEET        =
+HTML_EXTRA_STYLESHEET  =
 HTML_EXTRA_FILES       =
 HTML_COLORSTYLE_HUE    = 87
 HTML_COLORSTYLE_SAT    = 46
 HTML_COLORSTYLE_GAMMA  = 73
 HTML_TIMESTAMP         = YES
 HTML_DYNAMIC_SECTIONS  = YES
+HTML_INDEX_NUM_ENTRIES = 100
 GENERATE_DOCSET        = YES
 DOCSET_FEEDNAME        = "Doxygen generated docs"
 DOCSET_BUNDLE_ID       = pointclouds.org
@@ -202,13 +213,20 @@ EXT_LINKS_IN_WINDOW    = NO
 FORMULA_FONTSIZE       = 10
 FORMULA_TRANSPARENT    = YES
 USE_MATHJAX            = NO
+MATHJAX_FORMAT         = HTML-CSS
 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
 MATHJAX_EXTENSIONS     =
+MATHJAX_CODEFILE       =
 SEARCHENGINE           = @DOCUMENTATION_SEARCHENGINE@
 SERVER_BASED_SEARCH    = NO
+EXTERNAL_SEARCH        = NO
+SEARCHENGINE_URL       =
+SEARCHDATA_FILE        = searchdata.xml
+EXTERNAL_SEARCH_ID     =
+EXTRA_SEARCH_MAPPINGS  =
 
 #---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
+# Configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
 GENERATE_LATEX         = YES
 LATEX_OUTPUT           = latex
@@ -219,15 +237,18 @@ PAPER_TYPE             = a4wide
 EXTRA_PACKAGES         = amsmath amssymb
 LATEX_HEADER           =
 LATEX_FOOTER           =
+LATEX_EXTRA_STYLESHEET =
+LATEX_EXTRA_FILES      =
 PDF_HYPERLINKS         = YES
 USE_PDFLATEX           = YES
 LATEX_BATCHMODE        = NO
 LATEX_HIDE_INDICES     = NO
 LATEX_SOURCE_CODE      = NO
 LATEX_BIB_STYLE        = plain
+LATEX_TIMESTAMP        = NO
 
 #---------------------------------------------------------------------------
-# configuration options related to the RTF output
+# Configuration options related to the RTF output
 #---------------------------------------------------------------------------
 GENERATE_RTF           = NO
 RTF_OUTPUT             = rtf
@@ -235,29 +256,38 @@ COMPACT_RTF            = NO
 RTF_HYPERLINKS         = NO
 RTF_STYLESHEET_FILE    =
 RTF_EXTENSIONS_FILE    =
+RTF_SOURCE_CODE        = NO
 
 #---------------------------------------------------------------------------
-# configuration options related to the man page output
+# Configuration options related to the man page output
 #---------------------------------------------------------------------------
 GENERATE_MAN           = NO
 MAN_OUTPUT             = man
 MAN_EXTENSION          = .3
+MAN_SUBDIR             =
 MAN_LINKS              = NO
 
 #---------------------------------------------------------------------------
-# configuration options related to the XML output
+# Configuration options related to the XML output
 #---------------------------------------------------------------------------
 GENERATE_XML           = NO
 XML_OUTPUT             = xml
 XML_PROGRAMLISTING     = YES
 
 #---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+GENERATE_DOCBOOK       = NO
+DOCBOOK_OUTPUT         = docbook
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
 #---------------------------------------------------------------------------
 GENERATE_AUTOGEN_DEF   = NO
 
 #---------------------------------------------------------------------------
-# configuration options related to the Perl module output
+# Configuration options related to the Perl module output
 #---------------------------------------------------------------------------
 GENERATE_PERLMOD       = NO
 PERLMOD_LATEX          = NO
@@ -280,25 +310,27 @@ PREDEFINED =           = "HAVE_QHULL=1" \
                          "HAVE_DAVIDSDK=1" \
                          "HAVE_DSSDK=1" \
                          "HAVE_RSSDK=1" \
-                         "DOXYGEN_ONLY=1"
+                         "DOXYGEN_ONLY=1" \
+                         "_WIN32=1" \
+                         "PCL_DEPRECATED(major,minor,message)=/** \deprecated Scheduled for removal in version major.\ minor: message */"
 EXPAND_AS_DEFINED      =
 SKIP_FUNCTION_MACROS   = YES
 
 #---------------------------------------------------------------------------
-# Configuration::additions related to external references
+# Configuration options related to external references
 #---------------------------------------------------------------------------
 TAGFILES               =
 #TAGFILES               = qtools_docs/qtools.tag=../../qtools_docs/html
 GENERATE_TAGFILE       = pcl.tag
 ALLEXTERNALS           = NO
 EXTERNAL_GROUPS        = YES
-PERL_PATH              = /usr/bin/perl
+EXTERNAL_PAGES         = YES
 
 #---------------------------------------------------------------------------
 # Configuration options related to the dot tool
 #---------------------------------------------------------------------------
 CLASS_DIAGRAMS         = YES
-MSCGEN_PATH            =
+DIA_PATH               =
 HIDE_UNDOC_RELATIONS   = YES
 HAVE_DOT               = @HAVE_DOT@
 DOT_NUM_THREADS        = 0
@@ -322,7 +354,11 @@ INTERACTIVE_SVG        = YES
 DOT_PATH               =
 DOTFILE_DIRS           =
 MSCFILE_DIRS           =
-DOT_GRAPH_MAX_NODES    = 50
+DIAFILE_DIRS           =
+PLANTUML_JAR_PATH      =
+PLANTUML_CFG_FILE      =
+PLANTUML_INCLUDE_PATH  =
+DOT_GRAPH_MAX_NODES    = 250
 MAX_DOT_GRAPH_DEPTH    = 0
 DOT_TRANSPARENT        = YES
 DOT_MULTI_TARGETS      = NO
index b23a02f32c4da4c3bf8c9e3daff55937259bb8e4..29a0f91ce679763d9798314cac5725b17e13dc76 100644 (file)
@@ -28,9 +28,10 @@ Please visit http://www.pointclouds.org for more information.
 
 <h1>Quick Links</h1>
 <ul>
-  <li>Main website: http://www.pointclouds.org</li>
-  <li>Developer Zone: https://github.com/PointCloudLibrary</li>
-  <li>Build farm: https://travis-ci.org/PointCloudLibrary/pcl</li>
+  <li>Main Website: http://www.pointclouds.org</li>
+  <li>GitHub Repository: https://github.com/PointCloudLibrary</li>
+  <li>Continuous Integration: https://dev.azure.com/PointCloudLibrary/pcl/_build</li>
+  <li>Changelog: https://pointcloudlibrary.github.io/documentation/changelog.html</li>
 </ul>
 
 <h1>References</h1>
diff --git a/doc/requirements.txt b/doc/requirements.txt
new file mode 100644 (file)
index 0000000..03f46b6
--- /dev/null
@@ -0,0 +1,2 @@
+sphinx
+sphinxcontrib-doxylink
index 5282c37a50f1aa3635ed5dcb2a80ab4c3f4cda38..b0c7712441c09f849aa34634079c912ae9aa454d 100644 (file)
@@ -3,7 +3,12 @@ if(NOT SPHINX_FOUND)
 endif()
 
 add_custom_target(tutorials ALL
-                  COMMAND "${SPHINX_EXECUTABLE}" -b html -a -d "${SPHINX_CACHE_DIR}" -D html_file_suffix=".${SPHINX_HTML_FILE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/content" html)
+                  COMMAND "${SPHINX_EXECUTABLE}"
+                         -b html
+                         -d "${SPHINX_CACHE_DIR}"
+                         -Dversion="${PCL_VERSION_PRETTY}"
+                         -Drelease="${PCL_VERSION_PRETTY}"
+                         "${CMAKE_CURRENT_SOURCE_DIR}/content" html)
 add_dependencies(tutorials doc)
 set_target_properties(tutorials PROPERTIES FOLDER "Documentation (Tutorials)")
 install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
diff --git a/doc/tutorials/content/_templates/layout.html b/doc/tutorials/content/_templates/layout.html
deleted file mode 100644 (file)
index 0516be5..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-<title>Documentation - Point Cloud Library (PCL)</title>
-</head>
-{% extends "!layout.html" %}
-
-{% block extrahead %}
-<?php
-define('MODX_CORE_PATH', '/var/www/pointclouds.org/core/');
-define('MODX_CONFIG_KEY', 'config');
-
-require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
-require_once MODX_CORE_PATH.'model/modx/modx.class.php';
-$modx = new modX();
-$modx->initialize('web');
-
-$snip = $modx->runSnippet("getSiteNavigation", array('id'=>5, 'phLevels'=>'sitenav.level0,sitenav.level1', 'showPageNav'=>'n'));
-$chunkOutput = $modx->getChunk("site-header", array('sitenav'=>$snip));
-$bodytag = str_replace("[[+showSubmenus:notempty=`", "", $chunkOutput);
-$bodytag = str_replace("`]]", "", $bodytag);
-echo $bodytag;
-echo "\n";
-?>
-<div id="pagetitle">
-<h1>Documentation</h1>
-<a id="donate" href="http://www.openperception.org/support/"><img src="/assets/images/donate-button.png" alt="Donate to the Open Perception foundation"/></a>
-</div>
-<div id="page-content">
-{% endblock %}
-
-{% block relbar1 %}{% endblock %}
-{% block relbar2 %}{% endblock %}
-{% block rootrellink %}{% endblock %}
-
-{% block sidebarsearch %}{% endblock %}
-
-{% block footer %}
-</div> <!-- #page-content -->
-
-<?php
-$chunkOutput = $modx->getChunk("site-footer");
-echo $chunkOutput;
-?>
-{% endblock %}
-</html>
-
index 350e7964c74e944ec629aad11e218f2b1542e9c4..6bf3fa9ed1140dd276888322a4f7b22bdce31436 100644 (file)
@@ -6,7 +6,7 @@ Adding your own custom `PointT` type
 The current document explains not only how to add your own `PointT` point type,
 but also what templated point types are in PCL, why do they exist, and how are
 they exposed. If you're already familiar with this information, feel free to
-skip to the last part of the document. 
+skip to the last part of the document.
 
 .. contents::
 
@@ -72,7 +72,7 @@ to understand why the existing types were created they way they were. In
 addition, the type that you want, might already be defined for you.
 
 * `PointXYZ` - Members: float x, y, z;
-  
+
   This is one of the most used data types, as it represents 3D xyz information
   only. The 3 floats are padded with an additional float for SSE alignment. The
   user can either access `points[i].data[0]` or `points[i].x` for accessing
@@ -80,10 +80,10 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
@@ -100,16 +100,16 @@ addition, the type that you want, might already be defined for you.
   `intensity` a member of the same structure, as its contents will be
   overwritten. For example, a dot product between two points will set their 4th
   component to 0, otherwise the dot product doesn't make sense, etc.
-  
+
   Therefore for SSE-alignment, we pad intensity with 3 extra floats.
   Inefficient in terms of storage, but good in terms of memory alignment.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
@@ -188,10 +188,10 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
@@ -223,20 +223,20 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data_n[4];
     float normal[3];
-    struct 
+    struct
     {
       float normal_x;
       float normal_y;
       float normal_z;
     };
   }
-  union 
+  union
   {
-    struct 
+    struct
     {
       float curvature;
     };
@@ -250,30 +250,30 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
       float z;
     };
   };
-  union 
+  union
   {
     float data_n[4];
     float normal[3];
-    struct 
+    struct
     {
       float normal_x;
       float normal_y;
       float normal_z;
     };
   };
-  union 
+  union
   {
-    struct 
+    struct
     {
       float curvature;
     };
@@ -292,21 +292,21 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
       float z;
     };
   };
-  union 
+  union
   {
     float data_n[4];
     float normal[3];
-    struct 
+    struct
     {
       float normal_x;
       float normal_y;
@@ -345,30 +345,30 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
       float z;
     };
   };
-  union 
+  union
   {
     float data_n[4];
     float normal[3];
-    struct 
+    struct
     {
       float normal_x;
       float normal_y;
       float normal_z;
     };
   }
-  union 
+  union
   {
-    struct 
+    struct
     {
       float intensity;
       float curvature;
@@ -383,10 +383,10 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
@@ -410,10 +410,10 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
@@ -435,7 +435,7 @@ addition, the type that you want, might already be defined for you.
 * `MomentInvariants` - float j1, j2, j3;
 
   Simple point type holding the 3 moment invariants at a surface patch. See
-  `MomentInvariantsEstimation` for more information. 
+  `MomentInvariantsEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -447,7 +447,7 @@ addition, the type that you want, might already be defined for you.
 * `PrincipalRadiiRSD` - float r_min, r_max;
 
   Simple point type holding the 2 RSD radii at a surface patch. See
-  `RSDEstimation` for more information. 
+  `RSDEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -459,7 +459,7 @@ addition, the type that you want, might already be defined for you.
 * `Boundary` - std::uint8_t boundary_point;
 
   Simple point type holding whether the point is lying on a surface boundary or
-  not. See `BoundaryEstimation` for more information. 
+  not. See `BoundaryEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -471,7 +471,7 @@ addition, the type that you want, might already be defined for you.
 * `PrincipalCurvatures` - float principal_curvature[3], pc1, pc2;
 
   Simple point type holding the principal curvatures of a given point. See
-  `PrincipalCurvaturesEstimation` for more information. 
+  `PrincipalCurvaturesEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -494,7 +494,7 @@ addition, the type that you want, might already be defined for you.
 * `PFHSignature125` - float pfh[125];
 
   Simple point type holding the PFH (Point Feature Histogram) of a given point.
-  See `PFHEstimation` for more information. 
+  See `PFHEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -506,7 +506,7 @@ addition, the type that you want, might already be defined for you.
 * `FPFHSignature33` - float fpfh[33];
 
   Simple point type holding the FPFH (Fast Point Feature Histogram) of a given
-  point.  See `FPFHEstimation` for more information. 
+  point.  See `FPFHEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -518,7 +518,7 @@ addition, the type that you want, might already be defined for you.
 * `VFHSignature308` - float vfh[308];
 
   Simple point type holding the VFH (Viewpoint Feature Histogram) of a given
-  point.  See `VFHEstimation` for more information. 
+  point.  See `VFHEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -530,7 +530,7 @@ addition, the type that you want, might already be defined for you.
 * `Narf36` - float x, y, z, roll, pitch, yaw; float descriptor[36];
 
   Simple point type holding the NARF (Normally Aligned Radius Feature) of a given
-  point.  See `NARFEstimation` for more information. 
+  point.  See `NARFEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -543,7 +543,7 @@ addition, the type that you want, might already be defined for you.
 * `BorderDescription` - int x, y; BorderTraits traits;
 
   Simple point type holding the border type of a given point.  See
-  `BorderEstimation` for more information. 
+  `BorderEstimation` for more information.
 
 .. code-block:: cpp
 
@@ -556,12 +556,12 @@ addition, the type that you want, might already be defined for you.
 * `IntensityGradient` - float gradient[3];
 
   Simple point type holding the intensity gradient of a given point.  See
-  `IntensityGradientEstimation` for more information. 
+  `IntensityGradientEstimation` for more information.
 
 .. code-block:: cpp
 
   struct
-  { 
+  {
     union
     {
       float gradient[3];
@@ -571,8 +571,8 @@ addition, the type that you want, might already be defined for you.
         float gradient_y;
         float gradient_z;
       };
-    };  
-  };     
+    };
+  };
 
 * `Histogram` - float histogram[N];
 
@@ -596,10 +596,10 @@ addition, the type that you want, might already be defined for you.
 
   struct
   {
-    union 
+    union
     {
       float data[4];
-      struct 
+      struct
       {
         float x;
         float y;
@@ -616,21 +616,21 @@ addition, the type that you want, might already be defined for you.
 
 .. code-block:: cpp
 
-  union 
+  union
   {
     float data[4];
-    struct 
+    struct
     {
       float x;
       float y;
       float z;
     };
   };
-  union 
+  union
   {
     float data_n[4];
     float normal[3];
-    struct 
+    struct
     {
       float normal_x;
       float normal_y;
@@ -681,7 +681,7 @@ fictitious example:
    {
      public:
        void
-       compute (const pcl::PointCloud<PointT> &input, 
+       compute (const pcl::PointCloud<PointT> &input,
                 pcl::PointCloud<PointT> &output);
    }
 
@@ -702,7 +702,7 @@ anything yet.
    #include "foo.h"
 
    template <typename PointT> void
-   Foo::compute (const pcl::PointCloud<PointT> &input, 
+   Foo::compute (const pcl::PointCloud<PointT> &input,
                  pcl::PointCloud<PointT> &output)
    {
      output = input;
@@ -715,7 +715,7 @@ The above defines the actual template implementation of the method
 
 .. code-block:: cpp
    :linenos:
-   
+
    // foo.cpp
 
    #include "pcl/point_types.h"
@@ -765,7 +765,7 @@ following would do:
 
 .. code-block:: cpp
    :linenos:
-   
+
    // foo.cpp
 
    #include "pcl/point_types.h"
@@ -786,7 +786,7 @@ To add a new point type, you first have to define it. For example:
 
 .. code-block:: cpp
    :linenos:
+
    struct MyPointType
    {
      float test;
@@ -824,6 +824,7 @@ data (SSE padded), together with a test float.
    :linenos:
 
    #define PCL_NO_PRECOMPILE
+   #include <pcl/memory.h>
    #include <pcl/pcl_macros.h>
    #include <pcl/point_types.h>
    #include <pcl/point_cloud.h>
index 21888cdf5346bf533a666d9fa9988879e83c1195..d8c71ea4512364a9adee32e120fd29253bc28e63 100644 (file)
@@ -16,7 +16,7 @@ A clustering method needs to divide an unorganized point cloud model :math:`P`
 into smaller parts so that the overall processing time for :math:`P` is
 significantly reduced. A simple data clustering approach in an Euclidean sense
 can be implemented by making use of a 3D grid subdivision of the space using
-fixed width boxes, or more generally, an octree data structure. This particular
+fixed-width boxes, or more generally, an octree data structure. This particular
 representation is very fast to build and is useful for situations where either
 a volumetric representation of the occupied space is needed, or the data in
 each resultant 3D box (or octree leaf) can be approximated with a different
@@ -24,7 +24,7 @@ structure. In a more general sense however, we can make use of nearest
 neighbors and implement a clustering technique that is essentially similar to a
 flood fill algorithm.
 
-Let's assume we have given a point cloud with a table and objects on top of it.
+Let's assume we are given a point cloud with a table and objects on top of it.
 We want to find and segment the individual object point clusters lying on the
 plane. Assuming that we use a Kd-tree structure for finding the nearest
 neighbors, the algorithmic steps for that would be (from [RusuDissertation]_):
@@ -41,7 +41,7 @@ neighbors, the algorithmic steps for that would be (from [RusuDissertation]_):
 
      * *for every point* :math:`\boldsymbol{p}_i \in Q` *do:*
 
-        * *search for the set* :math:`P^i_k` *of point neighbors of* :math:`\boldsymbol{p}_i` *in a sphere with radius* :math:`r < d_{th}`;
+        * *search for the set* :math:`P^k_i` *of point neighbors of* :math:`\boldsymbol{p}_i` *in a sphere with radius* :math:`r < d_{th}`;
 
         * *for every neighbor* :math:`\boldsymbol{p}^k_i \in P^k_i`, *check if the point has already been processed, and if not add it to* :math:`Q`;
 
index 9190ca76a3dc245b9abb953242170ffa1b6d80eb..6eaf69bcdfd59f121baa7c60d976229d0218647a 100644 (file)
@@ -1,8 +1,6 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os
-
 # -- General configuration -----------------------------------------------------
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
@@ -10,7 +8,7 @@ extensions = ['sphinx.ext.imgmath', 'sphinxcontrib.doxylink.doxylink']
 imgmath_dvipng_args = ['-gamma', '1.5', '-D', '110', '-bg', 'Transparent']
 
 # Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ['_templates']
 
 # The suffix of source filenames.
 source_suffix = '.rst'
@@ -19,7 +17,7 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'PCL'
+project = u'Point Cloud Library'
 copyright = ''
 
 # The version info for the project you're documenting, acts as replacement for
@@ -72,7 +70,7 @@ pygments_style = 'sphinx'
 
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'sphinxdoc'
+html_theme = 'sphinx_rtd_theme'
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
@@ -107,7 +105,7 @@ html_static_path = ['_static']
 html_use_modindex = False
 
 # If false, no index is generated.
-html_use_index = False
+html_use_index = True
 
 # If true, the index is split into individual pages for each letter.
 html_split_index = False
@@ -122,13 +120,8 @@ html_show_sourcelink = False
 
 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
 html_file_suffix = '.html'
-
-html_sidebars = {
-    '**': [],
-    'using/windows': [],
-}
-html_show_copyright = False
-html_show_sphinx = False
+html_show_copyright = True
+html_show_sphinx = True
 html_add_permalinks = u''
 needs_sphinx = u'1.1'
 file_insertion_enabled = True
index 956a500aa351948bba9bce653f3cffee1f6bd2c0..3fa12db805cf64330a8bfa038bbd22c4a5d8cd95 100644 (file)
@@ -37,7 +37,7 @@ gets created and the reconstruction is performed:
 
 .. literalinclude:: sources/convex_hull_2d/convex_hull_2d.cpp
    :language: cpp
-   :lines: 48-51
+   :lines: 49-52
 
 
 Compiling and running the program
index 7098d80d912e5a7d715900802549a30553fee5df..f05d717d486fc6de712640bcf393bb7a855cd8ba 100644 (file)
@@ -45,7 +45,7 @@ In general, PCL features use approximate methods to compute the nearest neighbor
 Terminology
 -----------
 
-For the reminder of this article, we will make certain abbreviations and
+For the remainder of this article, we will make certain abbreviations and
 introduce certain notations, to simplify the in-text explanations. Please see
 the table below for a reference on each of the terms used.
 
@@ -71,7 +71,7 @@ the `pcl::Feature` class accepts input data in two different ways:
 
  1. an entire point cloud dataset, given via **setInputCloud (PointCloudConstPtr &)** - **mandatory**
 
-    Any feature estimation class with attempt to estimate a feature at **every** point in the given input cloud.
+    Any feature estimation class will attempt to estimate a feature at **every** point in the given input cloud.
 
  2. a subset of a point cloud dataset, given via **setInputCloud (PointCloudConstPtr &)** and **setIndices (IndicesConstPtr &)** - **optional**
 
index 563e1c2d0e59d187d04dae884c639fa7be44c038..255a57d88fba308893608e7f2599931b4550d23e 100644 (file)
@@ -15,7 +15,7 @@ First, download the dataset `table_scene_mug_stereo_textured.pcd
 and save it somewhere to disk.
 
 Then, create a file, let's say, ``concave_hull_2d.cpp`` or
-``convex_hull2d.cpp`` in your favorite editor and place the following inside:
+``convex_hull_2d.cpp`` in your favorite editor and place the following inside:
 
 .. literalinclude:: sources/concave_hull_2d/concave_hull_2d.cpp
    :language: cpp
diff --git a/doc/tutorials/content/images/form_0.png b/doc/tutorials/content/images/form_0.png
deleted file mode 100644 (file)
index 8312220..0000000
Binary files a/doc/tutorials/content/images/form_0.png and /dev/null differ
diff --git a/doc/tutorials/content/images/form_1.png b/doc/tutorials/content/images/form_1.png
deleted file mode 100644 (file)
index fb127a6..0000000
Binary files a/doc/tutorials/content/images/form_1.png and /dev/null differ
index ca487209d37baf6fa138ac1e18655795d0411b3b..f286330a230ac79ba08ef3cb5ca36c162699df98 100644 (file)
@@ -1,5 +1,9 @@
 .. toctree::
-  
+
+
+Introduction
+-----------
+
 The following links describe a set of basic PCL tutorials. Please note that
 their source codes may already be provided as part of the PCL regular releases,
 so check there before you start copy & pasting the code. The list of tutorials
@@ -12,27 +16,6 @@ below is automatically generated from reST files located in our git repository.
 As always, we would be happy to hear your comments and receive your
 contributions on any tutorial.
 
-Table of contents
------------------
-
-  * :ref:`basic_usage`
-  * :ref:`advanced_usage`
-  * :ref:`applications_tutorial`
-  * :ref:`features_tutorial`
-  * :ref:`filtering_tutorial`
-  * :ref:`i_o`
-  * :ref:`keypoints_tutorial`
-  * :ref:`kdtree_tutorial`
-  * :ref:`octree_tutorial`
-  * :ref:`range_images`
-  * :ref:`recognition_tutorial`
-  * :ref:`registration_tutorial`
-  * :ref:`sample_consensus`
-  * :ref:`segmentation_tutorial`
-  * :ref:`surface_tutorial`
-  * :ref:`visualization_tutorial`
-  * :ref:`gpu`
-
 .. _basic_usage:
 
 Basic Usage
index ef387dde7c4ae13eaeeee71dfc8611262ea2de6f..c6cf9db8688cff6571e4b8ea393d9c09059cfd41 100644 (file)
@@ -8,7 +8,7 @@ In this tutorial we will go over how to use a KdTree for finding the K nearest n
 Theoretical primer
 ------------------
 
-A k-d tree, or k-dimensional tree, is a data structure used in computer science for organizing some number of points in a space with k dimensions.  It is a binary search tree with other constraints imposed on it. K-d trees are very useful for range and nearest neighbor searches.  For our purposes we will generally only be dealing with point clouds in three dimensions, so all of our k-d trees will be three-dimensional.  Each level of a k-d tree splits all children along a specific dimension, using a hyperplane that is perpendicular to the corresponding axis.  At the root of the tree all children will be split based on the first dimension (i.e. if the first dimension coordinate is less than the root it will be in the left-sub tree and if it is greater than the root it will obviously be in the right sub-tree).  Each level down in the tree divides on the next dimension, returning to the first dimension once all others have been exhausted.  They most efficient way to build a k-d tree is to use a partition method like the one Quick Sort uses to place the median point at the root and everything with a smaller one dimensional value to the left and larger to the right.  You then repeat this procedure on both the left and right sub-trees until the last trees that you are to partition are only composed of one element.
+A k-d tree, or k-dimensional tree, is a data structure used in computer science for organizing some number of points in a space with k dimensions.  It is a binary search tree with other constraints imposed on it. K-d trees are very useful for range and nearest neighbor searches.  For our purposes we will generally only be dealing with point clouds in three dimensions, so all of our k-d trees will be three-dimensional.  Each level of a k-d tree splits all children along a specific dimension, using a hyperplane that is perpendicular to the corresponding axis.  At the root of the tree all children will be split based on the first dimension (i.e. if the first dimension coordinate is less than the root it will be in the left-sub tree and if it is greater than the root it will obviously be in the right sub-tree).  Each level down in the tree divides on the next dimension, returning to the first dimension once all others have been exhausted.  The most efficient way to build a k-d tree is to use a partition method like the one Quick Sort uses to place the median point at the root and everything with a smaller one-dimensional value to the left and larger to the right.  You then repeat this procedure on both the left and right sub-trees until the last trees that you are to partition are only composed of one element.
 
 From [Wikipedia]_:
 
@@ -22,7 +22,7 @@ From [Wikipedia]_:
        :align: center
        :alt:
 
-       This is a demonstration of hour the Nearest-Neighbor search works.
+       This is a demonstration of how the Nearest-Neighbor search works.
 
 The code
 --------
index 96d572c01a08d5831d7946c9c47b9d60f2713d14..ec7ccd85f9f7e5b903e49502dd71cafff8caac95 100644 (file)
@@ -9,7 +9,7 @@ correct light sources that generate shadings and other visual effects.
 
 Given a geometric surface, it's usually trivial to infer the direction of the
 normal at a certain point on the surface as the vector perpendicular to the
-surface in that point. However, since the point cloud datasets that we acquire
+surface at that point. However, since the point cloud datasets that we acquire
 represent a set of point samples on the real surface, there are two
 possibilities:
 
@@ -133,7 +133,7 @@ the surrounding point neighborhood support of the point (also called
 **k-neighborhood**).
 
 The specifics of the nearest-neighbor estimation problem raise the question of
-the *right scale factor*: given a sampled point cloud dataset , what are the
+the *right scale factor*: given a sampled point cloud dataset, what are the
 correct **k** (given via **pcl::Feature::setKSearch**) or **r** (given via
 **pcl::Feature::setRadiusSearch**) values that should be used in determining
 the set of nearest neighbors of a point? 
@@ -143,7 +143,7 @@ automatic estimation (i.e., without user given thresholds) of a point feature
 representation. To better illustrate this issue, the figure below presents the
 effects of selecting a smaller scale (i.e., small **r** or **k**) versus a
 larger scale (i.e., large **r** or **k**). The left part of the figures depicts
-a reasonable well chosen scale factor, with estimated surface normals
+a reasonable well-chosen scale factor, with estimated surface normals
 approximately perpendicular for the two planar surfaces and small edges
 visible all across the table. If the scale factor however is too big (right
 part), and thus the set of neighbors is larger covering points from adjacent
index b352d95362d2dba1b860189dd9559a80ae01f853..bb9703704b98801995588d72e44971eccc10ad4d 100644 (file)
@@ -75,7 +75,7 @@ A graphical display of the filtering process is shown below.
 
 .. image:: images/passthrough_2.png
 
-Note that the coordinate axis are represented as red (x), green (y), and blue
+Note that the coordinate axes are represented as red (x), green (y), and blue
 (z). The five points are represented with green as the points remaining after
 filtering and red as the points that have been removed by the filter.
 
index 3c397599d285ae7082fcbdfc05b5a9c110d63b62..be1b1befd6e8a9767794abcbc661319d7da6a040 100644 (file)
@@ -3,8 +3,8 @@
 Plane model segmentation
 -------------------------
 
-In this tutorial we will learn how do a simple plane segmentation of a set of
-points, that is find all the points within a point cloud that support a plane
+In this tutorial we will learn how to do a simple plane segmentation of a set of
+points, that is to find all the points within a point cloud that support a plane
 model. This tutorial supports the :ref:`extract_indices` tutorial, presented in
 the **filtering** section.
 
@@ -58,8 +58,7 @@ Then, lines:
 
    
 create the :pcl:`SACSegmentation <pcl::SACSegmentation>` object and set the model and method type.  
-This is also where we specify the "distance threshold", which  determines how close a point must be to the model 
-in order to be considered an inlier. 
+This is also where we specify the "distance threshold", which determines how close a point must be to the model in order to be considered an inlier. 
 In this tutorial, we will use the RANSAC method (pcl::SAC_RANSAC) as the robust estimator of choice. 
 Our decision is motivated by RANSAC's simplicity (other robust estimators use it as
 a base and add additional, more complicated concepts). For more information
@@ -127,7 +126,7 @@ A graphical display of the segmentation process is shown below.
 
 .. image:: images/planar_segmentation_2.png
 
-Note that the coordinate axis are represented as red (x), green (y), and blue
+Note that the coordinate axes are represented as red (x), green (y), and blue
 (z). The points are represented with red as the outliers, and green as the
 inliers of the plane model found.
 
index d86328dccec2dd43e5632c560c3477c129d97059..d627f8b2cd6eb025c3666667f8e89f0046630ab0 100644 (file)
@@ -101,13 +101,13 @@ the program will display only the indices of the original PointCloud which satis
    :align: center
    :height: 400px
 
-Again hit 'r' to scale and center the view and then click and drag with the mouse to rotate around the cloud.  You can see there are no longer any points that do not lie with in the plane model in this PointCloud. Hit 'q' to exit the viewer and program.
+Again hit 'r' to scale and center the view and then click and drag with the mouse to rotate around the cloud.  You can see there are no longer any points that do not lie within the plane model in this PointCloud. Hit 'q' to exit the viewer and program.
 
 There is also an example using a sphere in this program.  If you run it with::
 
   $ ./random_sample_consensus -s
 
-It will generate and display a sphereical cloud and some outliers as well.
+It will generate and display a spherical cloud and some outliers as well.
 
 .. image:: images/ransac_outliers_sphere.png
    :align: center
index 0c4bc59997531d8e25fc7dfd51254ecf174b1585..e81bf59363d32be4998aa7c59c7b7bd13875ce6d 100644 (file)
@@ -44,11 +44,11 @@ sensorPose defines the 6DOF position of the virtual sensor as the origin with ro
 
 coordinate_frame=CAMERA_FRAME tells the system that x is facing right, y downwards and the z axis is forward. An alternative would be LASER_FRAME, with x facing forward, y to the left and z upwards.
 
-For noiseLevel=0 the range image is created using a normal z-buffer. Yet if you want to average over points falling in the same cell you can use a higher value. 0.05 would mean, that all point with a maximum distance of 5cm to the closest point are used to calculate the range.
+For noiseLevel=0 the range image is created using a normal z-buffer. Yet if you want to average over points falling in the same cell you can use a higher value. 0.05 would mean, that all points with a maximum distance of 5cm to the closest point are used to calculate the range.
 
-If minRange is greater 0 all points that are closer will be ignored.
+If minRange is greater than 0, all points that are closer will be ignored.
 
-borderSize greater 0 will leave a border of unobserved points around the image when cropping it.
+borderSize greater than 0 will leave a border of unobserved points around the image when cropping it.
 
 
 .. literalinclude:: sources/range_image_creation/range_image_creation.cpp
@@ -57,7 +57,7 @@ borderSize greater 0 will leave a border of unobserved points around the image w
 
 The remaining code creates the range image from the point cloud with the given parameters and outputs some information on the terminal.
 
-The range image is derived from the PointCloud class and its points have the members x,y,z and range. There are three kinds of points. Valid points have a real range greater zero. Unobserved points have x=y=z=NAN and range=-INFINITY. Far range points have x=y=z=NAN and range=INFINITY.
+The range image is derived from the PointCloud class and its points have the members x,y,z and range. There are three kinds of points. Valid points have a real range greater than zero. Unobserved points have x=y=z=NAN and range=-INFINITY. Far range points have x=y=z=NAN and range=INFINITY.
 
 Compiling and running the program
 ---------------------------------
index 1bd5dd31d4d60b9efae6951fd266c09e1d5e578f..65193dc009b8450c16e11773ea87b110f5e9d4af 100644 (file)
@@ -6,27 +6,27 @@ Region growing segmentation
 In this tutorial we will learn how to use the region growing algorithm implemented in the ``pcl::RegionGrowing`` class.
 The purpose of the said algorithm is to merge the points that are close enough in terms of the smoothness constraint.
 Thereby, the output of this algorithm is the set of clusters,
-were each cluster is a set of points that are considered to be a part of the same smooth surface.
+where each cluster is a set of points that are considered to be a part of the same smooth surface.
 The work of this algorithm is based on the comparison of the angles between the points normals.
 
 Theoretical Primer
 ---------------------------
 
-Let's take a look on how the algorithm works.
+Let's take a look at how the algorithm works.
 
 First of all it sorts the points by their curvature value.
 It needs to be done because the region begins its growth from the point that has the minimum curvature value.
 The reason for this is that the point with the minimum curvature is located in the flat area (growth from the flattest area
 allows to reduce the total number of segments).
 
-So we have the sorted cloud. Until there are unlabeled points in the cloud, algorithm picks up the point with minimum curvature value and starts the growth of the region. This process occurs as follows:
+So we have the sorted cloud. Until there are no unlabeled points in the cloud, the algorithm picks up the point with minimum curvature value and starts the growth of the region. This process occurs as follows:
 
   * The picked point is added to the set called seeds.
-  * For every seed point algorithm finds neighbouring points.
+  * For every seed point, the algorithm finds its neighbouring points.
      
-     * Every neighbour is tested for the angle between its normal and normal of the current seed point. If the angle is less than threshold value
+     * Every neighbour is tested for the angle between its normal and normal of the current seed point. If the angle is less than the threshold value
        then current point is added to the current region.
-     * After that every neighbour is tested for the curvature value. If the curvature is less than threshold value then this point is added to the seeds.
+     * After that every neighbour is tested for the curvature value. If the curvature is less than the threshold value then this point is added to the seeds.
      * Current seed is removed from the seeds.
 
 If the seeds set becomes empty this means that the algorithm has grown the region and the process is repeated from the beginning.
@@ -119,20 +119,19 @@ To learn more about how it is done you should take a look at the :ref:`normal_es
    :lines: 30-35
 
 These lines are given only for example. You can safely comment this part. Insofar as ``pcl::RegionGrowing`` is derived from ``pcl::PCLBase``,
-it can work with indices. It means you can point that you need to segment only
-those points that are listed in the indices array instead of the whole point cloud.
+it can work with indices. It means you can instruct that you only segment those points that are listed in the indices array instead of the whole point cloud.
 
 .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp
    :language: cpp
    :lines: 37-39
 
-You have finally reached the part where ``pcl::RegionGrowing`` is instantiated. It is a template class that have two parameters:
+You have finally reached the part where ``pcl::RegionGrowing`` is instantiated. It is a template class that has two parameters:
 
 * PointT - type of points to use(in the given example it is ``pcl::PointXYZ``)
 * NormalT - type of normals to use(in the given example it is ``pcl::Normal``)
 
 After that minimum and maximum cluster sizes are set. It means that
-after the segmentation is done all clusters that have less points then was set as minimum(or have more than maximum) will be discarded.
+after the segmentation is done all clusters that have less points than minimum(or have more than maximum) will be discarded.
 The default values for minimum and maximum are 1 and 'as much as possible' respectively.
 
 .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp
@@ -146,12 +145,12 @@ and number of neighbours is set. After that it receives the cloud that must be s
    :language: cpp
    :lines: 45-46
 
-This two lines are most important part in the algorithm initialization, because they are responsible for the mentioned smoothness constraint.
+These two lines are the most important part in the algorithm initialization, because they are responsible for the mentioned smoothness constraint.
 First method sets the angle in radians that will be used as the allowable range for the normals deviation.
-If the deviation between points normals is less than smoothness threshold then they are suggested to be in the same cluster
+If the deviation between points normals is less than the smoothness threshold then they are suggested to be in the same cluster
 (new point - the tested one - will be added to the cluster).
-The second one is responsible for curvature threshold. If two points have a small normals deviation then the disparity between their curvatures is tested.
-And if this value is less than curvature threshold then the algorithm will continue the growth of the cluster using new added point.
+The second one is responsible for the curvature threshold. If two points have a small normals deviation then the disparity between their curvatures is tested.
+And if this value is less than the curvature threshold then the algorithm will continue the growth of the cluster using the newly added point.
 
 .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp
    :language: cpp
@@ -195,7 +194,7 @@ After the segmentation the cloud viewer window will be opened and you will see s
 .. image:: images/region_growing_segmentation_2.jpg
    :height: 200px
 
-On the last image you can see that the colored cloud has many red points. This means that these points belong to the clusters
+In the last image you can see that the colored cloud has many red points. This means that these points belong to the clusters
 that were rejected, because they had too much/little points.
 
 .. image:: images/region_growing_segmentation_3.jpg
index 5405fbeb6e2722e4c89b7fc478e391e0f4269443..7ee6bb0ec8526889e6ecca1ef581ea7464b0446e 100644 (file)
@@ -3,7 +3,7 @@
 Removing outliers using a Conditional or RadiusOutlier removal
 --------------------------------------------------------------
 
-This document demonstrates how to remove outliers from a PointCloud using several different methods in the filter module.  First we will look at how to use a ConditionalRemoval filter which removes all indices in the given input cloud that do not satisfy one or more given conditions.  Then we will learn how to us a RadiusOutlierRemoval filter which removes all indices in it's input cloud that don't have at least some number of neighbors within a certain range.
+This document demonstrates how to remove outliers from a PointCloud using several different methods in the filter module.  First we will look at how to use a ConditionalRemoval filter which removes all indices in the given input cloud that do not satisfy one or more given conditions.  Then we will learn how to us a RadiusOutlierRemoval filter which removes all indices in its input cloud that don't have at least some number of neighbors within a certain range.
 
 The code
 --------
index 7e095af001e36a1ebd2527b543931dd2393f3197..66455a5a40e422d6aa91d6b076196bd30357c2ec 100644 (file)
@@ -36,7 +36,7 @@ we obtain:
 
 To approximate the surface defined by a local neighborhood of points 
 **p1**, **p2** ... **pk** at a point **q** we use a bivariate polynomial height function
-defined on a on a robustly computed reference plane. 
+defined on a robustly computed reference plane. 
 
 .. raw:: html
 
@@ -45,7 +45,11 @@ defined on a on a robustly computed reference plane.
 The code
 --------
 
-First, create a file, let's say, ``resampling.cpp`` in your favorite
+First, download the dataset `bun0.pcd
+<https://raw.githubusercontent.com/PointCloudLibrary/pcl/master/test/bun0.pcd>`_
+and save it somewhere to disk.
+
+Then, create a file, let's say, ``resampling.cpp`` in your favorite
 editor, and place the following inside it:
 
 
index 332515885ea8189b2fe8cbd65b7e3b277c709cb6..d64245b4a9d39eab144f0ba254493e0a4833368e 100644 (file)
@@ -10,4 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (bspline_fitting bspline_fitting.cpp)
 target_link_libraries (bspline_fitting ${PCL_LIBRARIES})
-
index a21b5264a91e8a5d3657edd4c84dd8705d4782f5..76137580520e785c202674b801d15c82deacef38 100644 (file)
@@ -45,7 +45,7 @@ main (int argc, char** argv)
   // Project the model inliers
   pcl::ProjectInliers<pcl::PointXYZ> proj;
   proj.setModelType (pcl::SACMODEL_PLANE);
-  proj.setIndices (inliers);
+  // proj.setIndices (inliers);
   proj.setInputCloud (cloud_filtered);
   proj.setModelCoefficients (coefficients);
   proj.filter (*cloud_projected);
index 453fc946c2b1ac7e740c34167246e40fe991b323..870d0de803d8c16b4c080217b4520c4c945b9e09 100644 (file)
@@ -10,4 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (conditional_euclidean_clustering conditional_euclidean_clustering.cpp)
 target_link_libraries (conditional_euclidean_clustering ${PCL_LIBRARIES})
-
index d48f2497b24da7b5c213ac76edd43155bb04d9f8..b7dcfb8ca3cb183d6459bb56e3aa56e9571cabbd 100644 (file)
@@ -9,4 +9,4 @@ link_directories(${PCL_LIBRARY_DIRS})
 add_definitions(${PCL_DEFINITIONS})
 
 add_executable (correspondence_grouping correspondence_grouping.cpp)
-target_link_libraries (correspondence_grouping ${PCL_LIBRARIES})
\ No newline at end of file
+target_link_libraries (correspondence_grouping ${PCL_LIBRARIES})
index 8eb2b12c11777da999c40181ebb93eb7553fe5c2..4ef87ab1b992400bf23170d5db21f0fae228af7c 100644 (file)
@@ -10,5 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (cylinder_segmentation cylinder_segmentation.cpp)
 target_link_libraries (cylinder_segmentation ${PCL_LIBRARIES})
-
-
index 4a356689f99042fa65ae3aaf41aa59b5a6f2189f..e2f1310bcbe52ab7afc62339c86db5b8778b0ac1 100644 (file)
@@ -10,5 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (don_segmentation don_segmentation.cpp)
 target_link_libraries (don_segmentation ${PCL_LIBRARIES})
-
-
index 83fd61e827d8c96ecf29a8dd9e14a3de7e6abd8a..6d4d10a698493a0ad6a04a609cba1910f3d8b14a 100644 (file)
@@ -11,7 +11,7 @@
 #include <vector>
 
 #include <pcl/common/common.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <pcl/console/print.h>
 #include <pcl/io/ensenso_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
index 7c75f4ee1902f5ca811ef4eb51b2738e638036b4..6a406a9124a3a69b09dc1198d1a2979992b125b8 100644 (file)
@@ -10,5 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (extract_indices extract_indices.cpp)
 target_link_libraries (extract_indices ${PCL_LIBRARIES})
-
-
index 10d5b006ea73c02c9161934f542e8b8bfb44892f..30db6a5a99139b0400fb8e009142b3a9bb2444c0 100644 (file)
@@ -11,4 +11,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (global_hypothesis_verification global_hypothesis_verification.cpp)
 target_link_libraries (global_hypothesis_verification ${PCL_LIBRARIES})
-
diff --git a/doc/tutorials/content/sources/gpu/people_detect/CMakeLists.txt.backup b/doc/tutorials/content/sources/gpu/people_detect/CMakeLists.txt.backup
deleted file mode 100644 (file)
index 0d96a2a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-if(NOT VTK_FOUND)
-  set(DEFAULT FALSE)
-  set(REASON "VTK was not found.")
-else(NOT VTK_FOUND)
-  set(DEFAULT TRUE)
-  set(REASON)
-  set(VTK_USE_FILE ${VTK_USE_FILE} CACHE INTERNAL "VTK_USE_FILE")
-  include (${VTK_USE_FILE})
-  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-endif(NOT VTK_FOUND)
-
-set(the_target people_tracking)
-
-include_directories(${VTK_INCLUDE_DIRS})
-
-PCL_ADD_EXECUTABLE(people_detect ${SUBSYS_NAME} src/people_detect.cpp)
-target_link_libraries (people_detect pcl_common pcl_filters pcl_kdtree pcl_segmentation pcl_kdtree pcl_gpu_people pcl_filters pcl_io pcl_visualization ${Boost_LIBRARIES})
-
index 15af15a2045b964192ee00fa6398a44155024250..b209ed8e02f99d85b1b89b11e350afa20356cb0e 100644 (file)
@@ -34,7 +34,7 @@ computeInitialAlignment (const PointCloudPtr & source_points, const LocalDescrip
   sac_ia.setMaxCorrespondenceDistance (max_correspondence_distance);
   sac_ia.setMaximumIterations (nr_iterations);
   
-  sac_ia.setInputCloud (source_points);
+  sac_ia.setInputSource (source_points);
   sac_ia.setSourceFeatures (source_descriptors);
 
   sac_ia.setInputTarget (target_points);
@@ -81,7 +81,7 @@ refineAlignment (const PointCloudPtr & source_points, const PointCloudPtr & targ
   PointCloudPtr source_points_transformed (new PointCloud);
   pcl::transformPointCloud (*source_points, *source_points_transformed, initial_alignment);
 
-  icp.setInputCloud (source_points_transformed);
+  icp.setInputSource (source_points_transformed);
   icp.setInputTarget (target_points);
 
   PointCloud registration_output;
index 92bccbf0a02af5ec0c278782518e413c94765865..c7bf1c03b998b9c32227260bcc7daa01e782a496 100644 (file)
@@ -18,7 +18,7 @@ class Mesh
     std::vector<pcl::Vertices> faces;
 };
 
-typedef boost::shared_ptr<Mesh> MeshPtr;
+using MeshPtr = std::shared_ptr<Mesh>;
 
 PointCloudPtr
 smoothPointCloud (const PointCloudPtr & input, float radius, int polynomial_order)
index ad76242a721069ae7b33dcaeee169c753c9e05fe..1f1c507343ddb561a1c8f9cdbc13f28dba769083 100644 (file)
@@ -1,6 +1,8 @@
 #include "openni_capture.h"
+
 #include <pcl/io/pcd_io.h>
-#include <boost/make_shared.hpp>
+#include <pcl/memory.h>  // for pcl::make_shared
+
 #include <mutex>
 
 OpenNICapture::OpenNICapture (const std::string& device_id)
@@ -67,7 +69,7 @@ OpenNICapture::onNewFrame (const PointCloudConstPtr &cloud)
 {
   mutex_.lock ();
   ++frame_counter_;
-  most_recent_frame_ = boost::make_shared<PointCloud> (*cloud); // Make a copy of the frame
+  most_recent_frame_ = pcl::make_shared<PointCloud> (*cloud); // Make a copy of the frame
   mutex_.unlock ();
 }
 
index 0a9718a9d864c845402127257cc962241c2d61de..bfae39a32879e27d075de10914a49ae1e512bde5 100644 (file)
@@ -1,6 +1,7 @@
 #include <vector>
 #include <string>
 #include <sstream>
+
 #include <pcl/io/pcd_io.h>
 #include <pcl/registration/transforms.h>
 #include <pcl/visualization/pcl_visualizer.h>
@@ -13,6 +14,7 @@
 #  include <pcl/keypoints/harris_3d.h>
 #endif
 
+#include <pcl/memory.h>  // for pcl::dynamic_pointer_cast
 #include <pcl/ModelCoefficients.h>
 #include <pcl/sample_consensus/method_types.h>
 #include <pcl/sample_consensus/model_types.h>
@@ -43,7 +45,7 @@ class ICCVTutorial
                   pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstructor,
                   typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr source,
                   typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr target);
-    
+
     /**
      * @brief starts the event loop for the visualizer
      */
@@ -55,14 +57,14 @@ class ICCVTutorial
      * @param segmented the resulting segmented point cloud containing only points of the largest cluster
      */
     void segmentation (typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input, typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr segmented) const;
-    
+
     /**
      * @brief Detects key points in the input point cloud
      * @param input the input point cloud
      * @param keypoints the resulting key points. Note that they are not necessarily a subset of the input cloud
      */
     void detectKeypoints (typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input, pcl::PointCloud<pcl::PointXYZI>::Ptr keypoints) const;
-    
+
     /**
      * @brief extract descriptors for given key points
      * @param input point cloud to be used for descriptor extraction
@@ -70,25 +72,25 @@ class ICCVTutorial
      * @param features resulting descriptors
      */
     void extractDescriptors (typename pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr input, typename pcl::PointCloud<pcl::PointXYZI>::Ptr keypoints, typename pcl::PointCloud<FeatureType>::Ptr features);
-    
+
     /**
      * @brief find corresponding features based on some metric
      * @param source source feature descriptors
-     * @param target target feature descriptors 
+     * @param target target feature descriptors
      * @param correspondences indices out of the target descriptors that correspond (nearest neighbor) to the source descriptors
-     */    
+     */
     void findCorrespondences (typename pcl::PointCloud<FeatureType>::Ptr source, typename pcl::PointCloud<FeatureType>::Ptr target, std::vector<int>& correspondences) const;
-    
+
     /**
      * @brief  remove non-consistent correspondences
      */
     void filterCorrespondences ();
-    
+
     /**
      * @brief calculate the initial rigid transformation from filtered corresponding keypoints
      */
     void determineInitialTransformation ();
-    
+
     /**
      * @brief calculate the final rigid transformation using ICP over all points
      */
@@ -105,7 +107,7 @@ class ICCVTutorial
      * @param cookie user defined data passed during registration of the callback
      */
     void keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie);
-    
+
   private:
     pcl::visualization::PCLVisualizer visualizer_;
     pcl::PointCloud<pcl::PointXYZI>::Ptr source_keypoints_;
@@ -157,24 +159,24 @@ ICCVTutorial<FeatureType>::ICCVTutorial(pcl::Keypoint<pcl::PointXYZRGB, pcl::Poi
 , show_correspondences (false)
 {
   visualizer_.registerKeyboardCallback(&ICCVTutorial::keyboard_callback, *this, 0);
-  
+
   segmentation (source_, source_segmented_);
-  segmentation (target_, target_segmented_);  
-  
+  segmentation (target_, target_segmented_);
+
   detectKeypoints (source_segmented_, source_keypoints_);
   detectKeypoints (target_segmented_, target_keypoints_);
-  
+
   extractDescriptors (source_segmented_, source_keypoints_, source_features_);
   extractDescriptors (target_segmented_, target_keypoints_, target_features_);
-  
+
   findCorrespondences (source_features_, target_features_, source2target_);
   findCorrespondences (target_features_, source_features_, target2source_);
-  
+
   filterCorrespondences ();
-  
+
   determineInitialTransformation ();
   determineFinalTransformation ();
-  
+
   reconstructSurface ();
 }
 
@@ -196,7 +198,7 @@ void ICCVTutorial<FeatureType>::segmentation (typename pcl::PointCloud<pcl::Poin
 
   seg.setInputCloud (source);
   seg.segment (*inliers, *coefficients);
-  
+
   pcl::ExtractIndices<pcl::PointXYZRGB> extract;
   extract.setInputCloud (source);
   extract.setIndices (inliers);
@@ -206,7 +208,7 @@ void ICCVTutorial<FeatureType>::segmentation (typename pcl::PointCloud<pcl::Poin
   std::vector<int> indices;
   pcl::removeNaNFromPointCloud(*segmented, *segmented, indices);
   std::cout << "OK" << std::endl;
-  
+
   std::cout << "clustering..." << std::flush;
   // euclidean clustering
   typename pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB>);
@@ -220,7 +222,7 @@ void ICCVTutorial<FeatureType>::segmentation (typename pcl::PointCloud<pcl::Poin
   clustering.setSearchMethod (tree);
   clustering.setInputCloud(segmented);
   clustering.extract (cluster_indices);
-  
+
   if (cluster_indices.size() > 0)//use largest cluster
   {
     std::cout << cluster_indices.size() << " clusters found";
@@ -252,16 +254,16 @@ void ICCVTutorial<FeatureType>::extractDescriptors (typename pcl::PointCloud<pcl
 {
   typename pcl::PointCloud<pcl::PointXYZRGB>::Ptr kpts(new pcl::PointCloud<pcl::PointXYZRGB>);
   kpts->points.resize(keypoints->points.size());
-  
+
   pcl::copyPointCloud(*keypoints, *kpts);
-          
-  typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType>::Ptr feature_from_normals = boost::dynamic_pointer_cast<pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType> > (feature_extractor_);
-  
+
+  typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType>::Ptr feature_from_normals = pcl::dynamic_pointer_cast<pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType> > (feature_extractor_);
+
   feature_extractor_->setSearchSurface(input);
   feature_extractor_->setInputCloud(kpts);
-  
+
   if (feature_from_normals)
-  //if (boost::dynamic_pointer_cast<typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType> > (feature_extractor_))
+  //if (pcl::dynamic_pointer_cast<typename pcl::FeatureFromNormals<pcl::PointXYZRGB, pcl::Normal, FeatureType> > (feature_extractor_))
   {
     std::cout << "normal estimation..." << std::flush;
     typename pcl::PointCloud<pcl::Normal>::Ptr normals (new  pcl::PointCloud<pcl::Normal>);
@@ -309,14 +311,14 @@ void ICCVTutorial<FeatureType>::filterCorrespondences ()
   for (unsigned cIdx = 0; cIdx < source2target_.size (); ++cIdx)
     if (target2source_[source2target_[cIdx]] == cIdx)
       correspondences.push_back(std::make_pair(cIdx, source2target_[cIdx]));
-  
+
   correspondences_->resize (correspondences.size());
   for (unsigned cIdx = 0; cIdx < correspondences.size(); ++cIdx)
   {
     (*correspondences_)[cIdx].index_query = correspondences[cIdx].first;
     (*correspondences_)[cIdx].index_match = correspondences[cIdx].second;
   }
-  
+
   pcl::registration::CorrespondenceRejectorSampleConsensus<pcl::PointXYZI> rejector;
   rejector.setInputSource(source_keypoints_);
   rejector.setInputTarget(target_keypoints_);
@@ -330,9 +332,9 @@ void ICCVTutorial<FeatureType>::determineInitialTransformation ()
 {
   std::cout << "initial alignment..." << std::flush;
   pcl::registration::TransformationEstimation<pcl::PointXYZI, pcl::PointXYZI>::Ptr transformation_estimation (new pcl::registration::TransformationEstimationSVD<pcl::PointXYZI, pcl::PointXYZI>);
-  
+
   transformation_estimation->estimateRigidTransformation (*source_keypoints_, *target_keypoints_, *correspondences_, initial_transformation_matrix_);
-  
+
   pcl::transformPointCloud(*source_segmented_, *source_transformed_, initial_transformation_matrix_);
   std::cout << "OK" << std::endl;
 }
@@ -342,7 +344,7 @@ void ICCVTutorial<FeatureType>::determineFinalTransformation ()
 {
   std::cout << "final registration..." << std::flush;
   pcl::Registration<pcl::PointXYZRGB, pcl::PointXYZRGB>::Ptr registration (new pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB>);
-  registration->setInputCloud(source_transformed_);
+  registration->setInputSource(source_transformed_);
   //registration->setInputCloud(source_segmented_);
   registration->setInputTarget (target_segmented_);
   registration->setMaxCorrespondenceDistance(0.05);
@@ -362,7 +364,7 @@ void ICCVTutorial<FeatureType>::reconstructSurface ()
   pcl::PointCloud<pcl::PointXYZRGB>::Ptr merged (new pcl::PointCloud<pcl::PointXYZRGB>);
   *merged = *source_transformed_;
   *merged += *target_segmented_;
-  
+
   // apply grid filtering to reduce amount of points as well as to make them uniform distributed
   pcl::VoxelGrid<pcl::PointXYZRGB> voxel_grid;
   voxel_grid.setInputCloud(merged);
@@ -378,7 +380,7 @@ void ICCVTutorial<FeatureType>::reconstructSurface ()
   normal_estimation.setRadiusSearch (0.01);
   normal_estimation.setInputCloud (merged);
   normal_estimation.compute (*vertices);
-  
+
   pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGBNormal>);
   tree->setInputCloud (vertices);
 
@@ -407,28 +409,28 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
           visualizer_.addPointCloud(source_, "source_points");
         }
         break;
-        
+
       case '2':
         if (!visualizer_.removePointCloud("target_points"))
         {
           visualizer_.addPointCloud(target_, "target_points");
         }
         break;
-      
+
       case '3':
         if (!visualizer_.removePointCloud("source_segmented"))
         {
           visualizer_.addPointCloud(source_segmented_, "source_segmented");
         }
         break;
-        
+
       case '4':
         if (!visualizer_.removePointCloud("target_segmented"))
         {
           visualizer_.addPointCloud(target_segmented_, "target_segmented");
         }
         break;
-        
+
       case '5':
         if (!visualizer_.removePointCloud("source_keypoints"))
         {
@@ -437,7 +439,7 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
           visualizer_.addPointCloud(source_keypoints_, keypoint_color, "source_keypoints");
         }
         break;
-      
+
       case '6':
         if (!visualizer_.removePointCloud("target_keypoints"))
         {
@@ -452,7 +454,7 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
           visualizer_.addCorrespondences<pcl::PointXYZI>(source_keypoints_, target_keypoints_, source2target_, "source2target");
         else
           visualizer_.removeCorrespondences("source2target");
-          
+
         show_source2target_ = !show_source2target_;
         break;
 
@@ -464,7 +466,7 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
 
         show_target2source_ = !show_target2source_;
         break;
-        
+
       case '9':
         if (!show_correspondences)
           visualizer_.addCorrespondences<pcl::PointXYZI>(source_keypoints_, target_keypoints_, *correspondences_, "correspondences");
@@ -472,7 +474,7 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
           visualizer_.removeCorrespondences("correspondences");
         show_correspondences = !show_correspondences;
         break;
-        
+
       case 'i':
       case 'I':
         if (!visualizer_.removePointCloud("transformed"))
@@ -484,7 +486,7 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
         if (!visualizer_.removePointCloud("registered"))
           visualizer_.addPointCloud(source_registered_, "registered");
         break;
-        
+
       case 't':
       case 'T':
           visualizer_.addPolygonMesh(surface_, "surface");
@@ -493,10 +495,10 @@ void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::Key
   }
 }
 
-int 
+int
 main (int argc, char ** argv)
 {
-  if (argc < 6) 
+  if (argc < 6)
   {
     pcl::console::print_info ("Syntax is: %s <source-pcd-file> <target-pcd-file> <keypoint-method> <descriptor-type> <surface-reconstruction-method>\n", argv[0]);
     pcl::console::print_info ("available <keypoint-methods>: 1 = Sift3D\n");
@@ -511,7 +513,7 @@ main (int argc, char ** argv)
     pcl::console::print_info ("                              4 = PFHRGB\n\n");
     pcl::console::print_info ("available <surface-methods>:  1 = Greedy Projection\n");
     pcl::console::print_info ("                              2 = Marching Cubes\n");    
-    
+
     return (1);
   }
   pcl::console::print_info ("== MENU ==\n");
@@ -529,19 +531,19 @@ main (int argc, char ** argv)
   pcl::console::print_info ("t - show/hide triangulation (surface reconstruction)\n");
   pcl::console::print_info ("h - show visualizer options\n");
   pcl::console::print_info ("q - quit\n");
-  
+
   pcl::PointCloud<pcl::PointXYZRGB>::Ptr source (new pcl::PointCloud<pcl::PointXYZRGB>);
   pcl::io::loadPCDFile (argv[1], *source);
-  
+
   pcl::PointCloud<pcl::PointXYZRGB>::Ptr target (new pcl::PointCloud<pcl::PointXYZRGB>);
   pcl::io::loadPCDFile (argv[2], *target);
-  
+
   int keypoint_type   = atoi (argv[3]);
   int descriptor_type = atoi (argv[4]);
   int surface_type    = atoi (argv[5]);
-  
+
   pcl::Keypoint<pcl::PointXYZRGB, pcl::PointXYZI>::Ptr keypoint_detector;
-  
+
   if (keypoint_type == 1)
   {
     pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI>* sift3D = new pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI>;
@@ -569,7 +571,7 @@ main (int argc, char ** argv)
       case 4:
         harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::NOBLE);
       break;
-      
+
       case 5:
         harris3D->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::LOWE);
       break;
@@ -582,11 +584,10 @@ main (int argc, char ** argv)
         exit (1);
         break;
     }
-    
   }
-  
+
   pcl::PCLSurfaceBase<pcl::PointXYZRGBNormal>::Ptr surface_reconstruction;
-  
+
   if (surface_type == 1)
   {
     pcl::GreedyProjectionTriangulation<pcl::PointXYZRGBNormal>* gp3 = new pcl::GreedyProjectionTriangulation<pcl::PointXYZRGBNormal>;
@@ -615,7 +616,7 @@ main (int argc, char ** argv)
     pcl::console::print_error("unknown surface reconstruction method %d\n expecting values between 1 and 2", surface_type);
     exit (1);
   }
-  
+
   switch (descriptor_type)
   {
     case 1:
@@ -627,7 +628,7 @@ main (int argc, char ** argv)
       tutorial.run ();
     }
     break;
-    
+
     case 2:
     {
       pcl::SHOTColorEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::SHOT1344>* shot = new pcl::SHOTColorEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::SHOT1344>;
@@ -637,7 +638,7 @@ main (int argc, char ** argv)
       tutorial.run ();
     }
     break;
-    
+
     case 3:
     {
       pcl::Feature<pcl::PointXYZRGB, pcl::PFHSignature125>::Ptr feature_extractor (new pcl::PFHEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHSignature125>);
@@ -646,7 +647,7 @@ main (int argc, char ** argv)
       tutorial.run ();
     }
     break;
-    
+
     case 4:
     {
       pcl::Feature<pcl::PointXYZRGB, pcl::PFHRGBSignature250>::Ptr feature_extractor (new pcl::PFHRGBEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHRGBSignature250>);
@@ -655,12 +656,12 @@ main (int argc, char ** argv)
       tutorial.run ();
     }
     break;
-    
+
     default:
       pcl::console::print_error("unknown descriptor type %d\n expecting values between 1 and 4", descriptor_type);
       exit (1);
       break;
-  }  
-  
+  }
+
   return (0);
 }
index b19cf301d5532c0e511e4be27a4a992ba0474080..9f85b0a1ce08b5fe7a8909238457fb383687a83b 100644 (file)
@@ -11,5 +11,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (implicit_shape_model implicit_shape_model.cpp)
 target_link_libraries (implicit_shape_model ${PCL_LIBRARIES})
-
-
index 0c30704453d15a2aec1d130bd5213a376bf473b6..45c48d48f6a3a5b298fabc3756dce5722e2ba2fa 100644 (file)
@@ -34,7 +34,7 @@ computeInitialAlignment (const PointCloudPtr & source_points, const LocalDescrip
   sac_ia.setMaxCorrespondenceDistance (max_correspondence_distance);
   sac_ia.setMaximumIterations (nr_iterations);
   
-  sac_ia.setInputCloud (source_points);
+  sac_ia.setInputSource (source_points);
   sac_ia.setSourceFeatures (source_descriptors);
 
   sac_ia.setInputTarget (target_points);
@@ -81,7 +81,7 @@ refineAlignment (const PointCloudPtr & source_points, const PointCloudPtr & targ
   PointCloudPtr source_points_transformed (new PointCloud);
   pcl::transformPointCloud (*source_points, *source_points_transformed, initial_alignment);
 
-  icp.setInputCloud (source_points_transformed);
+  icp.setInputSource (source_points_transformed);
   icp.setInputTarget (target_points);
 
   PointCloud registration_output;
index 92bccbf0a02af5ec0c278782518e413c94765865..c7bf1c03b998b9c32227260bcc7daa01e782a496 100644 (file)
@@ -18,7 +18,7 @@ class Mesh
     std::vector<pcl::Vertices> faces;
 };
 
-typedef boost::shared_ptr<Mesh> MeshPtr;
+using MeshPtr = std::shared_ptr<Mesh>;
 
 PointCloudPtr
 smoothPointCloud (const PointCloudPtr & input, float radius, int polynomial_order)
index 731a52ab87b630937666c38b7bddc93945f79fea..7749faedd3421bffaeddf2779436b5ed86727d3b 100644 (file)
@@ -18,7 +18,7 @@ public:
   std::vector<pcl::Vertices> faces;
 };
 
-typedef boost::shared_ptr<Mesh> MeshPtr;
+using MeshPtr = std::shared_ptr<Mesh>;
 
 PointCloudPtr
 smoothPointCloud (const PointCloudPtr & input, float radius, int polynomial_order)
index 4f4f3989cd4e9a9a81a4cde1ad8eec9191eb943c..29ae70d5649b4a104b76f8ec019eb286295dae32 100644 (file)
@@ -1,7 +1,9 @@
 #include "openni_capture.h"
+
 #include <pcl/io/pcd_io.h>
+#include <pcl/memory.h>  // for pcl::make_shared
+
 #include <mutex>
-#include <boost/make_shared.hpp>
 
 OpenNICapture::OpenNICapture (const std::string& device_id)
   : grabber_ (device_id)
@@ -22,7 +24,6 @@ OpenNICapture::~OpenNICapture ()
 {
   // Stop the grabber when shutting down
   grabber_.stop ();
-  if (preview_)
     delete preview_;
 }
 
@@ -70,7 +71,7 @@ OpenNICapture::onNewFrame (const PointCloudConstPtr &cloud)
 {
   mutex_.lock ();
   ++frame_counter_;
-  most_recent_frame_ = boost::make_shared<PointCloud> (*cloud); // Make a copy of the frame
+  most_recent_frame_ = pcl::make_shared<PointCloud> (*cloud); // Make a copy of the frame
   mutex_.unlock ();
 }
 
index 2dff353e0d7111f41d9a46d9fbb5fcfef9296671..ee4e3f74f4eb0951f32ab56a55ac1aa779250306 100644 (file)
@@ -6,39 +6,40 @@
 int
  main (int argc, char** argv)
 {
-  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZ>);
+  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZ>(5,1));
   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZ>);
 
   // Fill in the CloudIn data
-  cloud_in->width    = 5;
-  cloud_in->height   = 1;
-  cloud_in->is_dense = false;
-  cloud_in->points.resize (cloud_in->width * cloud_in->height);
-  for (std::size_t i = 0; i < cloud_in->points.size (); ++i)
+  for (auto& point : *cloud_in)
   {
-    cloud_in->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
-    cloud_in->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
-    cloud_in->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
+    point.x = 1024 * rand() / (RAND_MAX + 1.0f);
+    point.y = 1024 * rand() / (RAND_MAX + 1.0f);
+    point.z = 1024 * rand() / (RAND_MAX + 1.0f);
   }
-  std::cout << "Saved " << cloud_in->points.size () << " data points to input:"
-      << std::endl;
-  for (std::size_t i = 0; i < cloud_in->points.size (); ++i) std::cout << "    " <<
-      cloud_in->points[i].x << " " << cloud_in->points[i].y << " " <<
-      cloud_in->points[i].z << std::endl;
+  
+  std::cout << "Saved " << cloud_in->points.size () << " data points to input:" << std::endl;
+      
+  for (auto& point : *cloud_in)
+    std::cout << point << std::endl;
+      
   *cloud_out = *cloud_in;
+  
   std::cout << "size:" << cloud_out->points.size() << std::endl;
-  for (std::size_t i = 0; i < cloud_in->points.size (); ++i)
-    cloud_out->points[i].x = cloud_in->points[i].x + 0.7f;
-  std::cout << "Transformed " << cloud_in->points.size () << " data points:"
-      << std::endl;
-  for (std::size_t i = 0; i < cloud_out->points.size (); ++i)
-    std::cout << "    " << cloud_out->points[i].x << " " <<
-      cloud_out->points[i].y << " " << cloud_out->points[i].z << std::endl;
+  for (auto& point : *cloud_out)
+    point.x += 0.7f;
+
+  std::cout << "Transformed " << cloud_in->points.size () << " data points:" << std::endl;
+      
+  for (auto& point : *cloud_out)
+    std::cout << point << std::endl;
+
   pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
   icp.setInputSource(cloud_in);
   icp.setInputTarget(cloud_out);
+  
   pcl::PointCloud<pcl::PointXYZ> Final;
   icp.align(Final);
+
   std::cout << "has converged:" << icp.hasConverged() << " score: " <<
   icp.getFitnessScore() << std::endl;
   std::cout << icp.getFinalTransformation() << std::endl;
index e3d26ae2758337203a201db57488615f48eba77a..541dfb274296630e56802345d624332cd41d73a1 100644 (file)
@@ -10,5 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (min_cut_segmentation min_cut_segmentation.cpp)
 target_link_libraries (min_cut_segmentation ${PCL_LIBRARIES})
-
-
index 817ee201e5221cbfefa5bf24160eb037398b0439..f64ea5472d482802f5ec9cf849594aa419873a06 100644 (file)
@@ -11,4 +11,3 @@ add_definitions(${PCL_DEFINITIONS})
 add_executable (moment_of_inertia moment_of_inertia.cpp)
 target_link_libraries (moment_of_inertia ${PCL_LIBRARIES})
 
-
index 69cc07cb89ae7253c20908f19a8739c6deb5f4b8..4113739706841a59dd1cbb6f2ac4134490dee978 100644 (file)
@@ -10,4 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (narf_descriptor_visualization narf_descriptor_visualization.cpp)
 target_link_libraries (narf_descriptor_visualization ${PCL_LIBRARIES})
-
index a83a289a7662eb6851c449d29b1600e84c00e43a..bf26ed21dfee3cfdba26fbdcbd5ae5611939fa2e 100644 (file)
@@ -10,4 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (narf_feature_extraction narf_feature_extraction.cpp)
 target_link_libraries (narf_feature_extraction ${PCL_LIBRARIES})
-
index df0c982368270cbe9a724f7a912a16e01230efb5..334094afd6d26a620fa5e9a634608991e405f704 100644 (file)
@@ -10,4 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (narf_keypoint_extraction narf_keypoint_extraction.cpp)
 target_link_libraries (narf_keypoint_extraction ${PCL_LIBRARIES})
-
index ee9d2936e3e32eea6070de8d4f610d97f60bb4c9..d5d9d3972100fd3187d22f36932b27773532188a 100644 (file)
@@ -10,4 +10,3 @@ add_definitions(${PCL_DEFINITIONS})
 
 add_executable (openni_range_image_visualization openni_range_image_visualization.cpp)
 target_link_libraries (openni_range_image_visualization ${PCL_LIBRARIES})
-
index d07f92861c8867ab28c0913ea79a68b9fc5658ac..e377b6f72243518b6d6e82924aa2a77c607943fc 100644 (file)
@@ -38,7 +38,7 @@
 /* \author Radu Bogdan Rusu
  * adaptation Raphael Favier*/
 
-#include <boost/make_shared.hpp>
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_representation.h>
@@ -255,7 +255,7 @@ void pairAlign (const PointCloud::Ptr cloud_src, const PointCloud::Ptr cloud_tgt
   // Note: adjust this based on the size of your datasets
   reg.setMaxCorrespondenceDistance (0.1);  
   // Set the point representation
-  reg.setPointRepresentation (boost::make_shared<const MyPointRepresentation> (point_representation));
+  reg.setPointRepresentation (pcl::make_shared<const MyPointRepresentation> (point_representation));
 
   reg.setInputSource (points_with_normals_src);
   reg.setInputTarget (points_with_normals_tgt);
index 855ab516c1067cd392e2e114f71fd9bf638eca7d..f7e996105822dd1fb43065d9e396ca034841f0b1 100644 (file)
@@ -11,4 +11,3 @@ add_definitions(${PCL_DEFINITIONS})
 add_executable (region_growing_segmentation region_growing_segmentation.cpp)
 target_link_libraries (region_growing_segmentation ${PCL_LIBRARIES})
 
-
index 9023fa227537cd96b0ce93e78b535bd5ed89b4a9..f4a7f5e3edf8170ef7edd379bea10211d5b57474 100644 (file)
@@ -120,7 +120,7 @@ rejectBadCorrespondences (const CorrespondencesPtr &all_correspondences,
                           Correspondences &remaining_correspondences)
 {
   CorrespondenceRejectorDistance rej;
-  rej.setInputCloud<PointXYZ> (keypoints_src);
+  rej.setInputSource<PointXYZ> (keypoints_src);
   rej.setInputTarget<PointXYZ> (keypoints_tgt);
   rej.setMaximumDistance (1);    // 1m
   rej.setInputCorrespondences (all_correspondences);
index 478955697811e1bb0f8e7780d7214dec337975ec..98f3fc80e372792740df52a2233b145bb458ae2f 100644 (file)
@@ -11,4 +11,3 @@ add_definitions(${PCL_DEFINITIONS})
 add_executable (rops_feature rops_feature.cpp)
 target_link_libraries (rops_feature ${PCL_LIBRARIES})
 
-
index 7d8db5d0ee2ab6e5ec49041eb573a1e1d9fd768c..03f85dfa32ac7e600edc4bdbe02358477e3cf6e8 100644 (file)
@@ -2,7 +2,7 @@
 #include <pcl/console/parse.h>
 #include <pcl/console/time.h>
 #include <pcl/point_types.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/filters/passthrough.h>
 #include <pcl/filters/voxel_grid.h>
index 5d998352a5b153ebf79d532a7446d36ea8e76e26..46f95e87827b882932f9f234e2aeb8d730e959a1 100644 (file)
@@ -2,6 +2,7 @@
 #include <fstream>
 #include <vector>
 #include <Eigen/Core>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
@@ -161,7 +162,7 @@ class TemplateAlignment
     void
     align (FeatureCloud &template_cloud, TemplateAlignment::Result &result)
     {
-      sac_ia_.setInputCloud (template_cloud.getPointCloud ());
+      sac_ia_.setInputSource (template_cloud.getPointCloud ());
       sac_ia_.setSourceFeatures (template_cloud.getLocalFeatures ());
 
       pcl::PointCloud<pcl::PointXYZ> registration_output;
index abd31d0806df802191bf814e3b48ba7be9a0e52b..95c520674080c58b0fe11e465f3935675741ba50 100644 (file)
@@ -15,7 +15,7 @@ main (int argc, char** argv)
   reader.read ("table_scene_lms400.pcd", *cloud); // Remember to download the file first!
 
   std::cerr << "PointCloud before filtering: " << cloud->width * cloud->height 
-       << " data points (" << pcl::getFieldsList (*cloud) << ").";
+       << " data points (" << pcl::getFieldsList (*cloud) << ")." << std::endl;
 
   // Create the filtering object
   pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
@@ -24,7 +24,7 @@ main (int argc, char** argv)
   sor.filter (*cloud_filtered);
 
   std::cerr << "PointCloud after filtering: " << cloud_filtered->width * cloud_filtered->height 
-       << " data points (" << pcl::getFieldsList (*cloud_filtered) << ").";
+       << " data points (" << pcl::getFieldsList (*cloud_filtered) << ")." << std::endl;
 
   pcl::PCDWriter writer;
   writer.write ("table_scene_lms400_downsampled.pcd", *cloud_filtered, 
index 76ee373d7bbbdf88bd266cc6c3beae8a0f579bef..fa8ee28cfdb0d267400fad37fae6195a93358ffb 100644 (file)
@@ -20,7 +20,7 @@ characteristics such as surface normals or curvature changes, leading to
 erroneous values, which in turn might cause point cloud registration failures.
 Some of these irregularities can be solved by performing a statistical analysis
 on each point's neighborhood, and trimming those which do not meet a certain
-criteria.  Our sparse outlier removal is based on the computation of the
+criterion.  Our sparse outlier removal is based on the computation of the
 distribution of point to neighbors distances in the input dataset. For each
 point, we compute the mean distance from it to all its neighbors. By assuming
 that the resulted distribution is Gaussian with a mean and a standard
index 3f544d3e1eff1aef8bc904d5ec34d548ccda7966..f8cd1ce4e8cdc382b1c21596515f6f67ca1cc489 100644 (file)
@@ -5,11 +5,11 @@ Aligning object templates to a point cloud
 
 This tutorial gives an example of how some of the tools covered in the other tutorials can be combined to solve a higher level problem --- aligning a previously captured model of an object to some newly captured data.  In this specific example, we'll take a depth image that contains a person and try to fit some previously captured templates of their face; this will allow us to determine the position and orientation of the face in the scene.
 
-.. raw:: html 
+.. raw:: html
 
   <iframe width="560" height="349" style="margin-left:50px" src="http://www.youtube.com/embed/1T5HxTTgE4I" frameborder="0" allowfullscreen></iframe>
 
-We can use the code below to fit a template of a person's face (the blue points) to a new point cloud (the green points). 
+We can use the code below to fit a template of a person's face (the blue points) to a new point cloud (the green points).
 
 
 The code
@@ -71,11 +71,11 @@ The methods described above serve to encapsulate the work needed to compute feat
 
 Now we'll examine the *TemplateAlignment* class, which as the name suggests, will be used to perform template alignment (also referred to as template fitting/matching/registration).  A template is typically a small group of pixels or points that represents a known part of a larger object or scene.  By registering a template to a new image or point cloud, you can determine the position and orientation of the object that the template represents.
 
-We start by defining a structure to store the alignment results.  It contains a floating point value that represents the "fitness" of the alignment (a lower number means a better alignment) and a transformation matrix that describes how template points should be rotated and translated in order to best align with the points in the target cloud.  
+We start by defining a structure to store the alignment results.  It contains a floating point value that represents the "fitness" of the alignment (a lower number means a better alignment) and a transformation matrix that describes how template points should be rotated and translated in order to best align with the points in the target cloud.
 
 .. note::
 
-   Because we are including an Eigen::Matrix4f in this struct, we need to include the EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro, which will overload the struct's "operator new" so that it will generate 16-bytes-aligned pointers.  If you're curious, you can find more information about this issue `here <http://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html>`_. For convenience, there is a redefinition of the macro in pcl_macros.h, aptly named PCL_MAKE_ALIGNED_OPERATOR_NEW which will let us for example call `pcl::make_shared` to create a `shared_ptr` of over-aligned classes.
+   Because we are including an Eigen::Matrix4f in this struct, we need to include the EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro, which will overload the struct's "operator new" so that it will generate 16-bytes-aligned pointers.  If you're curious, you can find more information about this issue `here <http://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html>`_. For convenience, there is a redefinition of the macro in memory.h, aptly named PCL_MAKE_ALIGNED_OPERATOR_NEW which will let us for example call `pcl::make_shared` to create a `shared_ptr` of over-aligned classes.
 
 .. literalinclude:: sources/template_alignment/template_alignment.cpp
    :language: cpp
@@ -201,11 +201,11 @@ After you have made the executable, you can run it like so::
 After a few seconds, you will see output similar to::
 
   Best fitness score: 0.000009
-  
-      |  0.834  0.295  0.466 | 
-  R = | -0.336  0.942  0.006 | 
-      | -0.437 -0.162  0.885 | 
-  
+
+      |  0.834  0.295  0.466 |
+  R = | -0.336  0.942  0.006 |
+      | -0.437 -0.162  0.885 |
+
   t = < -0.373, -0.097, 0.087 >
 
 You can also use the `pcl_viewer <http://www.pointclouds.org/documentation/overview/visualization.php>`_ utility to visualize the aligned template and overlay it against the target cloud by running the following command::
index a1e45602ec4479b9ced8a9e2b044ed482ad7dd60..8f3a9baa6c8c087e13608028fca51a394a483fcd 100644 (file)
@@ -112,13 +112,7 @@ Features
        
        .. image:: images/features_normal.jpg
 
-       An example of two of the most widely used geometric point features are the underlying surface's estimated curvature and normal at a query point ``p``. Both of them are considered local features, as they characterize a point using the information provided by its ``k`` closest point neighbors. For determining these neighbors efficiently, the input dataset is usually split into smaller chunks using spatial decomposition techniques such as octrees or kD-trees (see the figure below - left: kD-tree, right: octree), and then closest point searches are performed in that space. Depending on the application one can opt for either determining a fixed number of ``k`` points in the vicinity of ``p``, or all points which are found inside of a sphere of radius ``r`` centered at ``p``. Unarguably, one the easiest methods for estimating the surface normals and curvature changes at a point ``p`` is to perform an eigendecomposition (i.e., compute the eigenvectors and eigenvalues) of the k-neighborhood point surface patch. Thus, the eigenvector corresponding to the smallest eigenvalue will approximate the surface normal ``n`` at point ``p``, while the surface curvature change will be estimated from the eigenvalues as:
-
-       .. image:: images/form_0.png
-       
-       .. image:: images/form_1.png
-       
-       |
+       An example of two of the most widely used geometric point features are the underlying surface's estimated curvature and normal at a query point ``p``. Both of them are considered local features, as they characterize a point using the information provided by its ``k`` closest point neighbors. For determining these neighbors efficiently, the input dataset is usually split into smaller chunks using spatial decomposition techniques such as octrees or kD-trees, and then closest point searches are performed in that space. Depending on the application one can opt for either determining a fixed number of ``k`` points in the vicinity of ``p``, or all points which are found inside of a sphere of radius ``r`` centered at ``p``. Unarguably, one the easiest methods for estimating the surface normals and curvature changes at a point ``p`` is to perform an eigendecomposition (i.e., compute the eigenvectors and eigenvalues) of the k-neighborhood point surface patch. Thus, the eigenvector corresponding to the smallest eigenvalue will approximate the surface normal ``n`` at point ``p``, while the surface curvature change will be estimated from the eigenvalues as :math:`\frac{\lambda_0}{\lambda_0+\lambda_1+\lambda_2}` with :math:`\lambda_0<\lambda_1<\lambda_2`.
 
        .. image:: images/features_bunny.jpg
        
@@ -789,4 +783,3 @@ This section provides a quick reference for some of the common tools in PCL.
                __ Octree_
 
 Top_
-
index 752f47ccb78d89746157ea340d11e061d7b5ed3e..ab42690b41984417d43a3c2fa736d7a06127e92e 100644 (file)
  *
  */
 
-#include <iostream>
-#include <limits>
-
 #include <pcl/point_types.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 
 int
 main ()
index 6ed6b2980e0365a61cc131a24840e2c4bc7eee07..8b95496e288b88e71351dcd1dd99ceff46a8b1a4 100644 (file)
  * members of the source PointType.
  */
 
-// STL
 #include <iostream>
 
-// PCL
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/common/io.h>
 
 static void
index 06d7e43ffce5861be52505c10f19cbb8b8038f8a..f097a24a3663159769b3353afd9d80863c762c44 100644 (file)
@@ -1,6 +1,5 @@
 #include <iostream>
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/common/common.h>
 
 int 
index da281911ed240571961e7d4da3e31e611d595c68..59c155bdb2ce5e7e407bd73e39f7d117acfe556e 100644 (file)
@@ -5,20 +5,13 @@
  * @author Yani Ioannou
  * @date 2012-03-11
  */
+
 #include <string>
 
-#include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/common/point_operators.h>
-#include <pcl/common/io.h>
-#include <pcl/search/organized.h>
-#include <pcl/search/octree.h>
-#include <pcl/search/kdtree.h>
 #include <pcl/features/normal_3d_omp.h>
 #include <pcl/filters/conditional_removal.h>
-#include <pcl/segmentation/sac_segmentation.h>
 #include <pcl/segmentation/extract_clusters.h>
-#include <pcl/io/vtk_io.h>
 #include <pcl/filters/voxel_grid.h>
 
 #include <pcl/features/don.h>
index fbcfde26d579aeda940b830574d0d1426ebfa24d..fa2a03ec5cf9a90ef701034cc283740deeb682e2 100644 (file)
  *
  */
 
-
 #include <iostream>
-#include <vector>
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/features/fpfh.h>
 #include <pcl/features/normal_3d.h>
 
index 597a85865ae41fc29fcb7f4c16c3c9e4dd14f652..a937faf390347e7020d91e23a8ad6b5b05423e98 100644 (file)
@@ -40,7 +40,6 @@
 #include <iostream>
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/features/normal_3d.h>
 
 int
index 878c773cff9cf167f67420a006c984e1ad84eb4c..68d5cf70631a3e0108475b1745562b47a598ff83 100644 (file)
  */
 
 #include <iostream>
-#include <vector>
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/features/pfh.h>
 #include <pcl/features/normal_3d.h>
 
index 3ebfc106ec0a0e8838c955e5a5c121275da92be5..8e91072f3643325117f05abcd5c1f87d1f38cadd 100644 (file)
  *
  */
 
-
 #include <iostream>
-#include <vector>
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/features/normal_3d.h>
 #include <pcl/features/principal_curvatures.h>
 
-
 int
 main (int, char** argv)
 {
index 2e97eed2cab381bbb63bafccc40e1af3df85a936..aaa4c8e2d5f6be61eb489b6a6630dd44e287d97e 100644 (file)
  *
  *
  */
-// STL
+
 #include <iostream>
 
-// PCL
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/common/io.h>
 #include <pcl/features/normal_3d.h>
 #include <pcl/features/rift.h>
 #include <pcl/features/intensity_gradient.h>
index c20150ecec73c021ab46b55f7e2c561b73ac9320..60ea94775bf4f3545f9e095cd3abba55a2e4c462 100644 (file)
  */
 
 #include <iostream>
-#include <vector>
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/features/3dsc.h>
-#include <pcl/features/impl/3dsc.hpp>
 #include <pcl/features/normal_3d.h>
 
 int
index f4d8ad401a67fb37109bc450ad1b6e7452cb0704..49ab93ce3da4c43b1a36879141da76ac9528cfeb 100644 (file)
  *
  */
 
-
-
 #include <iostream>
-#include <vector>
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
 #include <pcl/features/normal_3d.h>
 #include <pcl/features/spin_image.h>
 
index c4c769b363ea0c8d3aef4ddd24682b152f2ef272..ec47b82a0965142c85708ab60966c3ddb3f2cf78 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
 
-// PCL
-#include <pcl/point_types.h>
 #include <pcl/filters/extract_indices.h>
 
 int
@@ -65,7 +62,7 @@ main (int, char**)
   indices.indices.push_back (2);
 
   pcl::ExtractIndices<PointType> extract_indices;
-  extract_indices.setIndices (boost::make_shared<const pcl::PointIndices> (indices));
+  extract_indices.setIndices (pcl::make_shared<const pcl::PointIndices> (indices));
   extract_indices.setInputCloud (cloud);
   pcl::PointCloud<pcl::PointXYZ>::Ptr output (new pcl::PointCloud<pcl::PointXYZ>);
   extract_indices.filter (*output);
index 6037061c82ab41bd39e89c2c167a6879353e0347..ba338bac9acae9e2cd35bde50adce7e378ad95a8 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
-#include <limits>
 
-// PCL
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/filters/filter.h>
 
 int
index d7e726c6a7ff9c4bfa3bfa62528fefb4f082893c..e6822ca164a0354d7dbb6fc2c2ab6577a47e5518 100644 (file)
 
 #include <iostream>
 
-#include <pcl/console/parse.h>
-#include <pcl/console/print.h>
-#include <pcl/point_types.h>
-#include <pcl/point_cloud.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/keypoints/harris_3d.h>
 
index 09d9df3f0f12b113a001e32b3a279fe077777e5d..8e3350221227e3cfc5dfe271df76e434bd614502 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
 
-// PCL
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/common/io.h>
 #include <pcl/keypoints/sift_keypoint.h>
-#include <pcl/keypoints/impl/sift_keypoint.hpp>
-#include <pcl/features/normal_3d.h>
-// #include <pcl/visualization/pcl_visualizer.h>
-       
+
 int
 main(int, char** argv)
 {
index 7c2a7b4805a81c095284cb5e0c7dd3af41f85fdb..d15f2054b1d3ca9507a5c7b5319c51a4c93ff024 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
 
-// PCL
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/common/io.h>
 #include <pcl/keypoints/sift_keypoint.h>
 #include <pcl/features/normal_3d.h>
-// #include <pcl/visualization/pcl_visualizer.h>
 
 /* This example shows how to estimate the SIFT points based on the
  * Normal gradients i.e. curvature than using the Intensity gradient
index def4a492f79f4b72bc5caddb90e91df749cec681..df29ca3e3a83d7b95305e04e3d9e1d06bce17aac 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
 
-// PCL
 #include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/common/io.h>
 #include <pcl/keypoints/sift_keypoint.h>
-#include <pcl/features/normal_3d.h>
-// #include <pcl/visualization/pcl_visualizer.h>
 
 /* This examples shows how to estimate the SIFT points based on the 
  * z gradient of the 3D points than using the Intensity gradient as
index ebf291cf077a489ce507f94390b4eaadaa5ea447..0e72dec2be2a0f2c574143f1fc1c1b82cd277c1c 100644 (file)
  */
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/console/print.h>
-
-#include <pcl/point_types.h>
-#include <pcl/PCLPointCloud2.h>
 
 #include <pcl/outofcore/outofcore.h>
 #include <pcl/outofcore/outofcore_impl.h>
-#include <pcl/outofcore/boost.h>
 
 using namespace pcl::outofcore;
 
index 3dafd48041ca52d0c855ed02674f0448d39541a5..6906fe0d0185334e766ffad362acb5f58efb5aca 100644 (file)
  */
 
 #include <pcl/io/pcd_io.h>
-#include <pcl/console/print.h>
 
 #include <pcl/outofcore/outofcore.h>
 #include <pcl/outofcore/outofcore_impl.h>
 
-#include <pcl/outofcore/boost.h>
-
-#include<pcl/point_types.h>
-#include <pcl/PCLPointCloud2.h>
-
 using namespace pcl::outofcore;
 
 using OctreeDisk = OutofcoreOctreeBase<OutofcoreOctreeDiskContainer<pcl::PointXYZ>, pcl::PointXYZ>;
index bdd29409be81cf95b13125aeb92a40aedf7134a0..354c9285bb29fc5c2c6209cc4d6d93d9e581c7f3 100644 (file)
  *
  */
 
-// Stdlib
 #include <cstdlib>
-#include <cmath>
-#include <climits>
 #include <thread>
 
 #include <boost/format.hpp>
-#include <boost/filesystem.hpp>
 
-// PCL input/output
 #include <pcl/console/parse.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/visualization/point_cloud_color_handlers.h>
 
-//PCL other
-#include <pcl/filters/passthrough.h>
-#include <pcl/segmentation/supervoxel_clustering.h>
-
-// The segmentation class this example is for
 #include <pcl/segmentation/cpc_segmentation.h>
 
-// VTK
-#include <vtkImageReader2Factory.h>
-#include <vtkImageReader2.h>
-#include <vtkImageData.h>
-#include <vtkImageFlip.h>
 #include <vtkPolyLine.h>
 
 using namespace std::chrono_literals;
index 684cf2a3bc8f6615242cd0ca92340785cc11daee..b91477cd13c7395b8621c0d67c619a064727654c 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
 
-// PCL
-#include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/filters/extract_indices.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/kdtree/kdtree.h>
 #include <pcl/segmentation/extract_clusters.h>
 
-
 int 
 main (int, char **argv)
 {
index e7e0dcb74d6a7f020fc8eb1c9abb44e75178c01c..7d5603f7dfff70d1826f30d9f5079b8de35cb7d7 100644 (file)
  *
  */
 
-// Stdlib
 #include <cstdlib>
-#include <cmath>
-#include <climits>
 #include <thread>
 
 #include <boost/format.hpp>
 
-
-// PCL input/output
 #include <pcl/console/parse.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/visualization/point_cloud_color_handlers.h>
-
-//PCL other
-#include <pcl/filters/passthrough.h>
-#include <pcl/segmentation/supervoxel_clustering.h>
 
-// The segmentation class this example is for
 #include <pcl/segmentation/lccp_segmentation.h>
 
-// VTK
-#include <vtkImageReader2Factory.h>
-#include <vtkImageReader2.h>
-#include <vtkImageData.h>
-#include <vtkImageFlip.h>
 #include <vtkPolyLine.h>
 
 using namespace std::chrono_literals;
index 12e3683683b670058d81756025f87ee3748ca37f..13389603fa5d406964152a2b32912fad8affdfee 100644 (file)
  *
  */
 
-// STL
 #include <iostream>
 
-// PCL
 #include <pcl/filters/filter.h>
 #include <pcl/features/normal_3d.h>
-#include <pcl/point_types.h>
-#include <pcl/point_cloud.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/segmentation/region_growing.h>
-#include <pcl/kdtree/kdtree.h>
 #include <pcl/common/time.h>
 #include <pcl/console/parse.h>
 
index 97ffa55b35b4034d971567b38397388b94cd5083..fbfabca97c4213620139769ab070671cda7363c4 100644 (file)
@@ -1,9 +1,6 @@
 #include <thread>
 
-#include <pcl/common/time.h>
 #include <pcl/console/parse.h>
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/io/png_io.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/visualization/pcl_visualizer.h>
index 842037cbb232996603df5cbb1e2152f74076fcb5..65342497a359bb9ab0176dab9ea3cd0b9db65057 100644 (file)
@@ -3,8 +3,6 @@
 #include <pcl/surface/on_nurbs/fitting_curve_2d_sdm.h>
 #include <pcl/surface/on_nurbs/triangulation.h>
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
 
 #include <pcl/visualization/pcl_visualizer.h>
index 7032bbe357305ab33ee4342b6d22d72fd30aa7f7..c6da7235fac9f616de8f7b9f03f4f80c25f91248 100644 (file)
@@ -1,8 +1,6 @@
 #include <pcl/surface/on_nurbs/fitting_curve_pdm.h>
 #include <pcl/surface/on_nurbs/triangulation.h>
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
 
 #include <pcl/visualization/pcl_visualizer.h>
index 9e986784aa2a241ea1ba8b5dc77d7373a18bf28e..f66b050cfdd512a1eb01176318e43b000e417969 100644 (file)
@@ -1,8 +1,6 @@
 #include <pcl/surface/on_nurbs/fitting_curve_2d.h>
 #include <pcl/surface/on_nurbs/triangulation.h>
 
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
 
 #include <pcl/visualization/pcl_visualizer.h>
index b018d5bb8396655a543497fb664eb2682aa898ff..0cbda86ac808188b1e5bbb9076c1ed77335c0bbb 100644 (file)
@@ -1,5 +1,4 @@
 #include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
 
 #include <pcl/visualization/pcl_visualizer.h>
index e63019ca072ff7521f23f38921c8a5dc2fefb4f8..3a71431a2b1b8fa2848e9f5a06442bd7880ba3be 100644 (file)
@@ -1,10 +1,6 @@
 #include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/io/pcd_io.h>
 
 #include <pcl/visualization/pcl_visualizer.h>
-#include <pcl/surface/on_nurbs/fitting_surface_tdm.h>
-#include <pcl/surface/on_nurbs/fitting_curve_2d_asdm.h>
 #include <pcl/surface/on_nurbs/triangulation.h>
 
 using Point = pcl::PointXYZ;
index 56c21f518d392deb2f489a125c36d8ff683a5f1c..74a520835871a3a613f543976a9a3edfee9cadd8 100644 (file)
@@ -1,6 +1,4 @@
 #include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <pcl/common/io.h>
 
 #include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/surface/on_nurbs/fitting_surface_tdm.h>
index 1d54d6090af98e508dd3d5a6c839bc8cba6ca2b0..4a24a6581daea2d8a0cd7d59ebc50ea4e9a8dc94 100644 (file)
 #pragma once
 
 #if defined __GNUC__
-#  pragma GCC system_header 
+#  pragma GCC system_header
 #endif
 
 // PCL includes
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/search/search.h>
@@ -133,7 +134,7 @@ namespace pcl
         search_parameter_(0), search_radius_(0), k_(0),
         fake_surface_(false)
       {}
-            
+
       /** \brief Empty destructor */
       virtual ~Feature () {}
 
@@ -329,7 +330,7 @@ namespace pcl
 
       /** \brief Empty constructor. */
       FeatureFromNormals () : normals_ () {}
-      
+
       /** \brief Empty destructor */
       virtual ~FeatureFromNormals () {}
 
@@ -392,7 +393,7 @@ namespace pcl
       {
         k_ = 1; // Search tree is not always used here.
       }
-      
+
       /** \brief Empty destructor */
       virtual ~FeatureFromLabels () {}
 
index b7e6baba59cc696a3bcc372f73f199fee1b5080f..8563a0e193e10cebc04c12bca59f7e223d2859d0 100644 (file)
@@ -57,7 +57,7 @@ namespace pcl
      * \param[in] cloud Point cloud containing the XYZ coordinates,
      * \param[in] normals Point cloud containing the corresponding surface normals.
      * \param[out] covariances Vector of computed covariances.
-     * \param[in] Optional: Epsilon for the expected noise along the surface normal (default: 0.001)
+     * \param[in] epsilon Optional: Epsilon for the expected noise along the surface normal (default: 0.001)
      */
     template <typename PointT, typename PointNT> inline void
     computeApproximateCovariances(const pcl::PointCloud<PointT>& cloud,
index 6936fb13bc74acb99c0ab273812c65c296026e35..c0e39748e82b697ec7b1c1195a398b511aab4985 100644 (file)
@@ -139,8 +139,8 @@ namespace pcl
         shape_interp_ = interp;
       }
 
-      /** \brief Returns the transformation aligning the point cloud to the canonical coordinate system
-       * \param[out] trans transformation
+      /**
+       * \brief Returns the transformation aligning the point cloud to the canonical coordinate system
        */
       const Eigen::Matrix4f&
       getTransform () const
@@ -338,7 +338,7 @@ namespace pcl
       /** \brief copy computed color histograms to output descriptor point cloud
        * \param[in] grid_size size of the regular grid used to compute the descriptor
        * \param[in] hists_size size of the color histograms
-       * \param[in,out] hists color histograms, which are finalized, since they are circular 
+       * \param[in,out] hists color histograms, which are finalized, since they are circular
        * \param[out] output output descriptor point cloud
        * \param[in,out] pos current position of output descriptor point cloud
        */
index 7b9386ffca2cebc3fd20ecc1e68d051784a63053..d8da789e964431f8847199c62af717f9abf4deb6 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_3DSC_HPP_
-#define PCL_FEATURES_IMPL_3DSC_HPP_
+#pragma once
 
-#include <cmath>
 #include <pcl/features/3dsc.h>
-#include <pcl/common/utils.h>
-#include <pcl/common/geometry.h>
+
 #include <pcl/common/angles.h>
+#include <pcl/common/geometry.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+#include <pcl/common/utils.h>
+
+#include <cmath>
+
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT> bool
@@ -272,4 +275,3 @@ pcl::ShapeContext3DEstimation<PointInT, PointNT, PointOutT>::computeFeature (Poi
 
 #define PCL_INSTANTIATE_ShapeContext3DEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::ShapeContext3DEstimation<T,NT,OutT>;
 
-#endif
index fcd1a41670db11d041eab0d4762841af51a4f096..91080cc78c8bcf4f7658fae76316d020bdba4038 100644 (file)
@@ -189,7 +189,7 @@ pcl::BOARDLocalReferenceFrameEstimation<PointInT, PointNT, PointOutT>::computePo
   //extract support points for Rz radius
   std::vector<int> neighbours_indices;
   std::vector<float> neighbours_distances;
-  int n_neighbours = this->searchForNeighbors (index, search_parameter_, neighbours_indices, neighbours_distances);
+  std::size_t n_neighbours = this->searchForNeighbors (index, search_parameter_, neighbours_indices, neighbours_distances);
 
   //check if there are enough neighbor points, otherwise compute a random X axis and use normal as Z axis
   if (n_neighbours < 6)
@@ -206,7 +206,7 @@ pcl::BOARDLocalReferenceFrameEstimation<PointInT, PointNT, PointOutT>::computePo
 
   //copy neighbours coordinates into eigen matrix
   Eigen::Matrix<float, Eigen::Dynamic, 3> neigh_points_mat (n_neighbours, 3);
-  for (int i = 0; i < n_neighbours; ++i)
+  for (std::size_t i = 0; i < n_neighbours; ++i)
   {
     neigh_points_mat.row (i) = (*surface_)[neighbours_indices[i]].getVector3fMap ();
   }
@@ -311,7 +311,7 @@ pcl::BOARDLocalReferenceFrameEstimation<PointInT, PointNT, PointOutT>::computePo
   if (!margin_point_found)
   {
     //find among points with neighDistance <= marginThresh*radius
-    for (int curr_neigh = 0; curr_neigh < n_neighbours; curr_neigh++)
+    for (std::size_t curr_neigh = 0; curr_neigh < n_neighbours; curr_neigh++)
     {
       const int& curr_neigh_idx = neighbours_indices[curr_neigh];
       const float& neigh_distance_sqr = neighbours_distances[curr_neigh];
@@ -448,7 +448,7 @@ pcl::BOARDLocalReferenceFrameEstimation<PointInT, PointNT, PointOutT>::computePo
   float max_hole_prob = -std::numeric_limits<float>::max ();
 
   //find holes
-  for (auto ch = first_no_border; ch < check_margin_array_size_; ch++)
+  for (auto ch = first_no_border; ch < static_cast<std::size_t>(check_margin_array_size_); ch++)
   {
     if (!check_margin_array_[ch])
     {
index 9410a5b29323494ecadc80dd8fa67242dcac6f16..ff55132810827411f877e95c263829715d709bde 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_BOUNDARY_H_
-#define PCL_FEATURES_IMPL_BOUNDARY_H_
+#pragma once
 
 #include <pcl/features/boundary.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
 #include <cfloat>
 
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT> bool
 pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>::isBoundaryPoint (
@@ -169,5 +171,3 @@ pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointClou
 
 #define PCL_INSTANTIATE_BoundaryEstimation(PointInT,PointNT,PointOutT) template class PCL_EXPORTS pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>;
 
-#endif    // PCL_FEATURES_IMPL_BOUNDARY_H_ 
-
index 0ee753e35c1dc04c13800d8a57e2003c012a0ec8..bbf3687943a40dc24bfe63eadd50af5a878afa20 100644 (file)
  *
  */
 
+
 #ifndef PCL_FEATURES_IMPL_BRISK_2D_HPP_
 #define PCL_FEATURES_IMPL_BRISK_2D_HPP_
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT, typename KeypointT, typename IntensityT>
-pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::BRISK2DEstimation ()
+BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::BRISK2DEstimation ()
   : rotation_invariance_enabled_ (true)
   , scale_invariance_enabled_ (true)
   , pattern_scale_ (1.0f)
@@ -81,21 +85,21 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::BRISK2DEstim
   generateKernel (r_list, n_list, 5.85f * pattern_scale_, 8.2f * pattern_scale_);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename KeypointT, typename IntensityT>
-pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::~BRISK2DEstimation ()
+BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::~BRISK2DEstimation ()
 {
-   if (pattern_points_) delete [] pattern_points_;
-  if (short_pairs_) delete [] short_pairs_;
-  if (long_pairs_) delete [] long_pairs_;
-  if (scale_list_) delete [] scale_list_;
-  if (size_list_) delete [] size_list_;
+  delete [] pattern_points_;
+  delete [] short_pairs_;
+  delete [] long_pairs_;
+  delete [] scale_list_;
+  delete [] size_list_;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename KeypointT, typename IntensityT> void
-pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::generateKernel (
-    std::vector<float> &radius_list, 
+BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::generateKernel (
+    std::vector<float> &radius_list,
     std::vector<int> &number_list, float d_max, float d_min,
     std::vector<int> index_change)
 {
@@ -132,15 +136,15 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::generateKern
     {
       // this is the rotation of the feature
       double theta = double (rot) * 2 * M_PI / double (n_rot_);
-      for (int ring = 0; ring < rings; ++ring)
+      for (int ring = 0; ring < static_cast<int>(rings); ++ring)
       {
         for (int num = 0; num < number_list[ring]; ++num)
         {
           // the actual coordinates on the circle
           double alpha = double (num) * 2 * M_PI / double (number_list[ring]);
-          
+
           // feature rotation plus angle of the point
-          pattern_iterator->x = scale_list_[scale] * radius_list[ring] * static_cast<float> (std::cos (alpha + theta)); 
+          pattern_iterator->x = scale_list_[scale] * radius_list[ring] * static_cast<float> (std::cos (alpha + theta));
           pattern_iterator->y = scale_list_[scale] * radius_list[ring] * static_cast<float> (sin (alpha + theta));
           // and the gaussian kernel sigma
           if (ring == 0)
@@ -210,9 +214,9 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::generateKern
   strings_ = int (std::ceil ((float (no_short_pairs_)) / 128.0)) * 4 * 4;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename KeypointT, typename IntensityT> inline int
-pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedIntensity (
+BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedIntensity (
     const std::vector<unsigned char> &image,
     int image_width, int,
     //const Stefan& integral,
@@ -243,26 +247,26 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedInte
     const int r_y   = static_cast<int> ((yf - float (y)) * 1024);
     const int r_x_1 = (1024 - r_x);
     const int r_y_1 = (1024 - r_y);
-    
+
     //+const unsigned char* ptr = static_cast<const unsigned char*> (&image.points[0].r) + x + y * imagecols;
     const unsigned char* ptr = static_cast<const unsigned char*>(&image[0]) + x + y * imagecols;
-    
+
     // just interpolate:
     ret_val = (r_x_1 * r_y_1 * int (*ptr));
-    
+
     //+ptr += sizeof (PointInT);
     ptr++;
 
     ret_val += (r_x * r_y_1 * int (*ptr));
-    
+
     //+ptr += (imagecols * sizeof (PointInT));
     ptr += imagecols;
-    
+
     ret_val += (r_x * r_y * int (*ptr));
-    
+
     //+ptr -= sizeof (PointInT);
     ptr--;
-    
+
     ret_val += (r_x_1 * r_y * int (*ptr));
     return (ret_val + 512) / 1024;
   }
@@ -306,32 +310,32 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedInte
   if (dx + dy > 2)
   {
     // now the calculation:
-    
+
     //+const unsigned char* ptr = static_cast<const unsigned char*> (&image.points[0].r) + x_left + imagecols * y_top;
     const unsigned char* ptr = static_cast<const unsigned char*>(&image[0]) + x_left + imagecols * y_top;
 
     // first the corners:
     ret_val = A * int (*ptr);
-  
+
     //+ptr += (dx + 1) * sizeof (PointInT);
     ptr += dx + 1;
-    
+
     ret_val += B * int (*ptr);
-    
+
     //+ptr += (dy * imagecols + 1) * sizeof (PointInT);
     ptr += dy * imagecols + 1;
-    
+
     ret_val += C * int (*ptr);
-    
+
     //+ptr -= (dx + 1) * sizeof (PointInT);
     ptr -= dx + 1;
-    
+
     ret_val += D * int (*ptr);
 
     // next the edges:
     //+int* ptr_integral;// = static_cast<int*> (integral.data) + x_left + integralcols * y_top + 1;
     const int* ptr_integral = static_cast<const int*> (&integral_image[0]) + x_left + integralcols * y_top + 1;
-    
+
     // find a simple path through the different surface corners
     const int tmp1 = (*ptr_integral);
     ptr_integral += dx;
@@ -368,16 +372,16 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedInte
   }
 
   // now the calculation:
-  
+
   //const unsigned char* ptr = static_cast<const unsigned char*> (&image.points[0].r) + x_left + imagecols * y_top;
   const unsigned char* ptr = static_cast<const unsigned char*>(&image[0]) + x_left + imagecols * y_top;
-  
+
   // first row:
   ret_val = A * int (*ptr);
-  
+
   //+ptr += sizeof (PointInT);
   ptr++;
-  
+
   //+const unsigned char* end1 = ptr + (dx * sizeof (PointInT));
   const unsigned char* end1 = ptr + dx;
 
@@ -385,25 +389,25 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedInte
   for (; ptr < end1; ptr++)
     ret_val += r_y_1_i * int (*ptr);
   ret_val += B * int (*ptr);
-  
+
   // middle ones:
   //+ptr += (imagecols - dx - 1) * sizeof (PointInT);
   ptr += imagecols - dx - 1;
-  
+
   //+const unsigned char* end_j = ptr + (dy * imagecols) * sizeof (PointInT);
   const unsigned char* end_j = ptr + dy * imagecols;
-  
+
   //+for (; ptr < end_j; ptr += (imagecols - dx - 1) * sizeof (PointInT))
   for (; ptr < end_j; ptr += imagecols - dx - 1)
   {
     ret_val += r_x_1_i * int (*ptr);
-    
+
     //+ptr += sizeof (PointInT);
     ptr++;
-    
+
     //+const unsigned char* end2 = ptr + (dx * sizeof (PointInT));
     const unsigned char* end2 = ptr + dx;
-    
+
     //+for (; ptr < end2; ptr += sizeof (PointInT))
     for (; ptr < end2; ptr++)
       ret_val += int (*ptr) * scaling;
@@ -412,10 +416,10 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedInte
   }
   // last row:
   ret_val += D * int (*ptr);
-  
+
   //+ptr += sizeof (PointInT);
   ptr++;
-  
+
   //+const unsigned char* end3 = ptr + (dx * sizeof (PointInT));
   const unsigned char* end3 = ptr + dx;
 
@@ -429,29 +433,28 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::smoothedInte
 }
 
 
-//////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT, typename KeypointT, typename IntensityT> bool
-pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::RoiPredicate (
+BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::RoiPredicate (
     const float min_x, const float min_y,
     const float max_x, const float max_y, const KeypointT& pt)
 {
   return ((pt.x < min_x) || (pt.x >= max_x) || (pt.y < min_y) || (pt.y >= max_y));
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename KeypointT, typename IntensityT> void
-pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
+BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
     PointCloudOutT &output)
 {
   if (!input_cloud_->isOrganized ())
-  {    
+  {
     PCL_ERROR ("[pcl::%s::initCompute] %s doesn't support non organized clouds!\n", name_.c_str ());
     return;
   }
 
   // image size
-  const int width = int (input_cloud_->width);
-  const int height = int (input_cloud_->height);
+  const index_t width = static_cast<index_t>(input_cloud_->width);
+  const index_t height = static_cast<index_t>(input_cloud_->height);
 
   // destination for intensity data; will be forwarded to BRISK
   std::vector<unsigned char> image_data (width*height);
@@ -463,13 +466,13 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
   std::size_t ksize = keypoints_->points.size ();
   std::vector<int> kscales; // remember the scale per keypoint
   kscales.resize (ksize);
+
   // initialize constants
   static const float lb_scalerange = std::log2 (scalerange_);
 
   typename std::vector<KeypointT, Eigen::aligned_allocator<KeypointT> >::iterator beginning = keypoints_->points.begin ();
   std::vector<int>::iterator beginningkscales = kscales.begin ();
-  
+
   static const float basic_size_06 = basic_size_ * 0.6f;
   unsigned int basicscale = 0;
 
@@ -518,9 +521,9 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
   // current integral image
   std::vector<int> integral ((width+1)*(height+1), 0);    // the integral image
 
-  for (std::size_t row_index = 1; row_index < height; ++row_index)
+  for (index_t row_index = 1; row_index < height; ++row_index)
   {
-    for (std::size_t col_index = 1; col_index < width; ++col_index)
+    for (index_t col_index = 1; col_index < width; ++col_index)
     {
       const std::size_t index = row_index*width+col_index;
       const std::size_t index2 = (row_index)*(width+1)+(col_index);
@@ -635,12 +638,12 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
     // now iterate through all the pairings
     UINT32_ALIAS* ptr2 = reinterpret_cast<UINT32_ALIAS*> (ptr);
     const BriskShortPair* max = short_pairs_ + no_short_pairs_;
-    
+
     for (BriskShortPair* iter = short_pairs_; iter < max; ++iter)
     {
       t1 = *(values + iter->i);
       t2 = *(values + iter->j);
-      
+
       if (t1 > t2)
         *ptr2 |= ((1) << shifter);
 
@@ -656,7 +659,7 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
     }
 
     //ptr += strings_;
+
     //// Account for the scale + orientation;
     //ptr += sizeof (output.points[0].scale);
     //ptr += sizeof (output.points[0].orientation);
@@ -671,6 +674,7 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
   delete [] values;
 }
 
+} // namespace pcl
 
 #endif  //#ifndef PCL_FEATURES_IMPL_BRISK_2D_HPP_
 
index 74782d4f86d7d54e8853c508c5a78f219e8b7b3a..deabc6968e18fe739558f77d994226fb1ca0c12c 100755 (executable)
@@ -71,7 +71,8 @@ pcl::CPPFEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut
     {
       PointOutT p;
       // No need to calculate feature for identity pair (i, j) as they aren't used in future calculations
-      if (i != j)
+      // @TODO: resolve issue with comparison in a better manner
+      if (static_cast<std::size_t>(i) != j)
       {
         if (
             pcl::computeCPPFPairFeature (input_->points[i].getVector4fMap (),
index 5e3a46703344bb5d688903a03b5d1d474be1992e..c0c94317d68c7ef11ae6485be4a0b43fd38e6bf1 100644 (file)
 
 #include <pcl/search/pcl_search.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 inline void
-pcl::solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
-                           const Eigen::Vector4f &point,
-                           Eigen::Vector4f &plane_parameters, float &curvature)
+solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
+                      const Eigen::Vector4f &point,
+                      Eigen::Vector4f &plane_parameters, float &curvature)
 {
   solvePlaneParameters (covariance_matrix, plane_parameters [0], plane_parameters [1], plane_parameters [2], curvature);
 
@@ -56,10 +59,10 @@ pcl::solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
   plane_parameters[3] = -1 * plane_parameters.dot (point);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 inline void
-pcl::solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
-                           float &nx, float &ny, float &nz, float &curvature)
+solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
+                      float &nx, float &ny, float &nz, float &curvature)
 {
   // Avoid getting hung on Eigen's optimizers
 //  for (int i = 0; i < 9; ++i)
@@ -86,11 +89,9 @@ pcl::solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
     curvature = 0;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> bool
-pcl::Feature<PointInT, PointOutT>::initCompute ()
+Feature<PointInT, PointOutT>::initCompute ()
 {
   if (!PCLBase<PointInT>::initCompute ())
   {
@@ -122,9 +123,9 @@ pcl::Feature<PointInT, PointOutT>::initCompute ()
     else
       tree_.reset (new pcl::search::KdTree<PointInT> (false));
   }
-  
+
   if (tree_->getInputCloud () != surface_) // Make sure the tree searches the surface
-    tree_->setInputCloud (surface_); 
+    tree_->setInputCloud (surface_);
 
 
   // Do a fast check to see if the search parameters are well defined
@@ -174,9 +175,9 @@ pcl::Feature<PointInT, PointOutT>::initCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> bool
-pcl::Feature<PointInT, PointOutT>::deinitCompute ()
+Feature<PointInT, PointOutT>::deinitCompute ()
 {
   // Reset the surface
   if (fake_surface_)
@@ -187,9 +188,9 @@ pcl::Feature<PointInT, PointOutT>::deinitCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> void
-pcl::Feature<PointInT, PointOutT>::compute (PointCloudOut &output)
+Feature<PointInT, PointOutT>::compute (PointCloudOut &output)
 {
   if (!initCompute ())
   {
@@ -225,11 +226,9 @@ pcl::Feature<PointInT, PointOutT>::compute (PointCloudOut &output)
   deinitCompute ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointNT, typename PointOutT> bool
-pcl::FeatureFromNormals<PointInT, PointNT, PointOutT>::initCompute ()
+FeatureFromNormals<PointInT, PointNT, PointOutT>::initCompute ()
 {
   if (!Feature<PointInT, PointOutT>::initCompute ())
   {
@@ -258,11 +257,9 @@ pcl::FeatureFromNormals<PointInT, PointNT, PointOutT>::initCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointLT, typename PointOutT> bool
-pcl::FeatureFromLabels<PointInT, PointLT, PointOutT>::initCompute ()
+FeatureFromLabels<PointInT, PointLT, PointOutT>::initCompute ()
 {
   if (!Feature<PointInT, PointOutT>::initCompute ())
   {
@@ -289,12 +286,10 @@ pcl::FeatureFromLabels<PointInT, PointLT, PointOutT>::initCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointRFT> bool
-pcl::FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (const std::size_t& indices_size,
-                                                                                    const LRFEstimationPtr& lrf_estimation)
+FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (const std::size_t& indices_size,
+                                                                               const LRFEstimationPtr& lrf_estimation)
 {
   if (frames_never_defined_)
     frames_.reset ();
@@ -334,5 +329,7 @@ pcl::FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFram
   return (true);
 }
 
+} // namespace pcl
+
 #endif  //#ifndef PCL_FEATURES_IMPL_FEATURE_H_
 
index fa53eff473e7dd4c47ebe65f2bd194e58b9e060c..ca58c39c89d45fe6071fe32d149b19ba63dc9169 100644 (file)
@@ -81,7 +81,7 @@ template<typename PointInT, typename PointNT, typename PointOutT, typename Signe
   }
 
   if (sampled_tree_->getInputCloud () != sampled_surface_) // Make sure the tree searches the sampled surface
-    sampled_tree_->setInputCloud (sampled_surface_); 
+    sampled_tree_->setInputCloud (sampled_surface_);
 
   return (true);
 }
@@ -121,7 +121,7 @@ template<typename PointInT, typename PointNT, typename PointOutT, typename Signe
 
   const std::size_t n_normal_neighbours =
       this->searchForNeighbors (index, search_parameter_, neighbours_indices, neighbours_distances);
-  if (n_normal_neighbours < min_neighbors_for_normal_axis_)
+  if (n_normal_neighbours < static_cast<std::size_t>(min_neighbors_for_normal_axis_))
   {
     if (!pcl::isFinite ((*normals_)[index]))
     {
@@ -158,7 +158,7 @@ template<typename PointInT, typename PointNT, typename PointOutT, typename Signe
   const std::size_t n_tangent_neighbours =
       sampled_tree_->radiusSearch ((*input_)[index], tangent_radius_, neighbours_indices, neighbours_distances);
 
-  if (n_tangent_neighbours < min_neighbors_for_tangent_axis_)
+  if (n_tangent_neighbours < static_cast<std::size_t>(min_neighbors_for_tangent_axis_))
   {
     //set X axis as a random axis
     x_axis = pcl::geometry::randomOrthogonalAxis (fitted_normal);
index e2bf64dd92ca5f5139dd2680b391c01085044094..08e8ac8b86fa76014b67480389e9a97c29580e01 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_FPFH_H_
-#define PCL_FEATURES_IMPL_FPFH_H_
+#pragma once
 
 #include <pcl/features/fpfh.h>
+
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/features/pfh_tools.h>
 
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT> bool
 pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::computePairFeatures (
@@ -57,7 +59,7 @@ pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::computePairFeatures (
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointInT, typename PointNT, typename PointOutT> void 
+template <typename PointInT, typename PointNT, typename PointOutT> void
 pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::computePointSPFHSignature (
     const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals,
     int p_idx, int row, const std::vector<int> &indices,
@@ -133,21 +135,21 @@ pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::weightPointSPFHSignature (
     weight = 1.0f / dists[idx];
 
     // Weight the SPFH of the query point with the SPFH of its neighbors
-    for (std::size_t f1_i = 0; f1_i < nr_bins_f1; ++f1_i)
+    for (Eigen::MatrixXf::Index f1_i = 0; f1_i < nr_bins_f1; ++f1_i)
     {
       val_f1 = hist_f1 (indices[idx], f1_i) * weight;
       sum_f1 += val_f1;
       fpfh_histogram[f1_i] += val_f1;
     }
 
-    for (std::size_t f2_i = 0; f2_i < nr_bins_f2; ++f2_i)
+    for (Eigen::MatrixXf::Index f2_i = 0; f2_i < nr_bins_f2; ++f2_i)
     {
       val_f2 = hist_f2 (indices[idx], f2_i) * weight;
       sum_f2 += val_f2;
       fpfh_histogram[f2_i + nr_bins_f1] += val_f2;
     }
 
-    for (std::size_t f3_i = 0; f3_i < nr_bins_f3; ++f3_i)
+    for (Eigen::MatrixXf::Index f3_i = 0; f3_i < nr_bins_f3; ++f3_i)
     {
       val_f3 = hist_f3 (indices[idx], f3_i) * weight;
       sum_f3 += val_f3;
@@ -258,7 +260,7 @@ pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut
         continue;
       }
 
-      // ... and remap the nn_indices values so that they represent row indices in the spfh_hist_* matrices 
+      // ... and remap the nn_indices values so that they represent row indices in the spfh_hist_* matrices
       // instead of indices into surface_->points
       for (auto &nn_index : nn_indices)
         nn_index = spfh_hist_lookup[nn_index];
@@ -285,7 +287,7 @@ pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut
         continue;
       }
 
-      // ... and remap the nn_indices values so that they represent row indices in the spfh_hist_* matrices 
+      // ... and remap the nn_indices values so that they represent row indices in the spfh_hist_* matrices
       // instead of indices into surface_->points
       for (auto &nn_index : nn_indices)
         nn_index = spfh_hist_lookup[nn_index];
@@ -301,5 +303,3 @@ pcl::FPFHEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut
 
 #define PCL_INSTANTIATE_FPFHEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::FPFHEstimation<T,NT,OutT>;
 
-#endif    // PCL_FEATURES_IMPL_FPFH_H_ 
-
index c0015a792fd7f75cc671aceedf27af099e0919ff..4001f894c1ee320b89bcb5e048d2ced46315d2a8 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_FPFH_OMP_H_
-#define PCL_FEATURES_IMPL_FPFH_OMP_H_
+#pragma once
+
+#include <pcl/features/fpfh_omp.h>
+
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 
 #include <numeric>
 
-#include <pcl/features/fpfh_omp.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT> void
@@ -106,9 +108,11 @@ pcl::FPFHEstimationOMP<PointInT, PointNT, PointOutT>::computeFeature (PointCloud
 
   // Compute SPFH signatures for every point that needs them
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (spfh_hist_lookup) private (nn_indices, nn_dists) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(spfh_hist_lookup, spfh_indices_vec) \
+  private(nn_indices, nn_dists) \
+  num_threads(threads_)
   for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t> (spfh_indices_vec.size ()); ++i)
   {
     // Get the next point index
@@ -133,9 +137,11 @@ pcl::FPFHEstimationOMP<PointInT, PointNT, PointOutT>::computeFeature (PointCloud
   nn_dists.clear();
 
   // Iterate over the entire index vector
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (nn_indices, nn_dists) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(nr_bins, output, spfh_hist_lookup) \
+  private(nn_dists, nn_indices) \
+  num_threads(threads_)
   for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
   {
     // Find the indices of point idx's neighbors...
@@ -168,5 +174,3 @@ pcl::FPFHEstimationOMP<PointInT, PointNT, PointOutT>::computeFeature (PointCloud
 
 #define PCL_INSTANTIATE_FPFHEstimationOMP(T,NT,OutT) template class PCL_EXPORTS pcl::FPFHEstimationOMP<T,NT,OutT>;
 
-#endif    // PCL_FEATURES_IMPL_FPFH_OMP_H_ 
-
index abf594b20bc49f5ca22041037557ea6a35fe1fcb..7eef7af910d171783d42e4353c7f952288a84c33 100644 (file)
  * $Id: feature.h 2784 2011-10-15 22:05:38Z aichim $
  */
 
+
 #ifndef PCL_INTEGRAL_IMAGE2D_IMPL_H_
 #define PCL_INTEGRAL_IMAGE2D_IMPL_H_
 
 #include <cstddef>
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename DataType, unsigned Dimension> void
-pcl::IntegralImage2D<DataType, Dimension>::setSecondOrderComputation (bool compute_second_order_integral_images)
+IntegralImage2D<DataType, Dimension>::setSecondOrderComputation (bool compute_second_order_integral_images)
 {
   compute_second_order_integral_images_ = compute_second_order_integral_images;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> void
-pcl::IntegralImage2D<DataType, Dimension>::setInput (const DataType * data, unsigned width,unsigned height, unsigned element_stride, unsigned row_stride)
+IntegralImage2D<DataType, Dimension>::setInput (const DataType * data, unsigned width,unsigned height, unsigned element_stride, unsigned row_stride)
 {
   if ((width + 1) * (height + 1) > first_order_integral_image_.size () )
   {
@@ -65,9 +69,9 @@ pcl::IntegralImage2D<DataType, Dimension>::setInput (const DataType * data, unsi
   computeIntegralImages (data, row_stride, element_stride);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> typename pcl::IntegralImage2D<DataType, Dimension>::ElementType
-pcl::IntegralImage2D<DataType, Dimension>::getFirstOrderSum (
+IntegralImage2D<DataType, Dimension>::getFirstOrderSum (
     unsigned start_x, unsigned start_y, unsigned width, unsigned height) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -79,9 +83,9 @@ pcl::IntegralImage2D<DataType, Dimension>::getFirstOrderSum (
           first_order_integral_image_[upper_right_idx] - first_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> typename pcl::IntegralImage2D<DataType, Dimension>::SecondOrderType
-pcl::IntegralImage2D<DataType, Dimension>::getSecondOrderSum (
+IntegralImage2D<DataType, Dimension>::getSecondOrderSum (
     unsigned start_x, unsigned start_y, unsigned width, unsigned height) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -93,9 +97,9 @@ pcl::IntegralImage2D<DataType, Dimension>::getSecondOrderSum (
           second_order_integral_image_[upper_right_idx] - second_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> unsigned
-pcl::IntegralImage2D<DataType, Dimension>::getFiniteElementsCount (
+IntegralImage2D<DataType, Dimension>::getFiniteElementsCount (
     unsigned start_x, unsigned start_y, unsigned width, unsigned height) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -107,9 +111,9 @@ pcl::IntegralImage2D<DataType, Dimension>::getFiniteElementsCount (
           finite_values_integral_image_[upper_right_idx] - finite_values_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> typename pcl::IntegralImage2D<DataType, Dimension>::ElementType
-pcl::IntegralImage2D<DataType, Dimension>::getFirstOrderSumSE (
+IntegralImage2D<DataType, Dimension>::getFirstOrderSumSE (
     unsigned start_x, unsigned start_y, unsigned end_x, unsigned end_y) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -121,9 +125,9 @@ pcl::IntegralImage2D<DataType, Dimension>::getFirstOrderSumSE (
           first_order_integral_image_[upper_right_idx] - first_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> typename pcl::IntegralImage2D<DataType, Dimension>::SecondOrderType
-pcl::IntegralImage2D<DataType, Dimension>::getSecondOrderSumSE (
+IntegralImage2D<DataType, Dimension>::getSecondOrderSumSE (
     unsigned start_x, unsigned start_y, unsigned end_x, unsigned end_y) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -135,9 +139,9 @@ pcl::IntegralImage2D<DataType, Dimension>::getSecondOrderSumSE (
           second_order_integral_image_[upper_right_idx] - second_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> unsigned
-pcl::IntegralImage2D<DataType, Dimension>::getFiniteElementsCountSE (
+IntegralImage2D<DataType, Dimension>::getFiniteElementsCountSE (
     unsigned start_x, unsigned start_y, unsigned end_x, unsigned end_y) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -149,9 +153,9 @@ pcl::IntegralImage2D<DataType, Dimension>::getFiniteElementsCountSE (
           finite_values_integral_image_[upper_right_idx] - finite_values_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType, unsigned Dimension> void
-pcl::IntegralImage2D<DataType, Dimension>::computeIntegralImages (
+IntegralImage2D<DataType, Dimension>::computeIntegralImages (
     const DataType *data, unsigned row_stride, unsigned element_stride)
 {
   ElementType* previous_row = &first_order_integral_image_[0];
@@ -218,10 +222,9 @@ pcl::IntegralImage2D<DataType, Dimension>::computeIntegralImages (
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 template <typename DataType> void
-pcl::IntegralImage2D<DataType, 1>::setInput (const DataType * data, unsigned width,unsigned height, unsigned element_stride, unsigned row_stride)
+IntegralImage2D<DataType, 1>::setInput (const DataType * data, unsigned width,unsigned height, unsigned element_stride, unsigned row_stride)
 {
   if ((width + 1) * (height + 1) > first_order_integral_image_.size () )
   {
@@ -235,9 +238,9 @@ pcl::IntegralImage2D<DataType, 1>::setInput (const DataType * data, unsigned wid
   computeIntegralImages (data, row_stride, element_stride);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> typename pcl::IntegralImage2D<DataType, 1>::ElementType
-pcl::IntegralImage2D<DataType, 1>::getFirstOrderSum (
+IntegralImage2D<DataType, 1>::getFirstOrderSum (
     unsigned start_x, unsigned start_y, unsigned width, unsigned height) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -249,9 +252,9 @@ pcl::IntegralImage2D<DataType, 1>::getFirstOrderSum (
           first_order_integral_image_[upper_right_idx] - first_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> typename pcl::IntegralImage2D<DataType, 1>::SecondOrderType
-pcl::IntegralImage2D<DataType, 1>::getSecondOrderSum (
+IntegralImage2D<DataType, 1>::getSecondOrderSum (
     unsigned start_x, unsigned start_y, unsigned width, unsigned height) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -263,9 +266,9 @@ pcl::IntegralImage2D<DataType, 1>::getSecondOrderSum (
           second_order_integral_image_[upper_right_idx] - second_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> unsigned
-pcl::IntegralImage2D<DataType, 1>::getFiniteElementsCount (
+IntegralImage2D<DataType, 1>::getFiniteElementsCount (
     unsigned start_x, unsigned start_y, unsigned width, unsigned height) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -277,9 +280,9 @@ pcl::IntegralImage2D<DataType, 1>::getFiniteElementsCount (
           finite_values_integral_image_[upper_right_idx] - finite_values_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> typename pcl::IntegralImage2D<DataType, 1>::ElementType
-pcl::IntegralImage2D<DataType, 1>::getFirstOrderSumSE (
+IntegralImage2D<DataType, 1>::getFirstOrderSumSE (
     unsigned start_x, unsigned start_y, unsigned end_x, unsigned end_y) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -291,9 +294,9 @@ pcl::IntegralImage2D<DataType, 1>::getFirstOrderSumSE (
           first_order_integral_image_[upper_right_idx] - first_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> typename pcl::IntegralImage2D<DataType, 1>::SecondOrderType
-pcl::IntegralImage2D<DataType, 1>::getSecondOrderSumSE (
+IntegralImage2D<DataType, 1>::getSecondOrderSumSE (
     unsigned start_x, unsigned start_y, unsigned end_x, unsigned end_y) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -305,9 +308,9 @@ pcl::IntegralImage2D<DataType, 1>::getSecondOrderSumSE (
           second_order_integral_image_[upper_right_idx] - second_order_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> unsigned
-pcl::IntegralImage2D<DataType, 1>::getFiniteElementsCountSE (
+IntegralImage2D<DataType, 1>::getFiniteElementsCountSE (
     unsigned start_x, unsigned start_y, unsigned end_x, unsigned end_y) const
 {
   const unsigned upper_left_idx      = start_y * (width_ + 1) + start_x;
@@ -319,9 +322,9 @@ pcl::IntegralImage2D<DataType, 1>::getFiniteElementsCountSE (
           finite_values_integral_image_[upper_right_idx] - finite_values_integral_image_[lower_left_idx]  );
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename DataType> void
-pcl::IntegralImage2D<DataType, 1>::computeIntegralImages (
+IntegralImage2D<DataType, 1>::computeIntegralImages (
     const DataType *data, unsigned row_stride, unsigned element_stride)
 {
   ElementType* previous_row = &first_order_integral_image_[0];
@@ -381,5 +384,8 @@ pcl::IntegralImage2D<DataType, 1>::computeIntegralImages (
     }
   }
 }
+
+} // namespace pcl
+
 #endif    // PCL_INTEGRAL_IMAGE2D_IMPL_H_
 
index 3afbee4214910dd5acae05aa87e8d406b661afca..72e51e57e150306b6f85c92db70d7f843b76cccc 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_INTENSITY_GRADIENT_H_
-#define PCL_FEATURES_IMPL_INTENSITY_GRADIENT_H_
+#pragma once
 
 #include <pcl/features/intensity_gradient.h>
 
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT, typename IntensitySelectorT> void
 pcl::IntensityGradientEstimation <PointInT, PointNT, PointOutT, IntensitySelectorT>::computePointIntensityGradient (
@@ -90,9 +92,7 @@ pcl::IntensityGradientEstimation <PointInT, PointNT, PointOutT, IntensitySelecto
   A (2, 0) = A (0, 2);
   A (2, 1) = A (1, 2);
 
-//*
-  Eigen::Vector3f x = A.colPivHouseholderQr ().solve (b);
-/*/
+//  Eigen::Vector3f x = A.colPivHouseholderQr ().solve (b);
 
   Eigen::Vector3f eigen_values;
   Eigen::Matrix3f eigen_vectors;
@@ -130,9 +130,8 @@ pcl::IntensityGradientEstimation <PointInT, PointNT, PointOutT, IntensitySelecto
 //  x [2] = b.dot (A.col (2));
 //  if (A.col (2).squaredNorm () != 0)
 //    x[2] /= A.col (2).squaredNorm ();
-  // Fit a hyperplane to the data
-
-//*/
+//  // Fit a hyperplane to the data
+//
 //  std::cout << A << "\n*\n" << bb << "\n=\n" << x << "\nvs.\n" << x2 << "\n\n";
 //  std::cout << A * x << "\nvs.\n" << A * x2 << "\n\n------\n";
   // Project the gradient vector, x, onto the tangent plane
@@ -152,9 +151,11 @@ pcl::IntensityGradientEstimation<PointInT, PointNT, PointOutT, IntensitySelector
   // If the data is dense, we don't need to check for NaN
   if (surface_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (nn_indices, nn_dists) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  private(nn_indices, nn_dists) \
+  num_threads(threads_)
     // Iterating over the entire index vector
     for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
     {
@@ -190,9 +191,11 @@ pcl::IntensityGradientEstimation<PointInT, PointNT, PointOutT, IntensitySelector
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (nn_indices, nn_dists) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  private(nn_indices, nn_dists) \
+  num_threads(threads_)
     // Iterating over the entire index vector
     for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
     {
@@ -234,4 +237,3 @@ pcl::IntensityGradientEstimation<PointInT, PointNT, PointOutT, IntensitySelector
 
 #define PCL_INSTANTIATE_IntensityGradientEstimation(InT,NT,OutT) template class PCL_EXPORTS pcl::IntensityGradientEstimation<InT,NT,OutT>;
 
-#endif    // PCL_FEATURES_IMPL_INTENSITY_GRADIENT_H_
index a849a385c97334a5b7b9730a52cb37c324c33458..42abc887c47a6800a2ed19aa568033570b76e043 100644 (file)
@@ -70,9 +70,11 @@ pcl::NormalEstimationOMP<PointInT, PointOutT>::computeFeature (PointCloudOut &ou
   // Save a few cycles by not checking every point for NaN/Inf values if the cloud is set to dense
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) firstprivate (nn_indices, nn_dists) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  firstprivate(nn_indices, nn_dists) \
+  num_threads(threads_)
     // Iterating over the entire index vector
     for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
     {
@@ -97,9 +99,11 @@ pcl::NormalEstimationOMP<PointInT, PointOutT>::computeFeature (PointCloudOut &ou
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) firstprivate (nn_indices, nn_dists) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  firstprivate(nn_indices, nn_dists) \
+  num_threads(threads_)
     // Iterating over the entire index vector
     for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
     {
index d0b57e846cc7c5b4632ebccae87d17a878214870..ada95705a2c008a90feb321ccc86e1a2b723aa76 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_PFH_H_
-#define PCL_FEATURES_IMPL_PFH_H_
+#pragma once
 
 #include <pcl/features/pfh.h>
 
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT> bool
 pcl::PFHEstimation<PointInT, PointNT, PointOutT>::computePairFeatures (
@@ -226,5 +228,3 @@ pcl::PFHEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut
 
 #define PCL_INSTANTIATE_PFHEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PFHEstimation<T,NT,OutT>;
 
-#endif    // PCL_FEATURES_IMPL_PFH_H_ 
-
index bfa2499d5b536955753a27179c7a82000d06adfc..e119adec61af93ca613b965ac107303550ddd7c3 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_PRINCIPAL_CURVATURES_H_
-#define PCL_FEATURES_IMPL_PRINCIPAL_CURVATURES_H_
+#pragma once
 
 #include <pcl/features/principal_curvatures.h>
 
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointNT, typename PointOutT> void
 pcl::PrincipalCurvaturesEstimation<PointInT, PointNT, PointOutT>::computePointPrincipalCurvatures (
@@ -162,4 +164,3 @@ pcl::PrincipalCurvaturesEstimation<PointInT, PointNT, PointOutT>::computeFeature
 
 #define PCL_INSTANTIATE_PrincipalCurvaturesEstimation(T,NT,OutT) template class PCL_EXPORTS pcl::PrincipalCurvaturesEstimation<T,NT,OutT>;
 
-#endif    // PCL_FEATURES_IMPL_PRINCIPAL_CURVATURES_H_
index 93e31c4b0d5d893a0989b852c24cdcdf7c0fe8fa..814bb38eb005c767ae6c0865225b2ec5f1d32980 100644 (file)
@@ -72,9 +72,10 @@ pcl::SHOTLocalReferenceFrameEstimationOMP<PointInT, PointOutT>::computeFeature (
   }
   tree_->setSortedResults (true);
 
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  num_threads(threads_)
   for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t> (indices_->size ()); ++i)
   {
     // point result
index 5e0f39f351d89845fe430aa4d9c8600ac16ad2fa..681f1ae3fce692070b644077c906211c67d12f50 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_SHOT_OMP_H_
-#define PCL_FEATURES_IMPL_SHOT_OMP_H_
+#pragma once
 
 #include <pcl/features/shot_omp.h>
+
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/common/time.h>
 #include <pcl/features/shot_lrf_omp.h>
 
+
 template<typename PointInT, typename PointNT, typename PointOutT, typename PointRFT> bool
 pcl::SHOTEstimationOMP<PointInT, PointNT, PointOutT, PointRFT>::initCompute ()
 {
@@ -148,9 +150,10 @@ pcl::SHOTEstimationOMP<PointInT, PointNT, PointOutT, PointRFT>::computeFeature (
 
   output.is_dense = true;
   // Iterating over the entire index vector
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  num_threads(threads_)
   for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
   {
 
@@ -234,9 +237,10 @@ pcl::SHOTColorEstimationOMP<PointInT, PointNT, PointOutT, PointRFT>::computeFeat
 
   output.is_dense = true;
   // Iterating over the entire index vector
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  num_threads(threads_)
   for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
   {
     Eigen::VectorXf shot;
@@ -290,4 +294,3 @@ pcl::SHOTColorEstimationOMP<PointInT, PointNT, PointOutT, PointRFT>::computeFeat
 #define PCL_INSTANTIATE_SHOTEstimationOMP(T,NT,OutT,RFT) template class PCL_EXPORTS pcl::SHOTEstimationOMP<T,NT,OutT,RFT>;
 #define PCL_INSTANTIATE_SHOTColorEstimationOMP(T,NT,OutT,RFT) template class PCL_EXPORTS pcl::SHOTColorEstimationOMP<T,NT,OutT,RFT>;
 
-#endif    // PCL_FEATURES_IMPL_SHOT_OMP_H_
index da6487ac893615c600b5650da379c9b613d02c7e..c2065a52c883daa55203483d777e60cf873e14b3 100644 (file)
  *
  */
 
-#ifndef PCL_FEATURES_IMPL_USC_HPP_
-#define PCL_FEATURES_IMPL_USC_HPP_
+#pragma once
 
 #include <pcl/features/usc.h>
 #include <pcl/features/shot_lrf.h>
-#include <pcl/common/geometry.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/geometry.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/common/utils.h>
 
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT, typename PointRFT> bool
 pcl::UniqueShapeContext<PointInT, PointOutT, PointRFT>::initCompute ()
@@ -260,4 +261,3 @@ pcl::UniqueShapeContext<PointInT, PointOutT, PointRFT>::computeFeature (PointClo
 
 #define PCL_INSTANTIATE_UniqueShapeContext(T,OutT,RFT) template class PCL_EXPORTS pcl::UniqueShapeContext<T,OutT,RFT>;
 
-#endif
index a69537d1f7416f41b604d7a7e05ea5e4f4c1249b..864a195fa53e9c3de9394c20a1b8b7203fdfb95e 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
+
 #include <vector>
 
-#include <boost/shared_ptr.hpp>
 
 namespace pcl
 {
index c84987f4401294c36364cacb378ba793897579f2..5219830c517175bb2e743a91b16e0bc45a00b8e5 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
index b662d86115ca1973626209d1c72e9b3d545e207c..2526f98caa004e6138ce104e3ab006f41c3b88cd 100644 (file)
@@ -42,6 +42,7 @@
 #include <vector>
 #include <cmath>
 #include <pcl/features/feature.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/PointIndices.h>
 
index 10afe013dad10d0ef377f23fdb6e7f17b2478de8..0405d8e30e27975e105e35682108a48bde8ccea2 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/features/eigen.h>
 #include <pcl/common/common_headers.h>
index a83fc0c36bb3a2cbef1367b8c2e7676dfb6d27ed..3961804320d3909df87e6f32055d99a56296c8c2 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/features/feature.h>
 #include <pcl/common/centroid.h>
index d6792550bc34b2485c9712cb9fca667da0082224..e2e3d357c99d890b23b1f34afb4a81d88c4ceb99 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/PolygonMesh.h>
 #include <pcl/features/feature.h>
index edda7a5cf9f83d9961779079274e4c046ce0e592..dca37083d7698d764bdf3c274029fc0e3f801341 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/features/feature.h>
 
@@ -89,7 +90,7 @@ namespace pcl
               int nr_subdiv, double plane_radius, PointOutT &radii, bool compute_histogram = false);
 
   template <typename PointInT, typename PointNT, typename PointOutT>
-  PCL_DEPRECATED("use computeRSD() overload that takes input point clouds by const reference")
+  PCL_DEPRECATED(1, 12, "use computeRSD() overload that takes input point clouds by const reference")
   Eigen::MatrixXf
   computeRSD (typename pcl::PointCloud<PointInT>::ConstPtr &surface, typename pcl::PointCloud<PointNT>::ConstPtr &normals,
               const std::vector<int> &indices, double max_dist,
@@ -115,7 +116,7 @@ namespace pcl
               int nr_subdiv, double plane_radius, PointOutT &radii, bool compute_histogram = false);
 
   template <typename PointNT, typename PointOutT>
-  PCL_DEPRECATED("use computeRSD() overload that takes input point cloud by const reference")
+  PCL_DEPRECATED(1, 12, "use computeRSD() overload that takes input point cloud by const reference")
   Eigen::MatrixXf
   computeRSD (typename pcl::PointCloud<PointNT>::ConstPtr &normals,
               const std::vector<int> &indices, const std::vector<float> &sqr_dists, double max_dist,
index 50258ddf9696fef9efaadf79ede4875e998b1888..5a133265a08e45cee75d0eab794c21008264927a 100644 (file)
@@ -371,7 +371,11 @@ void
 Narf::extractForInterestPoints (const RangeImage& range_image, const PointCloud<InterestPoint>& interest_points,
                                 int descriptor_size, float support_size, bool rotation_invariant, std::vector<Narf*>& feature_list)
 {
-  # pragma omp parallel for num_threads(max_no_of_threads) default(shared) schedule(dynamic, 10)
+#pragma omp parallel for \
+  default(none) \
+  shared(descriptor_size, feature_list, interest_points, range_image, rotation_invariant, support_size) \
+  schedule(dynamic, 10) \
+  num_threads(max_no_of_threads)
   //!!! nizar 20110408 : for OpenMP sake on MSVC this must be kept signed
   for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t>(interest_points.points.size ()); ++idx)
   {
index 6a270c21592314dd7b1494f7bc763c8241af133b..2a74d52bed23bfb5b32a4e8cbe5140eeb6325882 100644 (file)
@@ -49,7 +49,7 @@ using std::cerr;
 #include <pcl/features/eigen.h>
 #include <pcl/features/range_image_border_extractor.h>
 
-namespace pcl 
+namespace pcl
 {
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -67,7 +67,7 @@ RangeImageBorderExtractor::~RangeImageBorderExtractor()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::setRangeImage (const RangeImage* range_image)
 {
   clearData ();
@@ -75,7 +75,7 @@ RangeImageBorderExtractor::setRangeImage (const RangeImage* range_image)
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::clearData ()
 {
   //std::cout << PVARC(range_image_size_during_extraction_)<<PVARN((void*)this);
@@ -89,25 +89,25 @@ RangeImageBorderExtractor::clearData ()
       delete border_directions_[i];
   }
   delete[] surface_structure_; surface_structure_ = nullptr;
-  delete border_descriptions_; border_descriptions_ = nullptr;
   delete[] shadow_border_informations_; shadow_border_informations_ = nullptr;
   delete[] border_directions_; border_directions_ = nullptr;
-  
+  delete border_descriptions_; border_descriptions_ = nullptr;
+
   delete[] surface_change_scores_;  surface_change_scores_ = nullptr;
   delete[] surface_change_directions_;  surface_change_directions_ = nullptr;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::extractLocalSurfaceStructure ()
 {
   if (surface_structure_ != nullptr)
     return;
   //std::cerr << __PRETTY_FUNCTION__<<" called (this="<<(void*)this<<").\n";
   //MEASURE_FUNCTION_TIME;
-  
-  const auto width  = range_image_->width,
-      height = range_image_->height;
+
+  const auto width  = range_image_->width;
+  const auto height = range_image_->height;
   range_image_size_during_extraction_ = width*height;
   const auto array_size = range_image_size_during_extraction_;
   surface_structure_ = new LocalSurface*[array_size];
@@ -116,10 +116,25 @@ RangeImageBorderExtractor::extractLocalSurfaceStructure ()
   const auto sqrt_neighbors = parameters_.pixel_radius_plane_extraction/step_size + 1;
   const auto no_of_nearest_neighbors = sqrt_neighbors * sqrt_neighbors;
 
-# pragma omp parallel for num_threads(parameters_.max_no_of_threads) default(shared) schedule(dynamic, 10)
-  for (int y=0; y<height; ++y)
+  // iteration_type should be at least as big as unsigned int (decltype of height)
+  // But OpenMP requires signed size. Here we choose the minimum size that fits the bill
+  using iteration_type = std::conditional_t<sizeof(int) == sizeof(long int), long long int, long int>;
+
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  schedule(dynamic, 10) \
+  num_threads(parameters_.max_no_of_threads)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(height, no_of_nearest_neighbors, step_size, width) \
+  schedule(dynamic, 10) \
+  num_threads(parameters_.max_no_of_threads)
+#endif
+  for (iteration_type y=0; y<height; ++y)
   {
-    for (int x=0; x<width; ++x)
+    for (unsigned int x=0; x<width; ++x)
     {
       std::size_t index = y*width + x;
       LocalSurface*& local_surface = surface_structure_[index];
@@ -139,23 +154,23 @@ RangeImageBorderExtractor::extractLocalSurfaceStructure ()
         delete local_surface;
         local_surface = nullptr;
       }
-      
+
       //std::cout << x<<","<<y<<": ("<<local_surface->normal_no_jumps[0]<<","<<local_surface->normal_no_jumps[1]<<","<<local_surface->normal_no_jumps[2]<<")\n";
     }
   }
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::extractBorderScoreImages ()
 {
   if (!border_scores_left_.empty())
     return;
-  
+
   extractLocalSurfaceStructure();
-  
+
   //MEASURE_FUNCTION_TIME;
-  
+
   int width  = range_image_->width,
       height = range_image_->height,
       size   = width*height;
@@ -163,20 +178,24 @@ RangeImageBorderExtractor::extractBorderScoreImages ()
   border_scores_right_.resize (size);
   border_scores_top_.resize (size);
   border_scores_bottom_ .resize (size);
-  
-# pragma omp parallel for num_threads(parameters_.max_no_of_threads) default(shared) schedule(dynamic, 10)
+
+#pragma omp parallel for \
+  default(none) \
+  shared(height, width) \
+  schedule(dynamic, 10) \
+  num_threads(parameters_.max_no_of_threads)
   for (int y=0; y<height; ++y) {
     for (int x=0; x<width; ++x) {
       int index = y*width + x;
       float& left=border_scores_left_[index]; float& right=border_scores_right_[index];
-      float& top=border_scores_top_[index]; float& bottom=border_scores_bottom_[index]; 
+      float& top=border_scores_top_[index]; float& bottom=border_scores_bottom_[index];
       LocalSurface* local_surface_ptr = surface_structure_[index];
       if (local_surface_ptr==nullptr)
       {
         left=right=top=bottom = 0.0f;
         continue;
       }
-      
+
       left   = getNeighborDistanceChangeScore(*local_surface_ptr, x, y, -1,  0, parameters_.pixel_radius_borders);
       right  = getNeighborDistanceChangeScore(*local_surface_ptr, x, y,  1,  0, parameters_.pixel_radius_borders);
       top    = getNeighborDistanceChangeScore(*local_surface_ptr, x, y,  0, -1, parameters_.pixel_radius_borders);
@@ -186,13 +205,13 @@ RangeImageBorderExtractor::extractBorderScoreImages ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-float* 
+float*
 RangeImageBorderExtractor::updatedScoresAccordingToNeighborValues (const float* border_scores) const
 {
   float* new_scores = new float[range_image_->width*range_image_->height];
   float* new_scores_ptr = new_scores;
-  for (int y=0; y < static_cast<int> (range_image_->height); ++y) 
-    for (int x=0; x < static_cast<int> (range_image_->width); ++x) 
+  for (int y=0; y < static_cast<int> (range_image_->height); ++y)
+    for (int x=0; x < static_cast<int> (range_image_->width); ++x)
       *(new_scores_ptr++) = updatedScoreAccordingToNeighborValues(x, y, border_scores);
   return (new_scores);
 }
@@ -209,45 +228,45 @@ RangeImageBorderExtractor::updatedScoresAccordingToNeighborValues (const std::ve
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::updateScoresAccordingToNeighborValues ()
 {
   extractBorderScoreImages();
-  
+
   //MEASURE_FUNCTION_TIME;
-  
+
   border_scores_left_ = updatedScoresAccordingToNeighborValues(border_scores_left_);
   border_scores_right_ = updatedScoresAccordingToNeighborValues(border_scores_right_);
   border_scores_top_ = updatedScoresAccordingToNeighborValues(border_scores_top_);
   border_scores_bottom_ = updatedScoresAccordingToNeighborValues(border_scores_bottom_);
 }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::findAndEvaluateShadowBorders ()
 {
   if (shadow_border_informations_ != nullptr)
     return;
-  
+
   if (border_scores_left_.empty ())
   {
     std::cerr << __PRETTY_FUNCTION__<<": border score images not available!\n";
   }
-  
+
   //MEASURE_FUNCTION_TIME;
-  
+
   int width  = range_image_->width,
       height = range_image_->height;
   shadow_border_informations_ = new ShadowBorderIndices*[width*height];
-  for (int y = 0; y < static_cast<int> (height); ++y) 
+  for (int y = 0; y < static_cast<int> (height); ++y)
   {
-    for (int x = 0; x < static_cast<int> (width); ++x) 
+    for (int x = 0; x < static_cast<int> (width); ++x)
     {
       int index = y*width+x;
       ShadowBorderIndices*& shadow_border_indices = shadow_border_informations_[index];
       shadow_border_indices = nullptr;
       int shadow_border_idx;
-      
+
       if (changeScoreAccordingToShadowBorderValue(x, y, -1, 0, border_scores_left_.data (), border_scores_right_.data (), shadow_border_idx))
       {
         shadow_border_indices = (shadow_border_indices==nullptr ? new ShadowBorderIndices : shadow_border_indices);
@@ -273,16 +292,16 @@ RangeImageBorderExtractor::findAndEvaluateShadowBorders ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-float* 
+float*
 RangeImageBorderExtractor::getAnglesImageForBorderDirections ()
 {
   calculateBorderDirections();
-  
+
   int width  = range_image_->width,
       height = range_image_->height,
       array_size = width*height;
   float* angles_image = new float[array_size];
-  
+
   for (int y=0; y<height; ++y)
   {
     for (int x=0; x<width; ++x)
@@ -295,7 +314,7 @@ RangeImageBorderExtractor::getAnglesImageForBorderDirections ()
         continue;
       const Eigen::Vector3f& border_direction = *border_direction_ptr;
       const PointWithRange& point = range_image_->getPoint(index);
-      
+
       float border_direction_in_image_x, border_direction_in_image_y;
       float tmp_factor = point.range*range_image_->getAngularResolution();
       range_image_->getImagePoint(point.x+tmp_factor*border_direction[0], point.y+tmp_factor*border_direction[1], point.z+tmp_factor*border_direction[2],
@@ -308,18 +327,18 @@ RangeImageBorderExtractor::getAnglesImageForBorderDirections ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-float* 
+float*
 RangeImageBorderExtractor::getAnglesImageForSurfaceChangeDirections ()
 {
   //MEASURE_FUNCTION_TIME;
-  
+
   calculateSurfaceChanges();
-  
+
   int width  = range_image_->width,
       height = range_image_->height,
       array_size = width*height;
   float* angles_image = new float[array_size];
-  
+
   for (int y=0; y<height; ++y)
   {
     for (int x=0; x<width; ++x)
@@ -332,7 +351,7 @@ RangeImageBorderExtractor::getAnglesImageForSurfaceChangeDirections ()
         continue;
       const Eigen::Vector3f& direction = surface_change_directions_[index];
       const PointWithRange& point = range_image_->getPoint(index);
-      
+
       float border_direction_in_image_x, border_direction_in_image_y;
       float tmp_factor = point.range*range_image_->getAngularResolution();
       range_image_->getImagePoint(point.x+tmp_factor*direction[0], point.y+tmp_factor*direction[1], point.z+tmp_factor*direction[2],
@@ -350,28 +369,28 @@ RangeImageBorderExtractor::getAnglesImageForSurfaceChangeDirections ()
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::classifyBorders ()
 {
   if (border_descriptions_ != nullptr)
     return;
-  
+
   // Get local plane approximations
   extractLocalSurfaceStructure();
-  
+
   // Get scores for every point, describing how probable a border in that direction is
   extractBorderScoreImages();
-  
+
   // Propagate values to neighboring pixels
   updateScoresAccordingToNeighborValues();
-  
+
   // Change border score according to the existence of a shadow border
   findAndEvaluateShadowBorders();
-  
+
   int width  = range_image_->width,
       height = range_image_->height,
       size   = width*height;
-  
+
   BorderDescription initial_border_description;
   initial_border_description.traits = 0;
   border_descriptions_ = new PointCloudOut;
@@ -379,21 +398,21 @@ RangeImageBorderExtractor::classifyBorders ()
   border_descriptions_->height = height;
   border_descriptions_->is_dense = true;
   border_descriptions_->points.resize(size, initial_border_description);
-  
-  for (int y = 0; y < static_cast<int> (height); ++y) 
+
+  for (int y = 0; y < static_cast<int> (height); ++y)
   {
-    for (int x = 0; x < static_cast<int> (width); ++x) 
+    for (int x = 0; x < static_cast<int> (width); ++x)
     {
       int index = y*width+x;
       BorderDescription& border_description = border_descriptions_->points[index];
       border_description.x = x;
       border_description.y = y;
       BorderTraits& border_traits = border_description.traits;
-      
+
       ShadowBorderIndices* shadow_border_indices = shadow_border_informations_[index];
       if (shadow_border_indices == nullptr)
         continue;
-      
+
       int shadow_border_index = shadow_border_indices->left;
       if (shadow_border_index >= 0 && checkIfMaximum(x, y, -1, 0, border_scores_left_.data (), shadow_border_index))
       {
@@ -406,7 +425,7 @@ RangeImageBorderExtractor::classifyBorders ()
           veil_point[BORDER_TRAIT__VEIL_POINT] = veil_point[BORDER_TRAIT__VEIL_POINT_RIGHT] = true;
         }
       }
-      
+
       shadow_border_index = shadow_border_indices->right;
       if (shadow_border_index >= 0 && checkIfMaximum(x, y, 1, 0, border_scores_right_.data (), shadow_border_index))
       {
@@ -419,7 +438,7 @@ RangeImageBorderExtractor::classifyBorders ()
           veil_point[BORDER_TRAIT__VEIL_POINT] = veil_point[BORDER_TRAIT__VEIL_POINT_LEFT] = true;
         }
       }
-      
+
       shadow_border_index = shadow_border_indices->top;
       if (shadow_border_index >= 0 && checkIfMaximum(x, y, 0, -1, border_scores_top_.data (), shadow_border_index))
       {
@@ -433,7 +452,7 @@ RangeImageBorderExtractor::classifyBorders ()
           veil_point[BORDER_TRAIT__VEIL_POINT] = veil_point[BORDER_TRAIT__VEIL_POINT_BOTTOM] = true;
         }
       }
-      
+
       shadow_border_index = shadow_border_indices->bottom;
       if (shadow_border_index >= 0 && checkIfMaximum(x, y, 0, 1, border_scores_bottom_.data (), shadow_border_index))
       {
@@ -447,7 +466,7 @@ RangeImageBorderExtractor::classifyBorders ()
           veil_point[BORDER_TRAIT__VEIL_POINT] = veil_point[BORDER_TRAIT__VEIL_POINT_TOP] = true;
         }
       }
-      
+
       //if (border_traits[BORDER_TRAIT__OBSTACLE_BORDER])
       //{
         //border_points.push_back(&border_description);
@@ -457,15 +476,15 @@ RangeImageBorderExtractor::classifyBorders ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::calculateBorderDirections ()
 {
   if (border_directions_!=nullptr)
     return;
   classifyBorders();
-  
+
   //MEASURE_FUNCTION_TIME;
-  
+
   int width  = range_image_->width,
       height = range_image_->height,
       size   = width*height;
@@ -477,7 +496,7 @@ RangeImageBorderExtractor::calculateBorderDirections ()
       calculateBorderDirection(x, y);
     }
   }
-  
+
   Eigen::Vector3f** average_border_directions = new Eigen::Vector3f*[size];
   int radius = parameters_.pixel_radius_border_direction;
   int minimum_weight = radius+1;
@@ -502,7 +521,7 @@ RangeImageBorderExtractor::calculateBorderDirections ()
           const Eigen::Vector3f* neighbor_border_direction = border_directions_[index2];
           if (neighbor_border_direction==nullptr || index2==index)
             continue;
-          
+
           // Opposite directions?
           float cos_angle = neighbor_border_direction->dot(*border_direction);
           if (cos_angle<min_cos_angle)
@@ -512,12 +531,12 @@ RangeImageBorderExtractor::calculateBorderDirections ()
           }
           //else
             //std::cout << "No reject\n";
-          
+
           // Border in between?
           float border_between_points_score = getNeighborDistanceChangeScore(*surface_structure_[index], x, y, x2-x,  y2-y, 1);
           if (std::abs(border_between_points_score) >= 0.95f*parameters_.minimum_border_probability)
             continue;
-          
+
           *average_border_direction += *neighbor_border_direction;
           weight_sum += 1.0f;
         }
@@ -531,7 +550,7 @@ RangeImageBorderExtractor::calculateBorderDirections ()
         average_border_direction->normalize();
     }
   }
-  
+
   for (int i=0; i<size; ++i)
     delete border_directions_[i];
   delete[] border_directions_;
@@ -539,22 +558,26 @@ RangeImageBorderExtractor::calculateBorderDirections ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::calculateSurfaceChanges ()
 {
   if (surface_change_scores_!=nullptr)
     return;
-  
+
   calculateBorderDirections();
-  
+
   //MEASURE_FUNCTION_TIME;
-  
+
   int width  = range_image_->width,
       height = range_image_->height,
       size   = width*height;
   surface_change_scores_ = new float[size];
   surface_change_directions_ = new Eigen::Vector3f[size];
-# pragma omp parallel for num_threads(parameters_.max_no_of_threads) default(shared) schedule(dynamic, 10)
+#pragma omp parallel for \
+  default(none) \
+  shared(height, width) \
+  schedule(dynamic, 10) \
+  num_threads(parameters_.max_no_of_threads)
   for (int y=0; y<height; ++y)
   {
     for (int x=0; x<width; ++x)
@@ -564,7 +587,7 @@ RangeImageBorderExtractor::calculateSurfaceChanges ()
       surface_change_score = 0.0f;
       Eigen::Vector3f& surface_change_direction = surface_change_directions_[index];
       surface_change_direction.setZero();
-      
+
       const BorderTraits& border_traits = border_descriptions_->points[index].traits;
       if (border_traits[BORDER_TRAIT__VEIL_POINT] || border_traits[BORDER_TRAIT__SHADOW_BORDER])
         continue;
@@ -588,13 +611,13 @@ RangeImageBorderExtractor::calculateSurfaceChanges ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::blurSurfaceChanges ()
 {
   int blur_radius = 1;
-  
+
   const RangeImage& range_image = *range_image_;
-  
+
   Eigen::Vector3f* blurred_directions = new Eigen::Vector3f[range_image.width*range_image.height];
   float* blurred_scores = new float[range_image.width*range_image.height];
   for (int y=0; y<int(range_image.height); ++y)
@@ -649,11 +672,11 @@ RangeImageBorderExtractor::blurSurfaceChanges ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::computeFeature (PointCloudOut& output)
 {
   output.points.clear();
-  
+
   if (indices_)
   {
     std::cerr << __PRETTY_FUNCTION__
@@ -662,7 +685,7 @@ RangeImageBorderExtractor::computeFeature (PointCloudOut& output)
     output.points.clear ();
     return;
   }
-  
+
   if (range_image_==nullptr)
   {
     std::cerr << __PRETTY_FUNCTION__
@@ -676,7 +699,7 @@ RangeImageBorderExtractor::computeFeature (PointCloudOut& output)
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 RangeImageBorderExtractor::compute (PointCloudOut& output)
 {
   computeFeature (output);
index e4319a2d471114401880439cf0b36599bc2aa10e..47a2aa6ac6739d6fc6a0cd82cafd6f5d585b9cd8 100644 (file)
@@ -14,6 +14,7 @@ endif()
 
 set(srcs
   src/conditional_removal.cpp
+  src/convolution.cpp
   src/crop_box.cpp
   src/extract_indices.cpp
   src/filter.cpp
index 1d4c47509e408b63bbe901d390ad7894b85c748c..85b20ffb9c1f961ec31c2b920a3d574722549ca8 100644 (file)
@@ -47,8 +47,6 @@
 // Marking all Boost headers as system headers to remove warnings
 #include <boost/random.hpp>
 #include <boost/random/normal_distribution.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/make_shared.hpp>
 #include <boost/dynamic_bitset.hpp>
 #include <boost/mpl/size.hpp>
 #include <boost/fusion/sequence/intrinsic/at_key.hpp>
index 0e68a4115b2c7557af6f334326c16fcca98fdbdb..baf4a6df0c0dbc9014101210e02525e412cdd070 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include "clipper3D.h"
 
index 0196ca08676315f8a5cba9c33282681b0d5779e8..b741ff7e8bf7369e063be1add8f455b91132ad2c 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <vector>
index 7fba1e9ffd272c1680030b2f2c5ca9693fa436a9..df7b58a51d056e9939a1fc7a86421f7a09eea374 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/common/eigen.h>
 #include <pcl/filters/filter.h>
index 3658a3d5de1f0b1253cabc01810bbf765d50ca26..ff2c61c8dad9659e637d9c0c9b9d04e75e317855 100644 (file)
@@ -40,7 +40,6 @@
 #pragma once
 
 #include <pcl/common/eigen.h>
-#include <pcl/common/point_operators.h>
 #include <pcl/point_cloud.h>
 #include <pcl/exceptions.h>
 #include <pcl/pcl_base.h>
index 5bba6dd0c3bd176ad848f237185d7e6ed0fe2c1f..76231a2452ec1dcfd8c789ee8160608e06ebac11 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/filters/filter_indices.h>
 
index 3ba04e4e1d440f721d1f2e08fba069d3206ff5ad..4beee5a93e6dade8f8aa1f2ff031c02a7cefa991 100644 (file)
@@ -70,7 +70,7 @@ namespace pcl
         * \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
         */
       CropBox (bool extract_removed_indices = false) :
-        FilterIndices<PointT>::FilterIndices (extract_removed_indices),
+        FilterIndices<PointT> (extract_removed_indices),
         min_pt_ (Eigen::Vector4f (-1, -1, -1, 1)),
         max_pt_ (Eigen::Vector4f (1, 1, 1, 1)),
         rotation_ (Eigen::Vector3f::Zero ()),
@@ -174,12 +174,6 @@ namespace pcl
       using FilterIndices<PointT>::extract_removed_indices_;
       using FilterIndices<PointT>::removed_indices_;
 
-      /** \brief Sample of point indices into a separate PointCloud
-        * \param[out] output the resultant point cloud
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Sample of point indices
         * \param[out] indices the resultant point cloud indices
         */
index 159573cdf8f212ac7acbb201360c2a3f56f5b0be..2759857e31d447c51ce7baf6ed304593f32fa328 100644 (file)
@@ -83,9 +83,6 @@ namespace pcl
   class Filter : public PCLBase<PointT>
   {
     public:
-      using PCLBase<PointT>::indices_;
-      using PCLBase<PointT>::input_;
-
       using Ptr = shared_ptr<Filter<PointT> >;
       using ConstPtr = shared_ptr<const Filter<PointT> >;
 
@@ -104,9 +101,6 @@ namespace pcl
       {
       }
 
-      /** \brief Empty destructor */
-      ~Filter () {}
-
       /** \brief Get the point indices being removed */
       inline IndicesConstPtr const
       getRemovedIndices () const
@@ -154,6 +148,9 @@ namespace pcl
 
     protected:
 
+      using PCLBase<PointT>::indices_;
+      using PCLBase<PointT>::input_;
+
       using PCLBase<PointT>::initCompute;
       using PCLBase<PointT>::deinitCompute;
 
@@ -209,9 +206,6 @@ namespace pcl
       {
       }
 
-      /** \brief Empty destructor */
-      ~Filter () {}
-
       /** \brief Get the point indices being removed */
       inline IndicesConstPtr const
       getRemovedIndices () const
index bd87ae1c38c23b809065f0cd152150d7985fc605..12374b3593c8edf1fa8177d2de203d137dd01fb4 100644 (file)
@@ -85,29 +85,19 @@ namespace pcl
         * \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
         */
       FilterIndices (bool extract_removed_indices = false) :
-          negative_ (false), 
-          keep_organized_ (false), 
+          Filter<PointT> (extract_removed_indices),
+          negative_ (false),
+          keep_organized_ (false),
           user_filter_value_ (std::numeric_limits<float>::quiet_NaN ())
-      {
-        extract_removed_indices_ = extract_removed_indices;
-      }
-
-      /** \brief Empty virtual destructor. */
-      
-      ~FilterIndices ()
       {
       }
 
-      inline void
-      filter (PointCloud &output)
-      {
-        pcl::Filter<PointT>::filter (output);
-      }
+      using Filter<PointT>::filter;
 
       /** \brief Calls the filtering method and returns the filtered point cloud indices.
         * \param[out] indices the resultant filtered point cloud indices
         */
-      inline void
+      void
       filter (std::vector<int> &indices)
       {
         if (!initCompute ())
@@ -171,6 +161,8 @@ namespace pcl
 
       using Filter<PointT>::initCompute;
       using Filter<PointT>::deinitCompute;
+      using Filter<PointT>::input_;
+      using Filter<PointT>::removed_indices_;
 
       /** \brief False = normal filter behavior (default), true = inverted behavior. */
       bool negative_;
@@ -187,7 +179,7 @@ namespace pcl
 
       /** \brief Abstract filter method for point cloud. */
       void
-      applyFilter (PointCloud &output) override = 0;
+      applyFilter (PointCloud &output) override;
   };
 
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -210,24 +202,14 @@ namespace pcl
         * \param[in] extract_removed_indices Set to true if you want to extract the indices of points being removed (default = false).
         */
       FilterIndices (bool extract_removed_indices = false) :
+          Filter<PCLPointCloud2> (extract_removed_indices),
           negative_ (false), 
           keep_organized_ (false), 
           user_filter_value_ (std::numeric_limits<float>::quiet_NaN ())
-      {
-        extract_removed_indices_ = extract_removed_indices;
-      }
-
-      /** \brief Empty virtual destructor. */
-      
-      ~FilterIndices ()
       {
       }
 
-      virtual void
-      filter (PCLPointCloud2 &output)
-      {
-        pcl::Filter<PCLPointCloud2>::filter (output);
-      }
+      using Filter<PCLPointCloud2>::filter;
 
       /** \brief Calls the filtering method and returns the filtered point cloud indices.
         * \param[out] indices the resultant filtered point cloud indices
index 18b64a888d499def6284b92d01f3e7e2531671b3..1e06be3b0f5e67ee1f7f11dd9017984fc56aceba 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/filters/filter_indices.h>
@@ -89,7 +90,7 @@ namespace pcl
       using Filter<PointT>::getClassName;
 
       FrustumCulling (bool extract_removed_indices = false) 
-        : FilterIndices<PointT>::FilterIndices (extract_removed_indices)
+        : FilterIndices<PointT> (extract_removed_indices)
         , camera_pose_ (Eigen::Matrix4f::Identity ())
         , hfov_ (60.0f)
         , vfov_ (60.0f)
@@ -204,12 +205,6 @@ namespace pcl
       using FilterIndices<PointT>::extract_removed_indices_;
       using FilterIndices<PointT>::removed_indices_;
 
-      /** \brief Sample of point indices into a separate PointCloud
-        * \param[out] output the resultant point cloud
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Sample of point indices
         * \param[out] indices the resultant point cloud indices
         */
index bce677a91f08eae9ea608419b0f23c660f271279..6f2c9207f79b67a9744d3645784bfe6baef0a78c 100644 (file)
@@ -90,11 +90,7 @@ pcl::FieldComparison<PointT>::FieldComparison (
 template <typename PointT>
 pcl::FieldComparison<PointT>::~FieldComparison () 
 {
-  if (point_data_ != nullptr)
-  {
-    delete point_data_;
-    point_data_ = nullptr;
-  }
+  delete point_data_;
 }
 
 //////////////////////////////////////////////////////////////////////////
index bf2817d00b56681524214b9b36e255c1854623c9..4a2f56afb279b017878bc2d5442ad717e6b4d23a 100644 (file)
@@ -3,6 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2011, Willow Garage, Inc.
+ *  Copyright (c) 2012-, Open Perception, Inc.
  *
  *  All rights reserved.
  *
  *
  */
 
-#ifndef PCL_FILTERS_CONVOLUTION_IMPL_HPP
-#define PCL_FILTERS_CONVOLUTION_IMPL_HPP
+#pragma once
 
 #include <pcl/pcl_config.h>
 #include <pcl/common/distances.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
+
+namespace pcl
+{
+namespace filters
+{
 
 template <typename PointIn, typename PointOut>
-pcl::filters::Convolution<PointIn, PointOut>::Convolution ()
+Convolution<PointIn, PointOut>::Convolution ()
   : borders_policy_ (BORDERS_POLICY_IGNORE)
   , distance_threshold_ (std::numeric_limits<float>::infinity ())
   , input_ ()
@@ -54,7 +61,7 @@ pcl::filters::Convolution<PointIn, PointOut>::Convolution ()
 {}
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::initCompute (PointCloud<PointOut>& output)
+Convolution<PointIn, PointOut>::initCompute (PointCloud<PointOut>& output)
 {
   if (borders_policy_ != BORDERS_POLICY_IGNORE &&
       borders_policy_ != BORDERS_POLICY_MIRROR &&
@@ -85,7 +92,7 @@ pcl::filters::Convolution<PointIn, PointOut>::initCompute (PointCloud<PointOut>&
 }
 
 template <typename PointIn, typename PointOut> inline void
-pcl::filters::Convolution<PointIn, PointOut>::convolveRows (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolveRows (PointCloudOut& output)
 {
   try
   {
@@ -105,7 +112,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolveRows (PointCloudOut& outpu
 }
 
 template <typename PointIn, typename PointOut> inline void
-pcl::filters::Convolution<PointIn, PointOut>::convolveCols (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolveCols (PointCloudOut& output)
 {
   try
   {
@@ -125,9 +132,9 @@ pcl::filters::Convolution<PointIn, PointOut>::convolveCols (PointCloudOut& outpu
 }
 
 template <typename PointIn, typename PointOut> inline void
-pcl::filters::Convolution<PointIn, PointOut>::convolve (const Eigen::ArrayXf& h_kernel,
-                                                       const Eigen::ArrayXf& v_kernel,
-                                                       PointCloud<PointOut>& output)
+Convolution<PointIn, PointOut>::convolve (const Eigen::ArrayXf& h_kernel,
+                                          const Eigen::ArrayXf& v_kernel,
+                                          PointCloud<PointOut>& output)
 {
   try
   {
@@ -146,7 +153,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve (const Eigen::ArrayXf& h_
 }
 
 template <typename PointIn, typename PointOut> inline void
-pcl::filters::Convolution<PointIn, PointOut>::convolve (PointCloud<PointOut>& output)
+Convolution<PointIn, PointOut>::convolve (PointCloud<PointOut>& output)
 {
   try
   {
@@ -163,7 +170,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve (PointCloud<PointOut>& ou
 }
 
 template <typename PointIn, typename PointOut> inline PointOut
-pcl::filters::Convolution<PointIn, PointOut>::convolveOneRowDense (int i, int j)
+Convolution<PointIn, PointOut>::convolveOneRowDense (int i, int j)
 {
   using namespace pcl::common;
   PointOut result;
@@ -173,7 +180,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolveOneRowDense (int i, int j)
 }
 
 template <typename PointIn, typename PointOut> inline PointOut
-pcl::filters::Convolution<PointIn, PointOut>::convolveOneColDense (int i, int j)
+Convolution<PointIn, PointOut>::convolveOneColDense (int i, int j)
 {
   using namespace pcl::common;
   PointOut result;
@@ -183,7 +190,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolveOneColDense (int i, int j)
 }
 
 template <typename PointIn, typename PointOut> inline PointOut
-pcl::filters::Convolution<PointIn, PointOut>::convolveOneRowNonDense (int i, int j)
+Convolution<PointIn, PointOut>::convolveOneRowNonDense (int i, int j)
 {
   using namespace pcl::common;
   PointOut result;
@@ -209,7 +216,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolveOneRowNonDense (int i, int
 }
 
 template <typename PointIn, typename PointOut> inline PointOut
-pcl::filters::Convolution<PointIn, PointOut>::convolveOneColNonDense (int i, int j)
+Convolution<PointIn, PointOut>::convolveOneColNonDense (int i, int j)
 {
   using namespace pcl::common;
   PointOut result;
@@ -234,174 +241,44 @@ pcl::filters::Convolution<PointIn, PointOut>::convolveOneColNonDense (int i, int
   return (result);
 }
 
-namespace pcl
-{
-  namespace filters
-  {
-    template<> pcl::PointXYZRGB
-    Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowDense (int i, int j)
-    {
-      pcl::PointXYZRGB result;
-      float r = 0, g = 0, b = 0;
-      for (int k = kernel_width_, l = i - half_width_; k > -1; --k, ++l)
-      {
-        result.x += (*input_) (l,j).x * kernel_[k];
-        result.y += (*input_) (l,j).y * kernel_[k];
-        result.z += (*input_) (l,j).z * kernel_[k];
-        r += kernel_[k] * static_cast<float> ((*input_) (l,j).r);
-        g += kernel_[k] * static_cast<float> ((*input_) (l,j).g);
-        b += kernel_[k] * static_cast<float> ((*input_) (l,j).b);
-      }
-      result.r = static_cast<std::uint8_t> (r);
-      result.g = static_cast<std::uint8_t> (g);
-      result.b = static_cast<std::uint8_t> (b);
-      return (result);
-    }
+template<> pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowDense (int i, int j);
 
-    template<> pcl::PointXYZRGB
-    Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColDense (int i, int j)
-    {
-      pcl::PointXYZRGB result;
-      float r = 0, g = 0, b = 0;
-      for (int k = kernel_width_, l = j - half_width_; k > -1; --k, ++l)
-      {
-        result.x += (*input_) (i,l).x * kernel_[k];
-        result.y += (*input_) (i,l).y * kernel_[k];
-        result.z += (*input_) (i,l).z * kernel_[k];
-        r += kernel_[k] * static_cast<float> ((*input_) (i,l).r);
-        g += kernel_[k] * static_cast<float> ((*input_) (i,l).g);
-        b += kernel_[k] * static_cast<float> ((*input_) (i,l).b);
-      }
-      result.r = static_cast<std::uint8_t> (r);
-      result.g = static_cast<std::uint8_t> (g);
-      result.b = static_cast<std::uint8_t> (b);
-      return (result);
-    }
+template<> pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColDense (int i, int j);
 
-    template<> pcl::PointXYZRGB
-    Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowNonDense (int i, int j)
-    {
-      pcl::PointXYZRGB result;
-      float weight = 0;
-      float r = 0, g = 0, b = 0;
-      for (int k = kernel_width_, l = i - half_width_; k > -1; --k, ++l)
-      {
-        if (!isFinite ((*input_) (l,j)))
-          continue;
-        if (pcl::squaredEuclideanDistance ((*input_) (i,j), (*input_) (l,j)) < distance_threshold_)
-        {
-          result.x += (*input_) (l,j).x * kernel_[k]; result.y += (*input_) (l,j).y * kernel_[k]; result.z += (*input_) (l,j).z * kernel_[k];
-          r+= kernel_[k] * static_cast<float> ((*input_) (l,j).r);
-          g+= kernel_[k] * static_cast<float> ((*input_) (l,j).g);
-          b+= kernel_[k] * static_cast<float> ((*input_) (l,j).b);
-          weight += kernel_[k];
-        }
-      }
-
-      if (weight == 0)
-        result.x = result.y = result.z = std::numeric_limits<float>::quiet_NaN ();
-      else
-      {
-        weight = 1.f/weight;
-        r*= weight; g*= weight; b*= weight;
-        result.x*= weight; result.y*= weight; result.z*= weight;
-        result.r = static_cast<std::uint8_t> (r);
-        result.g = static_cast<std::uint8_t> (g);
-        result.b = static_cast<std::uint8_t> (b);
-      }
-      return (result);
-    }
+template<> pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowNonDense (int i, int j);
 
-    template<> pcl::PointXYZRGB
-    Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColNonDense (int i, int j)
-    {
-      pcl::PointXYZRGB result;
-      float weight = 0;
-      float r = 0, g = 0, b = 0;
-      for (int k = kernel_width_, l = j - half_width_; k > -1; --k, ++l)
-      {
-        if (!isFinite ((*input_) (i,l)))
-          continue;
-        if (pcl::squaredEuclideanDistance ((*input_) (i,j), (*input_) (i,l)) < distance_threshold_)
-        {
-          result.x += (*input_) (i,l).x * kernel_[k]; result.y += (*input_) (i,l).y * kernel_[k]; result.z += (*input_) (i,l).z * kernel_[k];
-          r+= kernel_[k] * static_cast<float> ((*input_) (i,l).r);
-          g+= kernel_[k] * static_cast<float> ((*input_) (i,l).g);
-          b+= kernel_[k] * static_cast<float> ((*input_) (i,l).b);
-          weight+= kernel_[k];
-        }
-      }
-      if (weight == 0)
-        result.x = result.y = result.z = std::numeric_limits<float>::quiet_NaN ();
-      else
-      {
-        weight = 1.f/weight;
-        r*= weight; g*= weight; b*= weight;
-        result.x*= weight; result.y*= weight; result.z*= weight;
-        result.r = static_cast<std::uint8_t> (r);
-        result.g = static_cast<std::uint8_t> (g);
-        result.b = static_cast<std::uint8_t> (b);
-      }
-      return (result);
-    }
+template<> pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColNonDense (int i, int j);
 
-    ///////////////////////////////////////////////////////////////////////////////////////////////
-    template<> pcl::RGB
-    Convolution<pcl::RGB, pcl::RGB>::convolveOneRowDense (int i, int j)
-    {
-      pcl::RGB result;
-      float r = 0, g = 0, b = 0;
-      for (int k = kernel_width_, l = i - half_width_; k > -1; --k, ++l)
-      {
-        r += kernel_[k] * static_cast<float> ((*input_) (l,j).r);
-        g += kernel_[k] * static_cast<float> ((*input_) (l,j).g);
-        b += kernel_[k] * static_cast<float> ((*input_) (l,j).b);
-      }
-      result.r = static_cast<std::uint8_t> (r);
-      result.g = static_cast<std::uint8_t> (g);
-      result.b = static_cast<std::uint8_t> (b);
-      return (result);
-    }
+template<> pcl::RGB
+Convolution<pcl::RGB, pcl::RGB>::convolveOneRowDense (int i, int j);
 
-    template<> pcl::RGB
-    Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense (int i, int j)
-    {
-      pcl::RGB result;
-      float r = 0, g = 0, b = 0;
-      for (int k = kernel_width_, l = j - half_width_; k > -1; --k, ++l)
-      {
-        r += kernel_[k] * static_cast<float> ((*input_) (i,l).r);
-        g += kernel_[k] * static_cast<float> ((*input_) (i,l).g);
-        b += kernel_[k] * static_cast<float> ((*input_) (i,l).b);
-      }
-      result.r = static_cast<std::uint8_t> (r);
-      result.g = static_cast<std::uint8_t> (g);
-      result.b = static_cast<std::uint8_t> (b);
-      return (result);
-    }
+template<> pcl::RGB
+Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense (int i, int j);
 
-    template<> pcl::RGB
-    Convolution<pcl::RGB, pcl::RGB>::convolveOneRowNonDense (int i, int j)
-    {
-      return (convolveOneRowDense (i,j));
-    }
+template<> inline pcl::RGB
+Convolution<pcl::RGB, pcl::RGB>::convolveOneRowNonDense (int i, int j)
+{
+  return (convolveOneRowDense (i,j));
+}
 
-    template<> pcl::RGB
-    Convolution<pcl::RGB, pcl::RGB>::convolveOneColNonDense (int i, int j)
-    {
-      return (convolveOneColDense (i,j));
-    }
+template<> inline pcl::RGB
+Convolution<pcl::RGB, pcl::RGB>::convolveOneColNonDense (int i, int j)
+{
+  return (convolveOneColDense (i,j));
+}
 
-    template<> void
-    Convolution<pcl::RGB, pcl::RGB>::makeInfinite (pcl::RGB& p)
-    {
-      p.r = 0; p.g = 0; p.b = 0;
-    }    
-  }
+template<> inline void
+Convolution<pcl::RGB, pcl::RGB>::makeInfinite (pcl::RGB& p)
+{
+  p.r = 0; p.g = 0; p.b = 0;
 }
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::convolve_rows (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolve_rows (PointCloudOut& output)
 {
   using namespace pcl::common;
 
@@ -410,9 +287,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows (PointCloudOut& outp
   int last = input_->width - half_width_;
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, width) \
+  num_threads(threads_)
     for(int j = 0; j < height; ++j)
     {
       for (int i = 0; i < half_width_; ++i)
@@ -427,9 +305,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows (PointCloudOut& outp
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, width) \
+  num_threads(threads_)
     for(int j = 0; j < height; ++j)
     {
       for (int i = 0; i < half_width_; ++i)
@@ -445,7 +324,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows (PointCloudOut& outp
 }
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_duplicate (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolve_rows_duplicate (PointCloudOut& output)
 {
   using namespace pcl::common;
 
@@ -455,9 +334,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_duplicate (PointClou
   int w = last - 1;
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, w, width) \
+  num_threads(threads_)
     for(int j = 0; j < height; ++j)
     {
       for (int i = half_width_; i < last; ++i)
@@ -472,9 +352,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_duplicate (PointClou
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, w, width) \
+  num_threads(threads_)
     for(int j = 0; j < height; ++j)
     {
       for (int i = half_width_; i < last; ++i)
@@ -490,7 +371,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_duplicate (PointClou
 }
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_mirror (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolve_rows_mirror (PointCloudOut& output)
 {
   using namespace pcl::common;
 
@@ -500,9 +381,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_mirror (PointCloudOu
   int w = last - 1;
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, w, width) \
+  num_threads(threads_)
     for(int j = 0; j < height; ++j)
     {
       for (int i = half_width_; i < last; ++i)
@@ -517,9 +399,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_mirror (PointCloudOu
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, w, width) \
+  num_threads(threads_)
     for(int j = 0; j < height; ++j)
     {
       for (int i = half_width_; i < last; ++i)
@@ -535,7 +418,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_rows_mirror (PointCloudOu
 }
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::convolve_cols (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolve_cols (PointCloudOut& output)
 {
   using namespace pcl::common;
 
@@ -544,9 +427,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols (PointCloudOut& outp
   int last = input_->height - half_width_;
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, width) \
+  num_threads(threads_)
     for(int i = 0; i < width; ++i)
     {
       for (int j = 0; j < half_width_; ++j)
@@ -561,9 +445,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols (PointCloudOut& outp
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(height, last, output, width) \
+  num_threads(threads_)
     for(int i = 0; i < width; ++i)
     {
       for (int j = 0; j < half_width_; ++j)
@@ -579,7 +464,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols (PointCloudOut& outp
 }
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_duplicate (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolve_cols_duplicate (PointCloudOut& output)
 {
   using namespace pcl::common;
 
@@ -589,9 +474,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_duplicate (PointClou
   int h = last -1;
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(h, height, last, output, width) \
+  num_threads(threads_)
     for(int i = 0; i < width; ++i)
     {
       for (int j = half_width_; j < last; ++j)
@@ -606,9 +492,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_duplicate (PointClou
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(h, height, last, output, width) \
+  num_threads(threads_)
     for(int i = 0; i < width; ++i)
     {
       for (int j = half_width_; j < last; ++j)
@@ -624,7 +511,7 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_duplicate (PointClou
 }
 
 template <typename PointIn, typename PointOut> void
-pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_mirror (PointCloudOut& output)
+Convolution<PointIn, PointOut>::convolve_cols_mirror (PointCloudOut& output)
 {
   using namespace pcl::common;
 
@@ -634,9 +521,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_mirror (PointCloudOu
   int h = last -1;
   if (input_->is_dense)
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(h, height, last, output, width) \
+  num_threads(threads_)
     for(int i = 0; i < width; ++i)
     {
       for (int j = half_width_; j < last; ++j)
@@ -651,9 +539,10 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_mirror (PointCloudOu
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(h, height, last, output, width) \
+  num_threads(threads_)
     for(int i = 0; i < width; ++i)
     {
       for (int j = half_width_; j < last; ++j)
@@ -668,4 +557,6 @@ pcl::filters::Convolution<PointIn, PointOut>::convolve_cols_mirror (PointCloudOu
   }
 }
 
-#endif //PCL_FILTERS_CONVOLUTION_IMPL_HPP
+} // namespace filters
+} // namespace pcl
+
index 2421ddad904374f8eabb5096b0653222d894e932..eb7cafb3d521a2ee3176efa016e1c623a88dcdd1 100644 (file)
@@ -42,7 +42,6 @@
 
 #include <pcl/pcl_config.h>
 #include <pcl/point_types.h>
-#include <pcl/common/point_operators.h>
 
 #include <cmath>
 #include <cstdint>
@@ -242,9 +241,11 @@ pcl::filters::Convolution3D<PointInT, PointOutT, KernelT>::convolve (PointCloudO
   std::vector<int> nn_indices;
   std::vector<float> nn_distances;
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (nn_indices, nn_distances) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  private(nn_indices, nn_distances) \
+  num_threads(threads_)
   for (std::int64_t point_idx = 0; point_idx < static_cast<std::int64_t> (surface_->size ()); ++point_idx)
   {
     const PointInT& point_in = surface_->points [point_idx];
index 97f5aacba9f4ee96989792980c6c10c13b34a252..aff1d608bfa4567ea0398e755d3d88690658667d 100644 (file)
 #include <pcl/filters/crop_box.h>
 #include <pcl/common/io.h>
 
-///////////////////////////////////////////////////////////////////////////////
-template<typename PointT> void
-pcl::CropBox<PointT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilter (indices);
-    extract_removed_indices_ = temp;
-
-    output = *input_;
-    for (const auto ri : *removed_indices_)  // ri = removed index
-      output.points[ri].x = output.points[ri].y = output.points[ri].z = user_filter_value_;
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    output.is_dense = true;
-    applyFilter (indices);
-    pcl::copyPointCloud (*input_, indices, output);
-  }
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 template<typename PointT> void
 pcl::CropBox<PointT>::applyFilter (std::vector<int> &indices)
index bddfc65500217e514dbb17beb4226546213e5874..f53017785c1ebd76626f14e0295221bec50cdb91 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_FILTERS_IMPL_FAST_BILATERAL_HPP_
 #define PCL_FILTERS_IMPL_FAST_BILATERAL_HPP_
 
 #include <pcl/common/io.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointT> void
-pcl::FastBilateralFilter<PointT>::applyFilter (PointCloud &output)
+FastBilateralFilter<PointT>::applyFilter (PointCloud &output)
 {
   if (!input_->isOrganized ())
   {
@@ -164,12 +168,10 @@ pcl::FastBilateralFilter<PointT>::applyFilter (PointCloud &output)
 }
 
 
-
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> std::size_t
-pcl::FastBilateralFilter<PointT>::Array3D::clamp (const std::size_t min_value,
-                                                  const std::size_t max_value,
-                                                  const std::size_t x)
+FastBilateralFilter<PointT>::Array3D::clamp (const std::size_t min_value,
+                                             const std::size_t max_value,
+                                             const std::size_t x)
 {
   if (x >= min_value && x <= max_value)
   {
@@ -182,11 +184,11 @@ pcl::FastBilateralFilter<PointT>::Array3D::clamp (const std::size_t min_value,
   return (max_value);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> Eigen::Vector2f
-pcl::FastBilateralFilter<PointT>::Array3D::trilinear_interpolation (const float x,
-                                                                    const float y,
-                                                                    const float z)
+FastBilateralFilter<PointT>::Array3D::trilinear_interpolation (const float x,
+                                                               const float y,
+                                                               const float z)
 {
   const std::size_t x_index  = clamp (0, x_dim_ - 1, static_cast<std::size_t> (x));
   const std::size_t xx_index = clamp (0, x_dim_ - 1, x_index + 1);
@@ -212,4 +214,7 @@ pcl::FastBilateralFilter<PointT>::Array3D::trilinear_interpolation (const float
       x_alpha        * y_alpha        * z_alpha        * (*this)(xx_index, yy_index, zz_index);
 }
 
+} // namespace pcl
+
 #endif /* PCL_FILTERS_IMPL_FAST_BILATERAL_HPP_ */
+
index d56d4656b054c3c9b83d5ec5f82fa14df758f0cb..4bfe5fd74da1eb79caf868458054caf161cfd924 100644 (file)
@@ -91,9 +91,10 @@ pcl::FastBilateralFilterOMP<PointT>::applyFilter (PointCloud &output)
     PCL_WARN ("[pcl::FastBilateralFilterOMP] Given an empty cloud. Doing nothing.\n");
     return;
   }
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(base_min, base_max, output) \
+  num_threads(threads_)
   for (long int i = 0; i < static_cast<long int> (output.size ()); ++i)
     if (!std::isfinite (output.at(i).z))
       output.at(i).z = base_max;
@@ -108,8 +109,16 @@ pcl::FastBilateralFilterOMP<PointT>::applyFilter (PointCloud &output)
   const std::size_t small_depth  = static_cast<std::size_t> (base_delta / sigma_r_)   + 1 + 2 * padding_z;
 
   Array3D data (small_width, small_height, small_depth);
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  shared(base_min, data, output) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(base_min, data, output, small_height, small_width) \
+  num_threads(threads_)        
 #endif
   for (long int i = 0; i < static_cast<long int> (small_width * small_height); ++i)
   {
@@ -149,8 +158,16 @@ pcl::FastBilateralFilterOMP<PointT>::applyFilter (PointCloud &output)
     {
       Array3D* current_buffer = (n_iter % 2 == 1 ? &buffer : &data);
       Array3D* current_data =(n_iter % 2 == 1 ? &data : &buffer);
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  shared(current_buffer, current_data, dim, offset) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(current_buffer, current_data, dim, offset, small_depth, small_height, small_width) \
+  num_threads(threads_)
 #endif
       for(long int i = 0; i < static_cast<long int> ((small_width - 2)*(small_height - 2)); ++i)
       {
@@ -174,9 +191,10 @@ pcl::FastBilateralFilterOMP<PointT>::applyFilter (PointCloud &output)
     for (std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> >::iterator d = data.begin (); d != data.end (); ++d)
       *d /= ((*d)[0] != 0) ? (*d)[1] : 1;
 
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(base_min, data, output) \
+  num_threads(threads_)
     for (long int i = 0; i < static_cast<long int> (input_->size ()); ++i)
     {
       std::size_t x = static_cast<std::size_t> (i % input_->width);
@@ -190,9 +208,10 @@ pcl::FastBilateralFilterOMP<PointT>::applyFilter (PointCloud &output)
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(base_min, data, output) \
+  num_threads(threads_)
     for (long i = 0; i < static_cast<long int> (input_->size ()); ++i)
     {
       std::size_t x = static_cast<std::size_t> (i % input_->width);
index 03d17c1d555165e41ea8edd155f393044a4631ee..6c63735ef21448600bb2e2840698a682d2145db8 100644 (file)
  *
  */
 
-#ifndef PCL_FILTERS_IMPL_FILTER_H_
-#define PCL_FILTERS_IMPL_FILTER_H_
+#pragma once
 
 #include <pcl/pcl_macros.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/filters/filter.h>
 
 //////////////////////////////////////////////////////////////////////////
@@ -142,5 +142,3 @@ pcl::removeNaNNormalsFromPointCloud (const pcl::PointCloud<PointT> &cloud_in,
 #define PCL_INSTANTIATE_removeNaNFromPointCloud(T) template PCL_EXPORTS void pcl::removeNaNFromPointCloud<T>(const pcl::PointCloud<T>&, pcl::PointCloud<T>&, std::vector<int>&);
 #define PCL_INSTANTIATE_removeNaNNormalsFromPointCloud(T) template PCL_EXPORTS void pcl::removeNaNNormalsFromPointCloud<T>(const pcl::PointCloud<T>&, pcl::PointCloud<T>&, std::vector<int>&);
 
-#endif    // PCL_FILTERS_IMPL_FILTER_H_
-
index 60ada0589bc695434374e1da03b86d1d58244f8a..cee70c36c1330fd18c47c15a937411e1e33e3848 100644 (file)
@@ -74,7 +74,42 @@ pcl::removeNaNFromPointCloud (const pcl::PointCloud<PointT> &cloud_in,
   }
 }
 
+template<typename PointT> void
+pcl::FilterIndices<PointT>::applyFilter (PointCloud &output)
+{
+  std::vector<int> indices;
+  if (keep_organized_)
+  {
+    if (!extract_removed_indices_)
+    {
+      PCL_WARN ("[pcl::FilterIndices<PointT>::applyFilter] extract_removed_indices_ was set to 'true' to keep the point cloud organized.\n");
+      extract_removed_indices_ = true;
+    }
+    applyFilter (indices);
+
+    output = *input_;
+
+    // To preserve legacy behavior, only coordinates xyz are filtered.
+    // Copying a PointXYZ initialized with the user_filter_value_ into a generic
+    // PointT, ensures only the xyz coordinates, if they exist at destination,
+    // are overwritten.
+    const PointXYZ ufv (user_filter_value_, user_filter_value_, user_filter_value_);
+    for (const auto ri : *removed_indices_)  // ri = removed index
+      copyPoint(ufv, output[ri]);
+    if (!std::isfinite (user_filter_value_))
+      output.is_dense = false;
+  }
+  else
+  {
+    output.is_dense = true;
+    applyFilter (indices);
+    pcl::copyPointCloud (*input_, indices, output);
+  }
+}
+
+
 #define PCL_INSTANTIATE_removeNanFromPointCloud(T) template PCL_EXPORTS void pcl::removeNaNFromPointCloud<T>(const pcl::PointCloud<T>&, std::vector<int>&);
+#define PCL_INSTANTIATE_FilterIndices(T) template class PCL_EXPORTS  pcl::FilterIndices<T>;
 
 #endif    // PCL_FILTERS_IMPL_FILTER_INDICES_H_
 
index d4e4ce59ed65eca82848111a9469d0afcade1fa0..9d1597996e24fd1b94c0bb781406f80ce92609a6 100644 (file)
 #include <pcl/common/io.h>
 #include <vector>
 
-///////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void
-pcl::FrustumCulling<PointT>::applyFilter (PointCloud& output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilter (indices);
-    extract_removed_indices_ = temp;
-    copyPointCloud (*input_, output);
-
-    for (std::size_t rii = 0; rii < removed_indices_->size (); ++rii)
-    {
-      PointT &pt_to_remove = output.at ((*removed_indices_)[rii]);
-      pt_to_remove.x = pt_to_remove.y = pt_to_remove.z = user_filter_value_;
-      if (!std::isfinite (user_filter_value_))
-        output.is_dense = false;
-    }
-  }
-  else
-  {
-    output.is_dense = true;
-    applyFilter (indices);
-    copyPointCloud (*input_, indices, output);
-  }
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::FrustumCulling<PointT>::applyFilter (std::vector<int> &indices)
index 4ba3d9e1b511b2caab862603591bcb13a2686848..daec3e7610ec511f2c995965bde262e99beaf57b 100644 (file)
  *
  */
 
-#ifndef PCL_FILTERS_IMPL_LOCAL_MAXIMUM_H_
-#define PCL_FILTERS_IMPL_LOCAL_MAXIMUM_H_
+#pragma once
 
 #include <pcl/common/io.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/filters/local_maximum.h>
 #include <pcl/filters/project_inliers.h>
 #include <pcl/ModelCoefficients.h>
@@ -187,5 +187,3 @@ pcl::LocalMaximum<PointT>::applyFilterIndices (std::vector<int> &indices)
 
 #define PCL_INSTANTIATE_LocalMaximum(T) template class PCL_EXPORTS pcl::LocalMaximum<T>;
 
-#endif    // PCL_FILTERS_IMPL_LOCAL_MAXIMUM_H_
-
index ff510aff5a6503a9a58aa6fce0824927272be134..61359555f035fa74797d8c732e2afd7dd2be9d0f 100644 (file)
  *
  */
 
-#ifndef PCL_FILTERS_IMPL_MEDIAN_FILTER_HPP_
-#define PCL_FILTERS_IMPL_MEDIAN_FILTER_HPP_
+#pragma once
 
 #include <pcl/filters/median_filter.h>
 #include <pcl/common/io.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 
 template <typename PointT> void
 pcl::MedianFilter<PointT>::applyFilter (PointCloud &output)
@@ -88,5 +88,3 @@ pcl::MedianFilter<PointT>::applyFilter (PointCloud &output)
       }
 }
 
-
-#endif /* PCL_FILTERS_IMPL_MEDIAN_FILTER_HPP_ */
index a09c42bca94c3d3e1e993004dd6c3ff2aacaf06b..8ffd17242e5cae5fc93ffed99516108a7227f0ac 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PCL_FILTERS_IMPL_MODEL_OUTLIER_REMOVAL_HPP_
-#define PCL_FILTERS_IMPL_MODEL_OUTLIER_REMOVAL_HPP_
+#pragma once
 
 #include <pcl/filters/model_outlier_removal.h>
 #include <pcl/common/io.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/sample_consensus/sac_model_circle.h>
 #include <pcl/sample_consensus/sac_model_cylinder.h>
 #include <pcl/sample_consensus/sac_model_cone.h>
@@ -141,31 +141,6 @@ pcl::ModelOutlierRemoval<PointT>::initSACModel (pcl::SacModel model_type)
   return (true);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void
-pcl::ModelOutlierRemoval<PointT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilterIndices (indices);
-    extract_removed_indices_ = temp;
-
-    output = *input_;
-    for (int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)  // rii = removed indices iterator
-      output.points[ (*removed_indices_)[rii]].x = output.points[ (*removed_indices_)[rii]].y = output.points[ (*removed_indices_)[rii]].z = user_filter_value_;
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    applyFilterIndices (indices);
-    copyPointCloud (*input_, indices, output);
-  }
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::ModelOutlierRemoval<PointT>::applyFilterIndices (std::vector<int> &indices)
@@ -264,4 +239,3 @@ pcl::ModelOutlierRemoval<PointT>::applyFilterIndices (std::vector<int> &indices)
 
 #define PCL_INSTANTIATE_ModelOutlierRemoval(T) template class PCL_EXPORTS pcl::ModelOutlierRemoval<T>;
 
-#endif  // PCL_FILTERS_IMPL_MODEL_OUTLIER_REMOVAL_HPP_
index 2ed31e3e4cd46ae75b498e9aa6200bb92b124861..25c8407f45cab2823114d030b81f0d174af3067f 100644 (file)
 #include <pcl/filters/morphological_filter.h>
 #include <pcl/octree/octree_search.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+namespace pcl
+{
 template <typename PointT> void
-pcl::applyMorphologicalOperator (const typename pcl::PointCloud<PointT>::ConstPtr &cloud_in,
-                                 float resolution, const int morphological_operator,
-                                 pcl::PointCloud<PointT> &cloud_out)
+applyMorphologicalOperator (const typename pcl::PointCloud<PointT>::ConstPtr &cloud_in,
+                            float resolution, const int morphological_operator,
+                            pcl::PointCloud<PointT> &cloud_out)
 {
   if (cloud_in->empty ())
     return;
@@ -202,7 +203,8 @@ pcl::applyMorphologicalOperator (const typename pcl::PointCloud<PointT>::ConstPt
   return;
 }
 
+} // namespace pcl
+
 #define PCL_INSTANTIATE_applyMorphologicalOperator(T) template PCL_EXPORTS void pcl::applyMorphologicalOperator<T> (const pcl::PointCloud<T>::ConstPtr &, float, const int, pcl::PointCloud<T> &);
 
 #endif  //#ifndef PCL_FILTERS_IMPL_MORPHOLOGICAL_FILTER_H_
-
index f4b8f48530a943ca0a1f815007e5bb100be8a213..fab50f104c6ee13d9faa77de8ca44b6a43face4e 100644 (file)
@@ -59,40 +59,10 @@ pcl::NormalSpaceSampling<PointT, NormalT>::initCompute ()
     return false;
   }
 
-  boost::mt19937 rng (static_cast<unsigned int> (seed_));
-  boost::uniform_int<unsigned int> uniform_distrib (0, unsigned (input_->size ()));
-  delete rng_uniform_distribution_;
-  rng_uniform_distribution_ = new boost::variate_generator<boost::mt19937, boost::uniform_int<unsigned int> > (rng, uniform_distrib);
-
+  rng_.seed (seed_);
   return (true);
 }
 
-///////////////////////////////////////////////////////////////////////////////
-template<typename PointT, typename NormalT> void
-pcl::NormalSpaceSampling<PointT, NormalT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilter (indices);
-    extract_removed_indices_ = temp;
-
-    output = *input_;
-    for (int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)  // rii = removed indices iterator
-      output.points[(*removed_indices_)[rii]].x = output.points[(*removed_indices_)[rii]].y = output.points[(*removed_indices_)[rii]].z = user_filter_value_;
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    output.is_dense = true;
-    applyFilter (indices);
-    pcl::copyPointCloud (*input_, indices, output);
-  }
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 template<typename PointT, typename NormalT> bool 
 pcl::NormalSpaceSampling<PointT, NormalT>::isEntireBinSampled (boost::dynamic_bitset<> &array,
@@ -109,66 +79,12 @@ pcl::NormalSpaceSampling<PointT, NormalT>::isEntireBinSampled (boost::dynamic_bi
 
 ///////////////////////////////////////////////////////////////////////////////
 template<typename PointT, typename NormalT> unsigned int 
-pcl::NormalSpaceSampling<PointT, NormalT>::findBin (const float *normal, unsigned int)
+pcl::NormalSpaceSampling<PointT, NormalT>::findBin (const float *normal)
 {
-  unsigned int bin_number = 0;
-  // Holds the bin numbers for direction cosines in x,y,z directions
-  unsigned int t[3] = {0,0,0};
-  
-  // dcos is the direction cosine.
-  float dcos = 0.0;
-  float bin_size = 0.0;
-  // max_cos and min_cos are the maximum and minimum values of std::cos(theta) respectively
-  float max_cos = 1.0;
-  float min_cos = -1.0;
-
-//  dcos = std::cos (normal[0]);
-  dcos = normal[0];
-  bin_size = (max_cos - min_cos) / static_cast<float> (binsx_);
-
-  // Finding bin number for direction cosine in x direction
-  unsigned int k = 0;
-  for (float i = min_cos; (i + bin_size) < (max_cos - bin_size); i += bin_size , k++)
-  {
-    if (dcos >= i && dcos <= (i+bin_size))
-    {
-      break;
-    }
-  }
-  t[0] = k;
-
-//  dcos = std::cos (normal[1]);
-  dcos = normal[1];
-  bin_size = (max_cos - min_cos) / static_cast<float> (binsy_);
-
-  // Finding bin number for direction cosine in y direction
-  k = 0;
-  for (float i = min_cos; (i + bin_size) < (max_cos - bin_size); i += bin_size , k++)
-  {
-    if (dcos >= i && dcos <= (i+bin_size))
-    {
-      break;
-    }
-  }
-  t[1] = k;
-    
-//  dcos = std::cos (normal[2]);
-  dcos = normal[2];
-  bin_size = (max_cos - min_cos) / static_cast<float> (binsz_);
-
-  // Finding bin number for direction cosine in z direction
-  k = 0;
-  for (float i = min_cos; (i + bin_size) < (max_cos - bin_size); i += bin_size , k++)
-  {
-    if (dcos >= i && dcos <= (i+bin_size))
-    {
-      break;
-    }
-  }
-  t[2] = k;
-
-  bin_number = t[0] * (binsy_*binsz_) + t[1] * binsz_ + t[2];
-  return bin_number;
+  const unsigned ix = static_cast<unsigned> (std::round (0.5f * (binsx_ - 1.f) * (normal[0] + 1.f)));
+  const unsigned iy = static_cast<unsigned> (std::round (0.5f * (binsy_ - 1.f) * (normal[1] + 1.f)));
+  const unsigned iz = static_cast<unsigned> (std::round (0.5f * (binsz_ - 1.f) * (normal[2] + 1.f)));
+  return ix * (binsy_*binsz_) + iy * binsz_ + iz;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -195,10 +111,10 @@ pcl::NormalSpaceSampling<PointT, NormalT>::applyFilter (std::vector<int> &indice
   for (unsigned int i = 0; i < n_bins; i++)
     normals_hg.emplace_back();
 
-  for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
+  for (const auto index : *indices_)
   {
-    unsigned int bin_number = findBin (input_normals_->points[*it].normal, n_bins);
-    normals_hg[bin_number].push_back (*it);
+    unsigned int bin_number = findBin ((*input_normals_)[index].normal);
+    normals_hg[bin_number].push_back (index);
   }
 
 
@@ -239,11 +155,12 @@ pcl::NormalSpaceSampling<PointT, NormalT>::applyFilter (std::vector<int> &indice
 
       unsigned int pos = 0;
       unsigned int random_index = 0;
+      std::uniform_int_distribution<unsigned> rng_uniform_distribution (0u, M - 1u);
 
       // Picking up a sample at random from jth bin
       do
       {
-        random_index = static_cast<unsigned int> ((*rng_uniform_distribution_) () % M);
+        random_index = rng_uniform_distribution (rng_);
         pos = start_index[j] + random_index;
       } while (is_sampled_flag.test (pos));
 
index 269a9d731304e4f77956e1dca566e54c7db48127..c67bf743bdc0bfaec1010d425a2336d8c3ba0d5a 100644 (file)
 #include <pcl/filters/passthrough.h>
 #include <pcl/common/io.h>
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void
-pcl::PassThrough<PointT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilterIndices (indices);
-    extract_removed_indices_ = temp;
-
-    output = *input_;
-    for (const auto ri : *removed_indices_)  // ri = removed index
-      output.points[ri].x = output.points[ri].y = output.points[ri].z = user_filter_value_;
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    output.is_dense = true;
-    applyFilterIndices (indices);
-    copyPointCloud (*input_, indices, output);
-  }
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::PassThrough<PointT>::applyFilterIndices (std::vector<int> &indices)
index 0adb68143ffaaaff57d8d72b049001393ff8fe3b..1ccf9607a83412337cffefbddb88f0dfe366fe95 100644 (file)
@@ -182,41 +182,40 @@ pcl::PlaneClipper3D<PointT>::clipPointCloud3D (const pcl::PointCloud<PointT>& cl
   if (indices.empty ())
   {
     clipped.reserve (cloud_in.size ());
-    /*
-#if 0
-    Eigen::MatrixXf points = cloud_in.getMatrixXfMap (4, sizeof (PointT) / sizeof (float), offsetof(PointT,x) / sizeof (float));
-    Eigen::VectorXf distances = plane_params_.transpose () * points;
-    for (unsigned rIdx = 0; rIdx < cloud_in.size (); ++ rIdx)
-    {
-      if (distances (rIdx, 0) >= -plane_params_[3])
-        clipped.push_back (rIdx);
-    }
-#else
-    Eigen::Matrix4Xf points (4, cloud_in.size ());
-    for (unsigned rIdx = 0; rIdx < cloud_in.size (); ++ rIdx)
-    {
-      points (0, rIdx) = cloud_in[rIdx].x;
-      points (1, rIdx) = cloud_in[rIdx].y;
-      points (2, rIdx) = cloud_in[rIdx].z;
-      points (3, rIdx) = 1;
-    }
-    Eigen::VectorXf distances = plane_params_.transpose () * points;
-    for (unsigned rIdx = 0; rIdx < cloud_in.size (); ++ rIdx)
-    {
-      if (distances (rIdx, 0) >= 0)
-        clipped.push_back (rIdx);
-    }
-
-#endif
 
-    //std::cout << "points   : " << points.rows () << " x " << points.cols () << " * " << plane_params_.transpose ().rows () << " x " << plane_params_.transpose ().cols () << std::endl;
+// #if 0
+//     Eigen::MatrixXf points = cloud_in.getMatrixXfMap (4, sizeof (PointT) / sizeof (float), offsetof(PointT,x) / sizeof (float));
+//     Eigen::VectorXf distances = plane_params_.transpose () * points;
+//     for (unsigned rIdx = 0; rIdx < cloud_in.size (); ++ rIdx)
+//     {
+//       if (distances (rIdx, 0) >= -plane_params_[3])
+//         clipped.push_back (rIdx);
+//     }
+// #else
+//     Eigen::Matrix4Xf points (4, cloud_in.size ());
+//     for (unsigned rIdx = 0; rIdx < cloud_in.size (); ++ rIdx)
+//     {
+//       points (0, rIdx) = cloud_in[rIdx].x;
+//       points (1, rIdx) = cloud_in[rIdx].y;
+//       points (2, rIdx) = cloud_in[rIdx].z;
+//       points (3, rIdx) = 1;
+//     }
+//     Eigen::VectorXf distances = plane_params_.transpose () * points;
+//     for (unsigned rIdx = 0; rIdx < cloud_in.size (); ++ rIdx)
+//     {
+//       if (distances (rIdx, 0) >= 0)
+//         clipped.push_back (rIdx);
+//     }
+//
+// #endif
+//
+//     //std::cout << "points   : " << points.rows () << " x " << points.cols () << " * " << plane_params_.transpose ().rows () << " x " << plane_params_.transpose ().cols () << std::endl;
+//
+//     //std::cout << "distances: " << distances.rows () << " x " << distances.cols () << std::endl;
 
-    //std::cout << "distances: " << distances.rows () << " x " << distances.cols () << std::endl;
-    /*/
     for (unsigned pIdx = 0; pIdx < cloud_in.size (); ++pIdx)
       if (clipPoint3D (cloud_in[pIdx]))
         clipped.push_back (pIdx);
-    //*/
   }
   else
   {
index 41ddf1ef9571089b56c2dcb78ea64e80e5b05445..2ad5b449cfee7fb41b1b3712f61597700773ff9d 100644 (file)
  *
  */
 
+
 #ifndef PCL_FILTERS_IMPL_PYRAMID_HPP
 #define PCL_FILTERS_IMPL_PYRAMID_HPP
 
+
+namespace pcl
+{
+
+namespace filters
+{
+
 template <typename PointT> bool
-pcl::filters::Pyramid<PointT>::initCompute ()
+Pyramid<PointT>::initCompute ()
 {
   if (!input_->isOrganized ())
   {
     PCL_ERROR ("[pcl::fileters::%s::initCompute] Number of levels should be at least 2!", getClassName ().c_str ());
     return (false);
   }
-  
+
   if (levels_ < 2)
   {
     PCL_ERROR ("[pcl::fileters::%s::initCompute] Number of levels should be at least 2!", getClassName ().c_str ());
@@ -58,13 +66,13 @@ pcl::filters::Pyramid<PointT>::initCompute ()
   // std::size_t ratio (std::pow (2, levels_));
   // std::size_t last_width = input_->width / ratio;
   // std::size_t last_height = input_->height / ratio;
-  
+
   if (levels_ > 4)
   {
     PCL_ERROR ("[pcl::fileters::%s::initCompute] Number of levels should not exceed 4!", getClassName ().c_str ());
     return (false);
   }
-  
+
   if (large_)
   {
     Eigen::VectorXf k (5);
@@ -82,12 +90,12 @@ pcl::filters::Pyramid<PointT>::initCompute ()
     if (threshold_ != std::numeric_limits<float>::infinity ())
       threshold_ *= threshold_;
   }
-  
+
   return (true);
 }
 
 template <typename PointT> void
-pcl::filters::Pyramid<PointT>::compute (std::vector<PointCloudPtr>& output)
+Pyramid<PointT>::compute (std::vector<PointCloudPtr>& output)
 {
   std::cout << "compute" << std::endl;
   if (!initCompute ())
@@ -112,23 +120,24 @@ pcl::filters::Pyramid<PointT>::compute (std::vector<PointCloudPtr>& output)
       output[l].reset (new pcl::PointCloud<PointT> (output[l-1]->width/2, output[l-1]->height/2));
       const PointCloud<PointT> &previous = *output[l-1];
       PointCloud<PointT> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
       for(int i=0; i < next.height; ++i)
       {
         for(int j=0; j < next.width; ++j)
         {
           for(int m=0; m < kernel_rows; ++m)
           {
-            int mm = kernel_rows - 1 - m;      
-            for(int n=0; n < kernel_cols; ++n) 
+            int mm = kernel_rows - 1 - m;
+            for(int n=0; n < kernel_cols; ++n)
             {
               int nn = kernel_cols - 1 - n;
 
               int ii = 2*i + (m - kernel_center_y);
               int jj = 2*j + (n - kernel_center_x);
-              
+
               if (ii < 0) ii = 0;
               if (ii >= previous.height) ii = previous.height - 1;
               if (jj < 0) jj = 0;
@@ -147,9 +156,10 @@ pcl::filters::Pyramid<PointT>::compute (std::vector<PointCloudPtr>& output)
       output[l].reset (new pcl::PointCloud<PointT> (output[l-1]->width/2, output[l-1]->height/2));
       const PointCloud<PointT> &previous = *output[l-1];
       PointCloud<PointT> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
       for(int i=0; i < next.height; ++i)
       {
         for(int j=0; j < next.width; ++j)
@@ -186,383 +196,387 @@ pcl::filters::Pyramid<PointT>::compute (std::vector<PointCloudPtr>& output)
         }
       }
     }
-  }    
+  }
 }
 
-namespace pcl
+
+template <> void
+Pyramid<pcl::PointXYZRGB>::compute (std::vector<Pyramid<pcl::PointXYZRGB>::PointCloudPtr> &output)
 {
-  namespace filters
+  std::cout << "PointXYZRGB" << std::endl;
+  if (!initCompute ())
   {
-    template <> void 
-    Pyramid<pcl::PointXYZRGB>::compute (std::vector<Pyramid<pcl::PointXYZRGB>::PointCloudPtr> &output)
-    {
-      std::cout << "PointXYZRGB" << std::endl;
-      if (!initCompute ())
-      {
-        PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
-        return;
-      }
-      
-      int kernel_rows = static_cast<int> (kernel_.rows ());
-      int kernel_cols = static_cast<int> (kernel_.cols ());
-      int kernel_center_x = kernel_cols / 2;
-      int kernel_center_y = kernel_rows / 2;
+    PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
+    return;
+  }
 
-      output.resize (levels_ + 1);
-      output[0].reset (new pcl::PointCloud<pcl::PointXYZRGB>);
-      *(output[0]) = *input_;
+  int kernel_rows = static_cast<int> (kernel_.rows ());
+  int kernel_cols = static_cast<int> (kernel_.cols ());
+  int kernel_center_x = kernel_cols / 2;
+  int kernel_center_y = kernel_rows / 2;
+
+  output.resize (levels_ + 1);
+  output[0].reset (new pcl::PointCloud<pcl::PointXYZRGB>);
+  *(output[0]) = *input_;
 
-      if (input_->is_dense)
+  if (input_->is_dense)
+  {
+    for (int l = 1; l <= levels_; ++l)
+    {
+      output[l].reset (new pcl::PointCloud<pcl::PointXYZRGB> (output[l-1]->width/2, output[l-1]->height/2));
+      const PointCloud<pcl::PointXYZRGB> &previous = *output[l-1];
+      PointCloud<pcl::PointXYZRGB> &next = *output[l];
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
+      for(int i=0; i < next.height; ++i)              // rows
       {
-        for (int l = 1; l <= levels_; ++l)
+        for(int j=0; j < next.width; ++j)          // columns
         {
-          output[l].reset (new pcl::PointCloud<pcl::PointXYZRGB> (output[l-1]->width/2, output[l-1]->height/2));
-          const PointCloud<pcl::PointXYZRGB> &previous = *output[l-1];
-          PointCloud<pcl::PointXYZRGB> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
-          for(int i=0; i < next.height; ++i)              // rows
+          float r = 0, g = 0, b = 0;
+          for(int m=0; m < kernel_rows; ++m)     // kernel rows
           {
-            for(int j=0; j < next.width; ++j)          // columns
+            int mm = kernel_rows - 1 - m;      // row index of flipped kernel
+            for(int n=0; n < kernel_cols; ++n) // kernel columns
             {
-              float r = 0, g = 0, b = 0;
-              for(int m=0; m < kernel_rows; ++m)     // kernel rows
-              {
-                int mm = kernel_rows - 1 - m;      // row index of flipped kernel
-                for(int n=0; n < kernel_cols; ++n) // kernel columns
-                {
-                  int nn = kernel_cols - 1 - n;  // column index of flipped kernel
-                  // index of input signal, used for checking boundary
-                  int ii = 2*i + (m - kernel_center_y);
-                  int jj = 2*j + (n - kernel_center_x);
-                  
-                  // ignore input samples which are out of bound
-                  if (ii < 0) ii = 0;
-                  if (ii >= previous.height) ii = previous.height - 1;
-                  if (jj < 0) jj = 0;
-                  if (jj >= previous.width) jj = previous.width - 1;
-                  next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
-                  next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
-                  next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
-                  b += previous.at (jj,ii).b * kernel_ (mm,nn);
-                  g += previous.at (jj,ii).g * kernel_ (mm,nn);
-                  r += previous.at (jj,ii).r * kernel_ (mm,nn);
-                }
-              }
-              next.at (j,i).b = static_cast<std::uint8_t> (b);
-              next.at (j,i).g = static_cast<std::uint8_t> (g);
-              next.at (j,i).r = static_cast<std::uint8_t> (r);
+              int nn = kernel_cols - 1 - n;  // column index of flipped kernel
+              // index of input signal, used for checking boundary
+              int ii = 2*i + (m - kernel_center_y);
+              int jj = 2*j + (n - kernel_center_x);
+
+              // ignore input samples which are out of bound
+              if (ii < 0) ii = 0;
+              if (ii >= previous.height) ii = previous.height - 1;
+              if (jj < 0) jj = 0;
+              if (jj >= previous.width) jj = previous.width - 1;
+              next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
+              next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
+              next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
+              b += previous.at (jj,ii).b * kernel_ (mm,nn);
+              g += previous.at (jj,ii).g * kernel_ (mm,nn);
+              r += previous.at (jj,ii).r * kernel_ (mm,nn);
             }
           }
+          next.at (j,i).b = static_cast<std::uint8_t> (b);
+          next.at (j,i).g = static_cast<std::uint8_t> (g);
+          next.at (j,i).r = static_cast<std::uint8_t> (r);
         }
       }
-      else
+    }
+  }
+  else
+  {
+    for (int l = 1; l <= levels_; ++l)
+    {
+      output[l].reset (new pcl::PointCloud<pcl::PointXYZRGB> (output[l-1]->width/2, output[l-1]->height/2));
+      const PointCloud<pcl::PointXYZRGB> &previous = *output[l-1];
+      PointCloud<pcl::PointXYZRGB> &next = *output[l];
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
+      for(int i=0; i < next.height; ++i)
       {
-        for (int l = 1; l <= levels_; ++l)
+        for(int j=0; j < next.width; ++j)
         {
-          output[l].reset (new pcl::PointCloud<pcl::PointXYZRGB> (output[l-1]->width/2, output[l-1]->height/2));
-          const PointCloud<pcl::PointXYZRGB> &previous = *output[l-1];
-          PointCloud<pcl::PointXYZRGB> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
-          for(int i=0; i < next.height; ++i)
+          float weight = 0;
+          float r = 0, g = 0, b = 0;
+          for(int m=0; m < kernel_rows; ++m)
           {
-            for(int j=0; j < next.width; ++j)
+            int mm = kernel_rows - 1 - m;
+            for(int n=0; n < kernel_cols; ++n)
             {
-              float weight = 0;
-              float r = 0, g = 0, b = 0;
-              for(int m=0; m < kernel_rows; ++m)
-              {
-                int mm = kernel_rows - 1 - m;
-                for(int n=0; n < kernel_cols; ++n)
-                {
-                  int nn = kernel_cols - 1 - n;
-                  int ii = 2*i + (m - kernel_center_y);
-                  int jj = 2*j + (n - kernel_center_x);
-                  if (ii < 0) ii = 0;
-                  if (ii >= previous.height) ii = previous.height - 1;
-                  if (jj < 0) jj = 0;
-                  if (jj >= previous.width) jj = previous.width - 1;
-                  if (!isFinite (previous.at (jj,ii)))
-                    continue;
-                  if (pcl::squaredEuclideanDistance (previous.at (2*j,2*i), previous.at (jj,ii)) < threshold_)
-                  {
-                    next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
-                    next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
-                    next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
-                    b += previous.at (jj,ii).b * kernel_ (mm,nn);
-                    g += previous.at (jj,ii).g * kernel_ (mm,nn);
-                    r += previous.at (jj,ii).r * kernel_ (mm,nn);
-                    weight+= kernel_ (mm,nn);
-                  }
-                }
-              }
-              if (weight == 0)
-                nullify (next.at (j,i));
-              else
+              int nn = kernel_cols - 1 - n;
+              int ii = 2*i + (m - kernel_center_y);
+              int jj = 2*j + (n - kernel_center_x);
+              if (ii < 0) ii = 0;
+              if (ii >= previous.height) ii = previous.height - 1;
+              if (jj < 0) jj = 0;
+              if (jj >= previous.width) jj = previous.width - 1;
+              if (!isFinite (previous.at (jj,ii)))
+                continue;
+              if (pcl::squaredEuclideanDistance (previous.at (2*j,2*i), previous.at (jj,ii)) < threshold_)
               {
-                weight = 1.f/weight;
-                r*= weight; g*= weight; b*= weight;
-                next.at (j,i).x*= weight; next.at (j,i).y*= weight; next.at (j,i).z*= weight;
-                next.at (j,i).b = static_cast<std::uint8_t> (b);
-                next.at (j,i).g = static_cast<std::uint8_t> (g);
-                next.at (j,i).r = static_cast<std::uint8_t> (r);
+                next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
+                next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
+                next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
+                b += previous.at (jj,ii).b * kernel_ (mm,nn);
+                g += previous.at (jj,ii).g * kernel_ (mm,nn);
+                r += previous.at (jj,ii).r * kernel_ (mm,nn);
+                weight+= kernel_ (mm,nn);
               }
             }
           }
+          if (weight == 0)
+            nullify (next.at (j,i));
+          else
+          {
+            weight = 1.f/weight;
+            r*= weight; g*= weight; b*= weight;
+            next.at (j,i).x*= weight; next.at (j,i).y*= weight; next.at (j,i).z*= weight;
+            next.at (j,i).b = static_cast<std::uint8_t> (b);
+            next.at (j,i).g = static_cast<std::uint8_t> (g);
+            next.at (j,i).r = static_cast<std::uint8_t> (r);
+          }
         }
-      }    
-    }
-    
-    template <> void 
-    Pyramid<pcl::PointXYZRGBA>::compute (std::vector<Pyramid<pcl::PointXYZRGBA>::PointCloudPtr> &output)
-    {
-      std::cout << "PointXYZRGBA" << std::endl;
-      if (!initCompute ())
-      {
-        PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
-        return;
       }
-      
-      int kernel_rows = static_cast<int> (kernel_.rows ());
-      int kernel_cols = static_cast<int> (kernel_.cols ());
-      int kernel_center_x = kernel_cols / 2;
-      int kernel_center_y = kernel_rows / 2;
+    }
+  }
+}
+
+template <> void
+Pyramid<pcl::PointXYZRGBA>::compute (std::vector<Pyramid<pcl::PointXYZRGBA>::PointCloudPtr> &output)
+{
+  std::cout << "PointXYZRGBA" << std::endl;
+  if (!initCompute ())
+  {
+    PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
+    return;
+  }
+  
+  int kernel_rows = static_cast<int> (kernel_.rows ());
+  int kernel_cols = static_cast<int> (kernel_.cols ());
+  int kernel_center_x = kernel_cols / 2;
+  int kernel_center_y = kernel_rows / 2;
 
-      output.resize (levels_ + 1);
-      output[0].reset (new pcl::PointCloud<pcl::PointXYZRGBA>);
-      *(output[0]) = *input_;
+  output.resize (levels_ + 1);
+  output[0].reset (new pcl::PointCloud<pcl::PointXYZRGBA>);
+  *(output[0]) = *input_;
 
-      if (input_->is_dense)
+  if (input_->is_dense)
+  {
+    for (int l = 1; l <= levels_; ++l)
+    {
+      output[l].reset (new pcl::PointCloud<pcl::PointXYZRGBA> (output[l-1]->width/2, output[l-1]->height/2));
+      const PointCloud<pcl::PointXYZRGBA> &previous = *output[l-1];
+      PointCloud<pcl::PointXYZRGBA> &next = *output[l];
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
+      for(int i=0; i < next.height; ++i)              // rows
       {
-        for (int l = 1; l <= levels_; ++l)
+        for(int j=0; j < next.width; ++j)          // columns
         {
-          output[l].reset (new pcl::PointCloud<pcl::PointXYZRGBA> (output[l-1]->width/2, output[l-1]->height/2));
-          const PointCloud<pcl::PointXYZRGBA> &previous = *output[l-1];
-          PointCloud<pcl::PointXYZRGBA> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
-          for(int i=0; i < next.height; ++i)              // rows
+          float r = 0, g = 0, b = 0, a = 0;
+          for(int m=0; m < kernel_rows; ++m)     // kernel rows
           {
-            for(int j=0; j < next.width; ++j)          // columns
+            int mm = kernel_rows - 1 - m;      // row index of flipped kernel
+            for(int n=0; n < kernel_cols; ++n) // kernel columns
             {
-              float r = 0, g = 0, b = 0, a = 0;
-              for(int m=0; m < kernel_rows; ++m)     // kernel rows
-              {
-                int mm = kernel_rows - 1 - m;      // row index of flipped kernel
-                for(int n=0; n < kernel_cols; ++n) // kernel columns
-                {
-                  int nn = kernel_cols - 1 - n;  // column index of flipped kernel
-                  // index of input signal, used for checking boundary
-                  int ii = 2*i + (m - kernel_center_y);
-                  int jj = 2*j + (n - kernel_center_x);
-                  
-                  // ignore input samples which are out of bound
-                  if (ii < 0) ii = 0;
-                  if (ii >= previous.height) ii = previous.height - 1;
-                  if (jj < 0) jj = 0;
-                  if (jj >= previous.width) jj = previous.width - 1;
-                  next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
-                  next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
-                  next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
-                  b += previous.at (jj,ii).b * kernel_ (mm,nn);
-                  g += previous.at (jj,ii).g * kernel_ (mm,nn);
-                  r += previous.at (jj,ii).r * kernel_ (mm,nn);
-                  a += previous.at (jj,ii).a * kernel_ (mm,nn);
-                }
-              }
-              next.at (j,i).b = static_cast<std::uint8_t> (b);
-              next.at (j,i).g = static_cast<std::uint8_t> (g);
-              next.at (j,i).r = static_cast<std::uint8_t> (r);
-              next.at (j,i).a = static_cast<std::uint8_t> (a);
+              int nn = kernel_cols - 1 - n;  // column index of flipped kernel
+              // index of input signal, used for checking boundary
+              int ii = 2*i + (m - kernel_center_y);
+              int jj = 2*j + (n - kernel_center_x);
+
+              // ignore input samples which are out of bound
+              if (ii < 0) ii = 0;
+              if (ii >= previous.height) ii = previous.height - 1;
+              if (jj < 0) jj = 0;
+              if (jj >= previous.width) jj = previous.width - 1;
+              next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
+              next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
+              next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
+              b += previous.at (jj,ii).b * kernel_ (mm,nn);
+              g += previous.at (jj,ii).g * kernel_ (mm,nn);
+              r += previous.at (jj,ii).r * kernel_ (mm,nn);
+              a += previous.at (jj,ii).a * kernel_ (mm,nn);
             }
           }
+          next.at (j,i).b = static_cast<std::uint8_t> (b);
+          next.at (j,i).g = static_cast<std::uint8_t> (g);
+          next.at (j,i).r = static_cast<std::uint8_t> (r);
+          next.at (j,i).a = static_cast<std::uint8_t> (a);
         }
       }
-      else
+    }
+  }
+  else
+  {
+    for (int l = 1; l <= levels_; ++l)
+    {
+      output[l].reset (new pcl::PointCloud<pcl::PointXYZRGBA> (output[l-1]->width/2, output[l-1]->height/2));
+      const PointCloud<pcl::PointXYZRGBA> &previous = *output[l-1];
+      PointCloud<pcl::PointXYZRGBA> &next = *output[l];
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
+      for(int i=0; i < next.height; ++i)
       {
-        for (int l = 1; l <= levels_; ++l)
+        for(int j=0; j < next.width; ++j)
         {
-          output[l].reset (new pcl::PointCloud<pcl::PointXYZRGBA> (output[l-1]->width/2, output[l-1]->height/2));
-          const PointCloud<pcl::PointXYZRGBA> &previous = *output[l-1];
-          PointCloud<pcl::PointXYZRGBA> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
-          for(int i=0; i < next.height; ++i)
+          float weight = 0;
+          float r = 0, g = 0, b = 0, a = 0;
+          for(int m=0; m < kernel_rows; ++m)
           {
-            for(int j=0; j < next.width; ++j)
+            int mm = kernel_rows - 1 - m;
+            for(int n=0; n < kernel_cols; ++n)
             {
-              float weight = 0;
-              float r = 0, g = 0, b = 0, a = 0;
-              for(int m=0; m < kernel_rows; ++m)
-              {
-                int mm = kernel_rows - 1 - m;
-                for(int n=0; n < kernel_cols; ++n)
-                {
-                  int nn = kernel_cols - 1 - n;
-                  int ii = 2*i + (m - kernel_center_y);
-                  int jj = 2*j + (n - kernel_center_x);
-                  if (ii < 0) ii = 0;
-                  if (ii >= previous.height) ii = previous.height - 1;
-                  if (jj < 0) jj = 0;
-                  if (jj >= previous.width) jj = previous.width - 1;
-                  if (!isFinite (previous.at (jj,ii)))
-                    continue;
-                  if (pcl::squaredEuclideanDistance (previous.at (2*j,2*i), previous.at (jj,ii)) < threshold_)
-                  {
-                    next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
-                    next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
-                    next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
-                    b += previous.at (jj,ii).b * kernel_ (mm,nn);
-                    g += previous.at (jj,ii).g * kernel_ (mm,nn);
-                    r += previous.at (jj,ii).r * kernel_ (mm,nn);
-                    a += previous.at (jj,ii).a * kernel_ (mm,nn);
-                    weight+= kernel_ (mm,nn);
-                  }
-                }
-              }
-              if (weight == 0)
-                nullify (next.at (j,i));
-              else
+              int nn = kernel_cols - 1 - n;
+              int ii = 2*i + (m - kernel_center_y);
+              int jj = 2*j + (n - kernel_center_x);
+              if (ii < 0) ii = 0;
+              if (ii >= previous.height) ii = previous.height - 1;
+              if (jj < 0) jj = 0;
+              if (jj >= previous.width) jj = previous.width - 1;
+              if (!isFinite (previous.at (jj,ii)))
+                continue;
+              if (pcl::squaredEuclideanDistance (previous.at (2*j,2*i), previous.at (jj,ii)) < threshold_)
               {
-                weight = 1.f/weight;
-                r*= weight; g*= weight; b*= weight; a*= weight;
-                next.at (j,i).x*= weight; next.at (j,i).y*= weight; next.at (j,i).z*= weight;
-                next.at (j,i).b = static_cast<std::uint8_t> (b);
-                next.at (j,i).g = static_cast<std::uint8_t> (g);
-                next.at (j,i).r = static_cast<std::uint8_t> (r);
-                next.at (j,i).a = static_cast<std::uint8_t> (a);
+                next.at (j,i).x += previous.at (jj,ii).x * kernel_ (mm,nn);
+                next.at (j,i).y += previous.at (jj,ii).y * kernel_ (mm,nn);
+                next.at (j,i).z += previous.at (jj,ii).z * kernel_ (mm,nn);
+                b += previous.at (jj,ii).b * kernel_ (mm,nn);
+                g += previous.at (jj,ii).g * kernel_ (mm,nn);
+                r += previous.at (jj,ii).r * kernel_ (mm,nn);
+                a += previous.at (jj,ii).a * kernel_ (mm,nn);
+                weight+= kernel_ (mm,nn);
               }
             }
           }
+          if (weight == 0)
+            nullify (next.at (j,i));
+          else
+          {
+            weight = 1.f/weight;
+            r*= weight; g*= weight; b*= weight; a*= weight;
+            next.at (j,i).x*= weight; next.at (j,i).y*= weight; next.at (j,i).z*= weight;
+            next.at (j,i).b = static_cast<std::uint8_t> (b);
+            next.at (j,i).g = static_cast<std::uint8_t> (g);
+            next.at (j,i).r = static_cast<std::uint8_t> (r);
+            next.at (j,i).a = static_cast<std::uint8_t> (a);
+          }
         }
-      }    
+      }
     }
+  }
+}
 
-    template<> void
-    Pyramid<pcl::RGB>::nullify (pcl::RGB& p)
-    {
-      p.r = 0; p.g = 0; p.b = 0;
-    }    
+template<> void
+Pyramid<pcl::RGB>::nullify (pcl::RGB& p)
+{
+  p.r = 0; p.g = 0; p.b = 0;
+}
 
-    template <> void 
-    Pyramid<pcl::RGB>::compute (std::vector<Pyramid<pcl::RGB>::PointCloudPtr> &output)
-    {
-      std::cout << "RGB" << std::endl;
-      if (!initCompute ())
-      {
-        PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
-        return;
-      }
-      
-      int kernel_rows = static_cast<int> (kernel_.rows ());
-      int kernel_cols = static_cast<int> (kernel_.cols ());
-      int kernel_center_x = kernel_cols / 2;
-      int kernel_center_y = kernel_rows / 2;
+template <> void
+Pyramid<pcl::RGB>::compute (std::vector<Pyramid<pcl::RGB>::PointCloudPtr> &output)
+{
+  std::cout << "RGB" << std::endl;
+  if (!initCompute ())
+  {
+    PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
+    return;
+  }
 
-      output.resize (levels_ + 1);
-      output[0].reset (new pcl::PointCloud<pcl::RGB>);
-      *(output[0]) = *input_;
+  int kernel_rows = static_cast<int> (kernel_.rows ());
+  int kernel_cols = static_cast<int> (kernel_.cols ());
+  int kernel_center_x = kernel_cols / 2;
+  int kernel_center_y = kernel_rows / 2;
 
-      if (input_->is_dense)
+  output.resize (levels_ + 1);
+  output[0].reset (new pcl::PointCloud<pcl::RGB>);
+  *(output[0]) = *input_;
+
+  if (input_->is_dense)
+  {
+    for (int l = 1; l <= levels_; ++l)
+    {
+      output[l].reset (new pcl::PointCloud<pcl::RGB> (output[l-1]->width/2, output[l-1]->height/2));
+      const PointCloud<pcl::RGB> &previous = *output[l-1];
+      PointCloud<pcl::RGB> &next = *output[l];
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
+      for(int i=0; i < next.height; ++i)
       {
-        for (int l = 1; l <= levels_; ++l)
+        for(int j=0; j < next.width; ++j)
         {
-          output[l].reset (new pcl::PointCloud<pcl::RGB> (output[l-1]->width/2, output[l-1]->height/2));
-          const PointCloud<pcl::RGB> &previous = *output[l-1];
-          PointCloud<pcl::RGB> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
-          for(int i=0; i < next.height; ++i)
+          float r = 0, g = 0, b = 0;
+          for(int m=0; m < kernel_rows; ++m)
           {
-            for(int j=0; j < next.width; ++j)
+            int mm = kernel_rows - 1 - m;
+            for(int n=0; n < kernel_cols; ++n)
             {
-              float r = 0, g = 0, b = 0;
-              for(int m=0; m < kernel_rows; ++m)
-              {
-                int mm = kernel_rows - 1 - m;
-                for(int n=0; n < kernel_cols; ++n)
-                {
-                  int nn = kernel_cols - 1 - n;
-                  int ii = 2*i + (m - kernel_center_y);
-                  int jj = 2*j + (n - kernel_center_x);
-                  if (ii < 0) ii = 0;
-                  if (ii >= previous.height) ii = previous.height - 1;
-                  if (jj < 0) jj = 0;
-                  if (jj >= previous.width) jj = previous.width - 1;
-                  b += previous.at (jj,ii).b * kernel_ (mm,nn);
-                  g += previous.at (jj,ii).g * kernel_ (mm,nn);
-                  r += previous.at (jj,ii).r * kernel_ (mm,nn);
-                }
-              }
-              next.at (j,i).b = static_cast<std::uint8_t> (b);
-              next.at (j,i).g = static_cast<std::uint8_t> (g);
-              next.at (j,i).r = static_cast<std::uint8_t> (r);
+              int nn = kernel_cols - 1 - n;
+              int ii = 2*i + (m - kernel_center_y);
+              int jj = 2*j + (n - kernel_center_x);
+              if (ii < 0) ii = 0;
+              if (ii >= previous.height) ii = previous.height - 1;
+              if (jj < 0) jj = 0;
+              if (jj >= previous.width) jj = previous.width - 1;
+              b += previous.at (jj,ii).b * kernel_ (mm,nn);
+              g += previous.at (jj,ii).g * kernel_ (mm,nn);
+              r += previous.at (jj,ii).r * kernel_ (mm,nn);
             }
           }
+          next.at (j,i).b = static_cast<std::uint8_t> (b);
+          next.at (j,i).g = static_cast<std::uint8_t> (g);
+          next.at (j,i).r = static_cast<std::uint8_t> (r);
         }
       }
-      else
+    }
+  }
+  else
+  {
+    for (int l = 1; l <= levels_; ++l)
+    {
+      output[l].reset (new pcl::PointCloud<pcl::RGB> (output[l-1]->width/2, output[l-1]->height/2));
+      const PointCloud<pcl::RGB> &previous = *output[l-1];
+      PointCloud<pcl::RGB> &next = *output[l];
+#pragma omp parallel for \
+  default(none)          \
+  shared(next)           \
+  num_threads(threads_)
+      for(int i=0; i < next.height; ++i)
       {
-        for (int l = 1; l <= levels_; ++l)
+        for(int j=0; j < next.width; ++j)
         {
-          output[l].reset (new pcl::PointCloud<pcl::RGB> (output[l-1]->width/2, output[l-1]->height/2));
-          const PointCloud<pcl::RGB> &previous = *output[l-1];
-          PointCloud<pcl::RGB> &next = *output[l];
-#ifdef _OPENMP
-#pragma omp parallel for shared (next) num_threads(threads_)
-#endif
-          for(int i=0; i < next.height; ++i)
+          float weight = 0;
+          float r = 0, g = 0, b = 0;
+          for(int m=0; m < kernel_rows; ++m)
           {
-            for(int j=0; j < next.width; ++j)
+            int mm = kernel_rows - 1 - m;
+            for(int n=0; n < kernel_cols; ++n)
             {
-              float weight = 0;
-              float r = 0, g = 0, b = 0;
-              for(int m=0; m < kernel_rows; ++m)
-              {
-                int mm = kernel_rows - 1 - m;
-                for(int n=0; n < kernel_cols; ++n)
-                {
-                  int nn = kernel_cols - 1 - n;
-                  int ii = 2*i + (m - kernel_center_y);
-                  int jj = 2*j + (n - kernel_center_x);
-                  if (ii < 0) ii = 0;
-                  if (ii >= previous.height) ii = previous.height - 1;
-                  if (jj < 0) jj = 0;
-                  if (jj >= previous.width) jj = previous.width - 1;
-                  if (!isFinite (previous.at (jj,ii)))
-                    continue;
-                  if (pcl::squaredEuclideanDistance (previous.at (2*j,2*i), previous.at (jj,ii)) < threshold_)
-                  {
-                    b += previous.at (jj,ii).b * kernel_ (mm,nn);
-                    g += previous.at (jj,ii).g * kernel_ (mm,nn);
-                    r += previous.at (jj,ii).r * kernel_ (mm,nn);
-                    weight+= kernel_ (mm,nn);
-                  }
-                }
-              }
-              if (weight == 0)
-                nullify (next.at (j,i));
-              else
+              int nn = kernel_cols - 1 - n;
+              int ii = 2*i + (m - kernel_center_y);
+              int jj = 2*j + (n - kernel_center_x);
+              if (ii < 0) ii = 0;
+              if (ii >= previous.height) ii = previous.height - 1;
+              if (jj < 0) jj = 0;
+              if (jj >= previous.width) jj = previous.width - 1;
+              if (!isFinite (previous.at (jj,ii)))
+                continue;
+              if (pcl::squaredEuclideanDistance (previous.at (2*j,2*i), previous.at (jj,ii)) < threshold_)
               {
-                weight = 1.f/weight;
-                r*= weight; g*= weight; b*= weight;
-                next.at (j,i).b = static_cast<std::uint8_t> (b);
-                next.at (j,i).g = static_cast<std::uint8_t> (g);
-                next.at (j,i).r = static_cast<std::uint8_t> (r);
+                b += previous.at (jj,ii).b * kernel_ (mm,nn);
+                g += previous.at (jj,ii).g * kernel_ (mm,nn);
+                r += previous.at (jj,ii).r * kernel_ (mm,nn);
+                weight+= kernel_ (mm,nn);
               }
             }
           }
+          if (weight == 0)
+            nullify (next.at (j,i));
+          else
+          {
+            weight = 1.f/weight;
+            r*= weight; g*= weight; b*= weight;
+            next.at (j,i).b = static_cast<std::uint8_t> (b);
+            next.at (j,i).g = static_cast<std::uint8_t> (g);
+            next.at (j,i).r = static_cast<std::uint8_t> (r);
+          }
         }
-      }    
+      }
     }
-
   }
 }
 
+} // namespace filters
+} // namespace pcl
+
 #endif
+
index c3f96d79ca54cac9ce49efebc7a37861db67a99c..9f73cd027ba3e842b3eadb21f6006b869a53056f 100644 (file)
 #include <pcl/filters/radius_outlier_removal.h>
 #include <pcl/common/io.h>
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void
-pcl::RadiusOutlierRemoval<PointT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilterIndices (indices);
-    extract_removed_indices_ = temp;
-
-    output = *input_;
-    for (const auto ri : *removed_indices_)  // ri = removed index
-      output.points[ri].x = output.points[ri].y = output.points[ri].z = user_filter_value_;
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    applyFilterIndices (indices);
-    copyPointCloud (*input_, indices, output);
-  }
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::RadiusOutlierRemoval<PointT>::applyFilterIndices (std::vector<int> &indices)
index d7bebbb7c62f984fff90dc0f50a569370289202c..9db1143eedddeecf0acbd155e395dda1841bccbe 100644 (file)
 
 #include <pcl/filters/random_sample.h>
 #include <pcl/common/io.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 
 
-///////////////////////////////////////////////////////////////////////////////
-template<typename PointT> void
-pcl::RandomSample<PointT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilter (indices);
-    extract_removed_indices_ = temp;
-    copyPointCloud (*input_, output);
-    // Get X, Y, Z fields
-    const auto fields = pcl::getFields<PointT> ();
-    std::vector<std::size_t> offsets;
-    for (const auto &field : fields)
-    {
-      if (field.name == "x" ||
-          field.name == "y" ||
-          field.name == "z")
-        offsets.push_back (field.offset);
-    }
-    // For every "removed" point, set the x,y,z fields to user_filter_value_
-    const static float user_filter_value = user_filter_value_;
-    for (const auto ri : *removed_indices_)  // ri = removed index
-    {
-      std::uint8_t* pt_data = reinterpret_cast<std::uint8_t*> (&output[ri]);
-      for (const unsigned long &offset : offsets)
-      {
-        memcpy (pt_data + offset, &user_filter_value, sizeof (float));
-      }
-    }
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    output.is_dense = true;
-    applyFilter (indices);
-    copyPointCloud (*input_, indices, output);
-  }
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 template<typename PointT>
 void
index 38f2dd52115239748e076cc42c053508e16adbf9..14f0eb9a26c84ccdfc97d276d52fba7114168752 100644 (file)
@@ -41,6 +41,7 @@
 #include <iostream>
 #include <vector>
 #include <pcl/common/eigen.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/filters/sampling_surface_normal.h>
 
 ///////////////////////////////////////////////////////////////////////////////
index 73110ef8ae15f78eb268c9ff4380151c00095187..d09a9597b1511bcb5142896d84a27f1944033075 100644 (file)
 #include <pcl/filters/statistical_outlier_removal.h>
 #include <pcl/common/io.h>
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void
-pcl::StatisticalOutlierRemoval<PointT>::applyFilter (PointCloud &output)
-{
-  std::vector<int> indices;
-  if (keep_organized_)
-  {
-    bool temp = extract_removed_indices_;
-    extract_removed_indices_ = true;
-    applyFilterIndices (indices);
-    extract_removed_indices_ = temp;
-
-    output = *input_;
-    for (const auto ri : *removed_indices_)  // ri = removed index
-      output.points[ri].x = output.points[ri].y = output.points[ri].z = user_filter_value_;
-    if (!std::isfinite (user_filter_value_))
-      output.is_dense = false;
-  }
-  else
-  {
-    applyFilterIndices (indices);
-    copyPointCloud (*input_, indices, output);
-  }
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::StatisticalOutlierRemoval<PointT>::applyFilterIndices (std::vector<int> &indices)
index 6ba0bc6c9d89a4866229d89b2cbc129a50e99bdc..669b5c6fe64336cacdfe060fd9c151cc64a81e79 100644 (file)
@@ -42,6 +42,7 @@
 #include <pcl/common/common.h>
 #include <pcl/common/io.h>
 #include <pcl/filters/voxel_grid.h>
+#include  <boost/sort/spreadsort/integer_sort.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
@@ -205,6 +206,7 @@ struct cloud_point_index_idx
   unsigned int idx;
   unsigned int cloud_point_index;
 
+  cloud_point_index_idx() = default;
   cloud_point_index_idx (unsigned int idx_, unsigned int cloud_point_index_) : idx (idx_), cloud_point_index (cloud_point_index_) {}
   bool operator < (const cloud_point_index_idx &p) const { return (idx < p.idx); }
 };
@@ -339,8 +341,9 @@ pcl::VoxelGrid<PointT>::applyFilter (PointCloud &output)
 
   // Second pass: sort the index_vector vector using value representing target cell as index
   // in effect all points belonging to the same output cell will be next to each other
-  std::sort (index_vector.begin (), index_vector.end (), std::less<cloud_point_index_idx> ());
-
+  auto rightshift_func = [](const cloud_point_index_idx &x, const unsigned offset) { return x.idx >> offset; };
+  boost::sort::spreadsort::integer_sort(index_vector.begin(), index_vector.end(), rightshift_func);
+  
   // Third pass: count output cells
   // we need to skip all the same, adjacent idx values
   unsigned int total = 0;
index 31dcbd1d91aff37c70db15afff76a1f3e2c77400..edba6ab376a1c347bdf83a0df95c1f51fd22ecd5 100644 (file)
@@ -82,7 +82,7 @@ namespace pcl
        */
       inline
       ModelOutlierRemoval (bool extract_removed_indices = false) :
-          FilterIndices<PointT>::FilterIndices (extract_removed_indices)
+          FilterIndices<PointT> (extract_removed_indices)
       {
         thresh_ = 0;
         normals_distance_weight_ = 0;
@@ -199,12 +199,6 @@ namespace pcl
       using FilterIndices<PointT>::extract_removed_indices_;
       using FilterIndices<PointT>::removed_indices_;
 
-      /** \brief Filtered results are stored in a separate point cloud.
-       * \param[out] output The resultant point cloud.
-       */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Filtered results are indexed by an indices array.
        * \param[out] indices The resultant indices.
        */
index 5d88ef3ed4ba225bf501c7a23c908c05b76746c7..027e7cd102bdb259ef0f023151a1905f31adc691 100644 (file)
@@ -37,6 +37,8 @@
 
 #pragma once
 
+#include <pcl/pcl_macros.h>
+#include <pcl/common/utils.h>
 #include <pcl/filters/filter.h>
 
 namespace pcl
@@ -51,11 +53,13 @@ namespace pcl
    * \ingroup filters
    */
   template <typename NormalT> inline std::vector<float>
-  assignNormalWeights (const PointCloud<NormalT>&,
-                       int,
+  assignNormalWeights (const PointCloud<NormalT>& cloud,
+                       int index,
                        const std::vector<int>& k_indices,
                        const std::vector<float>& k_sqr_distances)
   {
+    pcl::utils::ignore(cloud);
+    pcl::utils::ignore(index);
     // Check inputs
     if (k_indices.size () != k_sqr_distances.size ())
       PCL_ERROR("[pcl::assignNormalWeights] inequal size of neighbor indices and distances!\n");
index 3a3f65ef51e63be75e672f4c829a84a71785efb4..522db676e77e0afac54fe06c2a6e05f456ad9d33 100644 (file)
 
 #include <pcl/filters/boost.h>
 #include <pcl/filters/filter_indices.h>
+
 #include <ctime>
 #include <climits>
+#include <random> // std::mt19937
 
 namespace pcl
 {
@@ -77,17 +79,10 @@ namespace pcl
         , binsy_ ()
         , binsz_ ()
         , input_normals_ ()
-        , rng_uniform_distribution_ (nullptr)
       {
         filter_name_ = "NormalSpaceSampling";
       }
 
-      /** \brief Destructor. */
-      ~NormalSpaceSampling ()
-      {
-        delete rng_uniform_distribution_;
-      }
-
       /** \brief Set number of indices to be sampled.
         * \param[in] sample the number of sample indices
         */
@@ -164,12 +159,6 @@ namespace pcl
       /** \brief The normals computed at each point in the input cloud */
       NormalsConstPtr input_normals_;
 
-      /** \brief Sample of point indices into a separate PointCloud
-        * \param[out] output the resultant point cloud
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Sample of point indices
         * \param[out] indices the resultant point cloud indices
         */
@@ -182,10 +171,9 @@ namespace pcl
     private:
       /** \brief Finds the bin number of the input normal, returns the bin number
         * \param[in] normal the input normal 
-        * \param[in] nbins total number of bins
         */
       unsigned int 
-      findBin (const float *normal, unsigned int nbins);
+      findBin (const float *normal);
 
       /** \brief Checks of the entire bin is sampled, returns true or false
         * \param[out] array flag which says whether a point is sampled or not
@@ -195,8 +183,8 @@ namespace pcl
       bool
       isEntireBinSampled (boost::dynamic_bitset<> &array, unsigned int start_index, unsigned int length);
 
-      /** \brief Uniform random distribution. */
-      boost::variate_generator<boost::mt19937, boost::uniform_int<std::uint32_t> > *rng_uniform_distribution_;
+      /** \brief Random engine */
+      std::mt19937 rng_;
   };
 }
 
index 3f5e2b6d78bd524905d69631bd0812ca8db288f6..d0f541d47f635b81d223ba53c511a10e3df2f5cb 100644 (file)
@@ -95,7 +95,7 @@ namespace pcl
         * \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
         */
       PassThrough (bool extract_removed_indices = false) :
-        FilterIndices<PointT>::FilterIndices (extract_removed_indices),
+        FilterIndices<PointT> (extract_removed_indices),
         filter_field_name_ (""),
         filter_limit_min_ (FLT_MIN),
         filter_limit_max_ (FLT_MAX)
@@ -150,6 +150,7 @@ namespace pcl
         * \warning This method will be removed in the future. Use setNegative() instead.
         * \param[in] limit_negative return data inside the interval (false) or outside (true)
         */
+      PCL_DEPRECATED(1, 13, "use inherited FilterIndices::setNegative() instead")
       inline void
       setFilterLimitsNegative (const bool limit_negative)
       {
@@ -160,6 +161,7 @@ namespace pcl
         * \warning This method will be removed in the future. Use getNegative() instead.
         * \param[out] limit_negative true if data \b outside the interval [min; max] is to be returned, false otherwise
         */
+      PCL_DEPRECATED(1, 13, "use inherited FilterIndices::getNegative() instead")
       inline void
       getFilterLimitsNegative (bool &limit_negative) const
       {
@@ -187,12 +189,6 @@ namespace pcl
       using FilterIndices<PointT>::extract_removed_indices_;
       using FilterIndices<PointT>::removed_indices_;
 
-      /** \brief Filtered results are stored in a separate point cloud.
-        * \param[out] output The resultant point cloud.
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Filtered results are indexed by an indices array.
         * \param[out] indices The resultant indices.
         */
@@ -287,7 +283,7 @@ namespace pcl
         * Default: false.
         * \param[in] limit_negative return data inside the interval (false) or outside (true)
         */
-      PCL_DEPRECATED("use inherited FilterIndices::setNegative() instead")
+      PCL_DEPRECATED(1, 12, "use inherited FilterIndices::setNegative() instead")
       inline void
       setFilterLimitsNegative (const bool limit_negative)
       {
@@ -297,7 +293,7 @@ namespace pcl
       /** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
         * \param[out] limit_negative true if data \b outside the interval [min; max] is to be returned, false otherwise
         */
-      PCL_DEPRECATED("use inherited FilterIndices::getNegative() instead")
+      PCL_DEPRECATED(1, 12, "use inherited FilterIndices::getNegative() instead")
       inline void
       getFilterLimitsNegative (bool &limit_negative) const
       {
@@ -307,7 +303,7 @@ namespace pcl
       /** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
         * \return true if data \b outside the interval [min; max] is to be returned, false otherwise
         */
-      PCL_DEPRECATED("use inherited FilterIndices::getNegative() instead")
+      PCL_DEPRECATED(1, 12, "use inherited FilterIndices::getNegative() instead")
       inline bool
       getFilterLimitsNegative () const
       {
index 3bb442b60caf3479c9b5bda6a580b0b26821f376..c37e0cb6be678019dd8fd8270585d47960f894dd 100644 (file)
@@ -39,8 +39,8 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
-#include <pcl/common/point_operators.h>
 #include <pcl/point_cloud.h>
 #include <pcl/pcl_config.h>
 
index d87d74bde7dcd868e368caf84953df25250907d8..99a690299b7c9d30b8394ea0ad9120d978791990 100644 (file)
@@ -86,7 +86,7 @@ namespace pcl
         * \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
         */
       RadiusOutlierRemoval (bool extract_removed_indices = false) :
-        FilterIndices<PointT>::FilterIndices (extract_removed_indices),
+        FilterIndices<PointT> (extract_removed_indices),
         searcher_ (),
         search_radius_ (0.0),
         min_pts_radius_ (1)
@@ -149,12 +149,6 @@ namespace pcl
       using FilterIndices<PointT>::extract_removed_indices_;
       using FilterIndices<PointT>::removed_indices_;
 
-      /** \brief Filtered results are stored in a separate point cloud.
-        * \param[out] output The resultant point cloud.
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Filtered results are indexed by an indices array.
         * \param[out] indices The resultant indices.
         */
index c023955df0bd5c53cfdc2ef1f87b526339f7044f..e29f4c8c5542398dd2c75b1b5ac0fcc5d484c6bb 100644 (file)
@@ -123,12 +123,6 @@ namespace pcl
       /** \brief Random number seed. */
       unsigned int seed_;
 
-      /** \brief Sample of point indices into a separate PointCloud
-        * \param output the resultant point cloud
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Sample of point indices
         * \param indices the resultant point cloud indices
         */
index 08451b645d7682c3b75bc89e787cc9e5237878ac..bcc8a465fcec885674a1ab46a78bd234ccb4c0ff 100644 (file)
@@ -95,7 +95,7 @@ namespace pcl
         * \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
         */
       StatisticalOutlierRemoval (bool extract_removed_indices = false) :
-        FilterIndices<PointT>::FilterIndices (extract_removed_indices),
+        FilterIndices<PointT> (extract_removed_indices),
         searcher_ (),
         mean_k_ (1),
         std_mul_ (0.0)
@@ -153,12 +153,6 @@ namespace pcl
       using FilterIndices<PointT>::extract_removed_indices_;
       using FilterIndices<PointT>::removed_indices_;
 
-      /** \brief Filtered results are stored in a separate point cloud.
-        * \param[out] output The resultant point cloud.
-        */
-      void
-      applyFilter (PointCloud &output) override;
-
       /** \brief Filtered results are indexed by an indices array.
         * \param[out] indices The resultant indices.
         */
diff --git a/filters/src/convolution.cpp b/filters/src/convolution.cpp
new file mode 100644 (file)
index 0000000..41ffd02
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2020-, Open Perception
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of the copyright holder(s) nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <pcl/filters/convolution.h>
+
+namespace pcl {
+namespace filters {
+template <>
+pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowDense(int i, int j)
+{
+  pcl::PointXYZRGB result;
+  float r = 0, g = 0, b = 0;
+  for (int k = kernel_width_, l = i - half_width_; k > -1; --k, ++l) {
+    result.x += (*input_)(l, j).x * kernel_[k];
+    result.y += (*input_)(l, j).y * kernel_[k];
+    result.z += (*input_)(l, j).z * kernel_[k];
+    r += kernel_[k] * static_cast<float>((*input_)(l, j).r);
+    g += kernel_[k] * static_cast<float>((*input_)(l, j).g);
+    b += kernel_[k] * static_cast<float>((*input_)(l, j).b);
+  }
+  result.r = static_cast<std::uint8_t>(r);
+  result.g = static_cast<std::uint8_t>(g);
+  result.b = static_cast<std::uint8_t>(b);
+  return (result);
+}
+
+template <>
+pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColDense(int i, int j)
+{
+  pcl::PointXYZRGB result;
+  float r = 0, g = 0, b = 0;
+  for (int k = kernel_width_, l = j - half_width_; k > -1; --k, ++l) {
+    result.x += (*input_)(i, l).x * kernel_[k];
+    result.y += (*input_)(i, l).y * kernel_[k];
+    result.z += (*input_)(i, l).z * kernel_[k];
+    r += kernel_[k] * static_cast<float>((*input_)(i, l).r);
+    g += kernel_[k] * static_cast<float>((*input_)(i, l).g);
+    b += kernel_[k] * static_cast<float>((*input_)(i, l).b);
+  }
+  result.r = static_cast<std::uint8_t>(r);
+  result.g = static_cast<std::uint8_t>(g);
+  result.b = static_cast<std::uint8_t>(b);
+  return (result);
+}
+
+template <>
+pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowNonDense(int i, int j)
+{
+  pcl::PointXYZRGB result;
+  float weight = 0;
+  float r = 0, g = 0, b = 0;
+  for (int k = kernel_width_, l = i - half_width_; k > -1; --k, ++l) {
+    if (!isFinite((*input_)(l, j)))
+      continue;
+    if (pcl::squaredEuclideanDistance((*input_)(i, j), (*input_)(l, j)) <
+        distance_threshold_) {
+      result.x += (*input_)(l, j).x * kernel_[k];
+      result.y += (*input_)(l, j).y * kernel_[k];
+      result.z += (*input_)(l, j).z * kernel_[k];
+      r += kernel_[k] * static_cast<float>((*input_)(l, j).r);
+      g += kernel_[k] * static_cast<float>((*input_)(l, j).g);
+      b += kernel_[k] * static_cast<float>((*input_)(l, j).b);
+      weight += kernel_[k];
+    }
+  }
+
+  if (weight == 0)
+    result.x = result.y = result.z = std::numeric_limits<float>::quiet_NaN();
+  else {
+    weight = 1.f / weight;
+    r *= weight;
+    g *= weight;
+    b *= weight;
+    result.x *= weight;
+    result.y *= weight;
+    result.z *= weight;
+    result.r = static_cast<std::uint8_t>(r);
+    result.g = static_cast<std::uint8_t>(g);
+    result.b = static_cast<std::uint8_t>(b);
+  }
+  return (result);
+}
+
+template <>
+pcl::PointXYZRGB
+Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColNonDense(int i, int j)
+{
+  pcl::PointXYZRGB result;
+  float weight = 0;
+  float r = 0, g = 0, b = 0;
+  for (int k = kernel_width_, l = j - half_width_; k > -1; --k, ++l) {
+    if (!isFinite((*input_)(i, l)))
+      continue;
+    if (pcl::squaredEuclideanDistance((*input_)(i, j), (*input_)(i, l)) <
+        distance_threshold_) {
+      result.x += (*input_)(i, l).x * kernel_[k];
+      result.y += (*input_)(i, l).y * kernel_[k];
+      result.z += (*input_)(i, l).z * kernel_[k];
+      r += kernel_[k] * static_cast<float>((*input_)(i, l).r);
+      g += kernel_[k] * static_cast<float>((*input_)(i, l).g);
+      b += kernel_[k] * static_cast<float>((*input_)(i, l).b);
+      weight += kernel_[k];
+    }
+  }
+  if (weight == 0)
+    result.x = result.y = result.z = std::numeric_limits<float>::quiet_NaN();
+  else {
+    weight = 1.f / weight;
+    r *= weight;
+    g *= weight;
+    b *= weight;
+    result.x *= weight;
+    result.y *= weight;
+    result.z *= weight;
+    result.r = static_cast<std::uint8_t>(r);
+    result.g = static_cast<std::uint8_t>(g);
+    result.b = static_cast<std::uint8_t>(b);
+  }
+  return (result);
+}
+
+template <>
+pcl::RGB
+Convolution<pcl::RGB, pcl::RGB>::convolveOneRowDense(int i, int j)
+{
+  pcl::RGB result;
+  float r = 0, g = 0, b = 0;
+  for (int k = kernel_width_, l = i - half_width_; k > -1; --k, ++l) {
+    r += kernel_[k] * static_cast<float>((*input_)(l, j).r);
+    g += kernel_[k] * static_cast<float>((*input_)(l, j).g);
+    b += kernel_[k] * static_cast<float>((*input_)(l, j).b);
+  }
+  result.r = static_cast<std::uint8_t>(r);
+  result.g = static_cast<std::uint8_t>(g);
+  result.b = static_cast<std::uint8_t>(b);
+  return (result);
+}
+
+template <>
+pcl::RGB
+Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense(int i, int j)
+{
+  pcl::RGB result;
+  float r = 0, g = 0, b = 0;
+  for (int k = kernel_width_, l = j - half_width_; k > -1; --k, ++l) {
+    r += kernel_[k] * static_cast<float>((*input_)(i, l).r);
+    g += kernel_[k] * static_cast<float>((*input_)(i, l).g);
+    b += kernel_[k] * static_cast<float>((*input_)(i, l).b);
+  }
+  result.r = static_cast<std::uint8_t>(r);
+  result.g = static_cast<std::uint8_t>(g);
+  result.b = static_cast<std::uint8_t>(b);
+  return (result);
+}
+} // namespace filters
+} // namespace pcl
index 7dc9d3339eb7b8e54961a2ec8c41d71730ea61fc..4735ef3bd0364eea3cb3b70f77e1cfaa0ad53c98 100644 (file)
@@ -62,6 +62,7 @@ pcl::FilterIndices<pcl::PCLPointCloud2>::filter (std::vector<int> &indices)
 
 // Instantiations of specific point types
 PCL_INSTANTIATE(removeNanFromPointCloud, PCL_XYZ_POINT_TYPES)
+PCL_INSTANTIATE(FilterIndices, PCL_POINT_TYPES)
 
 #endif    // PCL_NO_PRECOMPILE
 
index 485bb804d5f98405dacb105528bc58b872d78272..10d4bd28525afbe51be43425ea6b6de18678673e 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <pcl/filters/impl/radius_outlier_removal.hpp>
 #include <pcl/conversions.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 void
index 68e44dba0ed71b447b93814e264b310b581b2510..92e5f71dd25ed7d220a13efbdf9a9cf896d2fed2 100644 (file)
@@ -41,6 +41,7 @@
 #include <iostream>
 #include <pcl/common/io.h>
 #include <pcl/filters/impl/voxel_grid.hpp>
+#include <boost/sort/spreadsort/integer_sort.hpp>
 
 using Array4size_t = Eigen::Array<std::size_t, 4, 1>;
 
@@ -377,7 +378,8 @@ pcl::VoxelGrid<pcl::PCLPointCloud2>::applyFilter (PCLPointCloud2 &output)
 
   // Second pass: sort the index_vector vector using value representing target cell as index
   // in effect all points belonging to the same output cell will be next to each other
-  std::sort (index_vector.begin (), index_vector.end (), std::less<cloud_point_index_idx> ());
+  auto rightshift_func = [](const cloud_point_index_idx &x, const unsigned offset) { return x.idx >> offset; };
+  boost::sort::spreadsort::integer_sort(index_vector.begin(), index_vector.end(), rightshift_func);
 
   // Third pass: count output cells
   // we need to skip all the same, adjacenent idx values
@@ -549,4 +551,3 @@ PCL_INSTANTIATE(getMinMax3D, PCL_XYZ_POINT_TYPES)
 PCL_INSTANTIATE(VoxelGrid, PCL_XYZ_POINT_TYPES)
 
 #endif    // PCL_NO_PRECOMPILE
-
index 7e404ce8673f99af06e81f7ef1d0fb9e00b91596..051d18e0f237a4193ba493a408bd05e205586912 100644 (file)
@@ -5,7 +5,7 @@
 
 The PCL geometry library contains computational geometry data structures and algorithms.
 
-  \section secRecognitionRequirements Requirements
+  \section secGeometryRequirements Requirements
   - \ref common "common"
 
 */
index d5421caacc3d19480e5763009c239d38c4f7ee86..75b6a6b5946d29263883a42f2eeb7147921e670e 100644 (file)
@@ -45,5 +45,4 @@
 #endif
 
 #include <boost/operators.hpp>
-#include <boost/shared_ptr.hpp>
 #include <boost/version.hpp>
index 9a3f20ee2eafef880eaac85d339f8c4dcbb118f6..1f96b1210b2e3941e45c3171fc1ed70508c0f6c8 100644 (file)
@@ -46,6 +46,7 @@
 #include <pcl/geometry/mesh_indices.h>
 #include <pcl/geometry/mesh_elements.h>
 #include <pcl/geometry/mesh_traits.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 
index bd9f56fb890375879da268b87e12188cbe70bcfe..8a419c88fbc08298477c820e313653fb69e2c227 100644 (file)
@@ -40,6 +40,7 @@
 #pragma once
 
 #include <pcl/common/eigen.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/ModelCoefficients.h>
index 3c7432367179c423cab2bed40cef8b41b0df7a56..027e92647bfaf3e892dcb3e0f0f7681b91f255b9 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/geometry/mesh_base.h>
 
index f43540ca06f6c55a3e8683983af193cbb24eee51..5df668285000f7a79fb5028358829e870358e4f6 100644 (file)
@@ -33,8 +33,6 @@
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
  *
- * $Id: point_operators.h 4389 2012-02-10 10:10:26Z nizar $
- *
  */
 
 #pragma once
index 76dd113ebc6128ffcbc7e9d14b21587762c0a89a..22b442dbdd8363b17543cd2149bc4d1213e20238 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/geometry/mesh_base.h>
 
index ceb62570d62aca6d77cd035c2371e62604f452b5..d5f7f5bf1647d66b8617dcc31d9bd03e19ae8080 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <utility>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/geometry/mesh_base.h>
 
index 289fd71db24b03b04a7ac1a53de688a2b62bb0b2..99f36bf6405ce8367100fd70e17f963940065fa5 100644 (file)
@@ -20,4 +20,4 @@ topological_sort(PCL_GPU_MODULES_NAMES PCL_ _DEPENDS)
 sort_relative(PCL_GPU_MODULES_NAMES_UNSORTED PCL_GPU_MODULES_NAMES PCL_GPU_MODULES_DIRS)
 foreach(subdir ${PCL_GPU_MODULES_DIRS})
   add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${subdir}")
-endforeach()
\ No newline at end of file
+endforeach()
index 323c074317c788563d4f3fa65b317846063b1bed..cac6514838b417e199d5acfe42e0a5dd49a46bb0 100644 (file)
  *  Author: Anatoly Baskeheev, Itseez Ltd, (myname.mysurname@mycompany.com)
  */
 
+
 #ifndef PCL_GPU_CONTAINER_DEVICE_ARRAY_IMPL_HPP_
 #define PCL_GPU_CONTAINER_DEVICE_ARRAY_IMPL_HPP_
 
 
+namespace pcl
+{
+
+namespace gpu
+{
+
 /////////////////////  Inline implementations of DeviceArray ////////////////////////////////////////////
 
-template<class T> inline pcl::gpu::DeviceArray<T>::DeviceArray() {}
-template<class T> inline pcl::gpu::DeviceArray<T>::DeviceArray(std::size_t size) : DeviceMemory(size * elem_size) {}
-template<class T> inline pcl::gpu::DeviceArray<T>::DeviceArray(T *ptr, std::size_t size) : DeviceMemory(ptr, size * elem_size) {}
-template<class T> inline pcl::gpu::DeviceArray<T>::DeviceArray(const DeviceArray& other) : DeviceMemory(other) {}
-template<class T> inline pcl::gpu::DeviceArray<T>& pcl::gpu::DeviceArray<T>::operator=(const DeviceArray& other)
+template<class T> inline DeviceArray<T>::DeviceArray() {}
+template<class T> inline DeviceArray<T>::DeviceArray(std::size_t size) : DeviceMemory(size * elem_size) {}
+template<class T> inline DeviceArray<T>::DeviceArray(T *ptr, std::size_t size) : DeviceMemory(ptr, size * elem_size) {}
+template<class T> inline DeviceArray<T>::DeviceArray(const DeviceArray& other) : DeviceMemory(other) {}
+template<class T> inline DeviceArray<T>& DeviceArray<T>::operator=(const DeviceArray& other)
 { DeviceMemory::operator=(other); return *this; }
 
-template<class T> inline void pcl::gpu::DeviceArray<T>::create(std::size_t size) 
+template<class T> inline void DeviceArray<T>::create(std::size_t size)
 { DeviceMemory::create(size * elem_size); }
-template<class T> inline void pcl::gpu::DeviceArray<T>::release()  
+template<class T> inline void DeviceArray<T>::release()
 { DeviceMemory::release(); }
 
-template<class T> inline void pcl::gpu::DeviceArray<T>::copyTo(DeviceArray& other) const
+template<class T> inline void DeviceArray<T>::copyTo(DeviceArray& other) const
 { DeviceMemory::copyTo(other); }
-template<class T> inline void pcl::gpu::DeviceArray<T>::upload(const T *host_ptr, std::size_t size) 
+template<class T> inline void DeviceArray<T>::upload(const T *host_ptr, std::size_t size)
 { DeviceMemory::upload(host_ptr, size * elem_size); }
-template<class T> inline void pcl::gpu::DeviceArray<T>::download(T *host_ptr) const 
+template<class T> inline void DeviceArray<T>::download(T *host_ptr) const
 { DeviceMemory::download( host_ptr ); }
 
-template<class T> void pcl::gpu::DeviceArray<T>::swap(DeviceArray& other_arg) { DeviceMemory::swap(other_arg); }
+template<class T> void DeviceArray<T>::swap(DeviceArray& other_arg) { DeviceMemory::swap(other_arg); }
 
-template<class T> inline pcl::gpu::DeviceArray<T>::operator T*() { return ptr(); }
-template<class T> inline pcl::gpu::DeviceArray<T>::operator const T*() const { return ptr(); }
-template<class T> inline std::size_t pcl::gpu::DeviceArray<T>::size() const { return sizeBytes() / elem_size; }
+template<class T> inline DeviceArray<T>::operator T*() { return ptr(); }
+template<class T> inline DeviceArray<T>::operator const T*() const { return ptr(); }
+template<class T> inline std::size_t DeviceArray<T>::size() const { return sizeBytes() / elem_size; }
 
-template<class T> inline       T* pcl::gpu::DeviceArray<T>::ptr()       { return DeviceMemory::ptr<T>(); }
-template<class T> inline const T* pcl::gpu::DeviceArray<T>::ptr() const { return DeviceMemory::ptr<T>(); }
+template<class T> inline       T* DeviceArray<T>::ptr()       { return DeviceMemory::ptr<T>(); }
+template<class T> inline const T* DeviceArray<T>::ptr() const { return DeviceMemory::ptr<T>(); }
 
-template<class T> template<class A> inline void pcl::gpu::DeviceArray<T>::upload(const std::vector<T, A>& data) { upload(&data[0], data.size()); }
-template<class T> template<class A> inline void pcl::gpu::DeviceArray<T>::download(std::vector<T, A>& data) const { data.resize(size()); if (!data.empty()) download(&data[0]); }
+template<class T> template<class A> inline void DeviceArray<T>::upload(const std::vector<T, A>& data) { upload(&data[0], data.size()); }
+template<class T> template<class A> inline void DeviceArray<T>::download(std::vector<T, A>& data) const { data.resize(size()); if (!data.empty()) download(&data[0]); }
 
 /////////////////////  Inline implementations of DeviceArray2D ////////////////////////////////////////////
 
-template<class T> inline pcl::gpu::DeviceArray2D<T>::DeviceArray2D() {}
-template<class T> inline pcl::gpu::DeviceArray2D<T>::DeviceArray2D(int rows, int cols) : DeviceMemory2D(rows, cols * elem_size) {}
-template<class T> inline pcl::gpu::DeviceArray2D<T>::DeviceArray2D(int rows, int cols, void *data, std::size_t stepBytes) : DeviceMemory2D(rows, cols * elem_size, data, stepBytes) {}
-template<class T> inline pcl::gpu::DeviceArray2D<T>::DeviceArray2D(const DeviceArray2D& other) : DeviceMemory2D(other) {}
-template<class T> inline pcl::gpu::DeviceArray2D<T>& pcl::gpu::DeviceArray2D<T>::operator=(const DeviceArray2D& other)
+template<class T> inline DeviceArray2D<T>::DeviceArray2D() {}
+template<class T> inline DeviceArray2D<T>::DeviceArray2D(int rows, int cols) : DeviceMemory2D(rows, cols * elem_size) {}
+template<class T> inline DeviceArray2D<T>::DeviceArray2D(int rows, int cols, void *data, std::size_t stepBytes) : DeviceMemory2D(rows, cols * elem_size, data, stepBytes) {}
+template<class T> inline DeviceArray2D<T>::DeviceArray2D(const DeviceArray2D& other) : DeviceMemory2D(other) {}
+template<class T> inline DeviceArray2D<T>& DeviceArray2D<T>::operator=(const DeviceArray2D& other)
 { DeviceMemory2D::operator=(other); return *this; }
 
-template<class T> inline void pcl::gpu::DeviceArray2D<T>::create(int rows, int cols) 
+template<class T> inline void DeviceArray2D<T>::create(int rows, int cols)
 { DeviceMemory2D::create(rows, cols * elem_size); }
-template<class T> inline void pcl::gpu::DeviceArray2D<T>::release()  
+template<class T> inline void DeviceArray2D<T>::release()
 { DeviceMemory2D::release(); }
 
-template<class T> inline void pcl::gpu::DeviceArray2D<T>::copyTo(DeviceArray2D& other) const
+template<class T> inline void DeviceArray2D<T>::copyTo(DeviceArray2D& other) const
 { DeviceMemory2D::copyTo(other); }
-template<class T> inline void pcl::gpu::DeviceArray2D<T>::upload(const void *host_ptr, std::size_t host_step, int rows, int cols) 
+template<class T> inline void DeviceArray2D<T>::upload(const void *host_ptr, std::size_t host_step, int rows, int cols)
 { DeviceMemory2D::upload(host_ptr, host_step, rows, cols * elem_size); }
-template<class T> inline void pcl::gpu::DeviceArray2D<T>::download(void *host_ptr, std::size_t host_step) const 
+template<class T> inline void DeviceArray2D<T>::download(void *host_ptr, std::size_t host_step) const
 { DeviceMemory2D::download( host_ptr, host_step ); }
 
-template<class T> template<class A> inline void pcl::gpu::DeviceArray2D<T>::upload(const std::vector<T, A>& data, int cols) 
+template<class T> template<class A> inline void DeviceArray2D<T>::upload(const std::vector<T, A>& data, int cols)
 { upload(&data[0], cols * elem_size, data.size()/cols, cols); }
 
-template<class T> template<class A> inline void pcl::gpu::DeviceArray2D<T>::download(std::vector<T, A>& data, int& elem_step) const 
+template<class T> template<class A> inline void DeviceArray2D<T>::download(std::vector<T, A>& data, int& elem_step) const
 { elem_step = cols(); data.resize(cols() * rows()); if (!data.empty()) download(&data[0], colsBytes());  }
 
-template<class T> void  pcl::gpu::DeviceArray2D<T>::swap(DeviceArray2D& other_arg) { DeviceMemory2D::swap(other_arg); }
+template<class T> void  DeviceArray2D<T>::swap(DeviceArray2D& other_arg) { DeviceMemory2D::swap(other_arg); }
+
+template<class T> inline       T* DeviceArray2D<T>::ptr(int y)       { return DeviceMemory2D::ptr<T>(y); }
+template<class T> inline const T* DeviceArray2D<T>::ptr(int y) const { return DeviceMemory2D::ptr<T>(y); }
+
+template<class T> inline DeviceArray2D<T>::operator T*() { return ptr(); }
+template<class T> inline DeviceArray2D<T>::operator const T*() const { return ptr(); }
 
-template<class T> inline       T* pcl::gpu::DeviceArray2D<T>::ptr(int y)       { return DeviceMemory2D::ptr<T>(y); }
-template<class T> inline const T* pcl::gpu::DeviceArray2D<T>::ptr(int y) const { return DeviceMemory2D::ptr<T>(y); }
-            
-template<class T> inline pcl::gpu::DeviceArray2D<T>::operator T*() { return ptr(); }
-template<class T> inline pcl::gpu::DeviceArray2D<T>::operator const T*() const { return ptr(); }
+template<class T> inline int DeviceArray2D<T>::cols() const { return DeviceMemory2D::colsBytes()/elem_size; }
+template<class T> inline int DeviceArray2D<T>::rows() const { return DeviceMemory2D::rows(); }
 
-template<class T> inline int pcl::gpu::DeviceArray2D<T>::cols() const { return DeviceMemory2D::colsBytes()/elem_size; }
-template<class T> inline int pcl::gpu::DeviceArray2D<T>::rows() const { return DeviceMemory2D::rows(); }
+template<class T> inline std::size_t DeviceArray2D<T>::elem_step() const { return DeviceMemory2D::step()/elem_size; }
 
-template<class T> inline std::size_t pcl::gpu::DeviceArray2D<T>::elem_step() const { return DeviceMemory2D::step()/elem_size; }
+} // namespace gpu
+} // namespace pcl
 
+#endif /* PCL_GPU_CONTAINER_DEVICE_ARRAY_IMPL_HPP_ */
 
-#endif /* PCL_GPU_CONTAINER_DEVICE_ARRAY_IMPL_HPP_ */ 
index c368a6f0dd961c45afebbbdcf7acdcb0e800ca60..265a8e821ea3e17feced2ce97c443bd57bae2665 100644 (file)
 #ifndef PCL_GPU_CONTAINER_DEVICE_MEMORY_IMPL_HPP_
 #define PCL_GPU_CONTAINER_DEVICE_MEMORY_IMPL_HPP_
 
+namespace pcl
+{
+
+namespace gpu
+{
+
 /////////////////////  Inline implementations of DeviceMemory ////////////////////////////////////////////
+template<class T> inline T*
+DeviceMemory::ptr()
+{
+  return (T*)data_;
+}
+
+template<class T> inline const T*
+DeviceMemory::ptr() const
+{
+  return (const T*)data_;
+}
 
-template<class T> inline       T* pcl::gpu::DeviceMemory::ptr()       { return (      T*)data_; }
-template<class T> inline const T* pcl::gpu::DeviceMemory::ptr() const { return (const T*)data_; }
-                        
-template <class U> inline pcl::gpu::DeviceMemory::operator pcl::gpu::PtrSz<U>() const
+template <class U> inline DeviceMemory::operator
+PtrSz<U>() const
 {
     PtrSz<U> result;
     result.data = (U*)ptr<U>();
     result.size = sizeBytes_/sizeof(U);
-    return result; 
+    return result;
 }
 
 /////////////////////  Inline implementations of DeviceMemory2D ////////////////////////////////////////////
-               
-template<class T>        T* pcl::gpu::DeviceMemory2D::ptr(int y_arg)       { return (      T*)((      char*)data_ + y_arg * step_); }
-template<class T>  const T* pcl::gpu::DeviceMemory2D::ptr(int y_arg) const { return (const T*)((const char*)data_ + y_arg * step_); }
-  
-template <class U> pcl::gpu::DeviceMemory2D::operator pcl::gpu::PtrStep<U>() const
+template<class T> T*
+DeviceMemory2D::ptr(int y_arg)
+{
+  return (T*)((char*)data_ + y_arg * step_);
+}
+
+template<class T> const T*
+DeviceMemory2D::ptr(int y_arg) const
+{
+  return (const T*)((const char*)data_ + y_arg * step_);
+}
+
+template <class U> DeviceMemory2D::operator
+PtrStep<U>() const
 {
     PtrStep<U> result;
     result.data = (U*)ptr<U>();
@@ -63,7 +87,8 @@ template <class U> pcl::gpu::DeviceMemory2D::operator pcl::gpu::PtrStep<U>() con
     return result;
 }
 
-template <class U> pcl::gpu::DeviceMemory2D::operator pcl::gpu::PtrStepSz<U>() const
+template <class U> DeviceMemory2D::operator
+PtrStepSz<U>() const
 {
     PtrStepSz<U> result;
     result.data = (U*)ptr<U>();
@@ -73,5 +98,7 @@ template <class U> pcl::gpu::DeviceMemory2D::operator pcl::gpu::PtrStepSz<U>() c
     return result;
 }
 
-#endif /* PCL_GPU_CONTAINER_DEVICE_MEMORY_IMPL_HPP_ */ 
+} // namespace gpu
+} // namespace pcl
 
+#endif /* PCL_GPU_CONTAINER_DEVICE_MEMORY_IMPL_HPP_ */
index c8911ccdeabf908e4560d45a833c383ae23d35ea..fba1f0f5e5ce27037340acbd9c3938c8f980626d 100644 (file)
@@ -3,10 +3,11 @@
 
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
+#include <pcl/memory.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
-#include <boost/shared_ptr.hpp>
 #include <pcl/visualization/cloud_viewer.h>
+
 #include <iostream>
 
 int main (int argc, char** argv)
index 9ddf1bebda4810577a641349940de2e3826b2109..2576f80ef5cd3c527f3047ea63b0f9b10466799d 100644 (file)
@@ -99,7 +99,7 @@ namespace pcl
             NormalEstimation();
             void compute(Normals& normals);
             void setViewPoint(float  vpx, float  vpy, float  vpz);  
-            void getViewPoint(float& vpx, float& vpy, float& vpz);      
+            void getViewPoint(float& vpx, float& vpy, float& vpz) const;
 
             static void computeNormals(const PointCloud& cloud, const NeighborIndices& nn_indices, Normals& normals);
             static void flipNormalTowardsViewpoint(const PointCloud& cloud, float vp_x, float vp_y, float vp_z, Normals& normals);            
@@ -223,7 +223,7 @@ namespace pcl
             VFHEstimation();
 
             void setViewPoint(float  vpx, float  vpy, float  vpz);  
-            void getViewPoint(float& vpx, float& vpy, float& vpz);      
+            void getViewPoint(float& vpx, float& vpy, float& vpz) const;      
 
             void setUseGivenNormal (bool use);
             void setNormalToUse (const NormalType& normal);
index 5d370295ec2d4fb486ccef8623f2138fccc26715..b3270c54e0a6da97e7e2796b300b46b9cdb9c137 100644 (file)
@@ -94,7 +94,7 @@ void pcl::gpu::NormalEstimation::setViewPoint (float vpx, float vpy, float vpz)
     vpx_ = vpx; vpy_ = vpy; vpz_ = vpz;
 }
 
-void pcl::gpu::NormalEstimation::getViewPoint (float &vpx, float &vpy, float &vpz)
+void pcl::gpu::NormalEstimation::getViewPoint (float &vpx, float &vpy, float &vpz) const
 {
     vpx = vpx_; vpy = vpy_; vpz = vpz_;
 }
@@ -383,7 +383,7 @@ pcl::gpu::VFHEstimation::VFHEstimation()
 }
 
 void pcl::gpu::VFHEstimation::setViewPoint(float  vpx, float  vpy, float  vpz) { vpx_ = vpx; vpy_ = vpy; vpz_ = vpz; }
-void pcl::gpu::VFHEstimation::getViewPoint(float& vpx, float& vpy, float& vpz) { vpx = vpx_; vpy = vpy_; vpz = vpz_; }      
+void pcl::gpu::VFHEstimation::getViewPoint(float& vpx, float& vpy, float& vpz) const { vpx = vpx_; vpy = vpy_; vpz = vpz_; }      
 
 void pcl::gpu::VFHEstimation::setUseGivenNormal (bool use) { use_given_normal_ = use; }
 void pcl::gpu::VFHEstimation::setNormalToUse (const NormalType& normal)   { normal_to_use_ = normal; }
index b8eb2fb802ca3fb0358273ff0e01ad64cb280aee..8c843fa69ca8de64e3f0d4c466b0958bfa5b6612 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/point_types.h>
index cbe6e927e3a4d8aa61ff68e3cb7a8f2ac0320ce8..7e24a9acf1499685774185c092bfc76ffdd0f52b 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/gpu/kinfu/pixel_rgb.h>
@@ -97,7 +98,7 @@ namespace pcl
           * \param[out] cy principal point y
           */
         void
-        getDepthIntrinsics (float& fx, float& fy, float& cx, float& cy);
+        getDepthIntrinsics (float& fx, float& fy, float& cx, float& cy) const;
         
 
         /** \brief Sets initial camera pose relative to volume coordinate space
index 6c36245ec8a9554d28e5831c1a892b14d2de6334..f1ee497ddb57c189347e5679aa88e0a4524cf22c 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <Eigen/Core>
index 2bd37d0ec5ee77a05289c316bd1f6ded36e2c3ad..07a701da2e49d72d7187420f8479e69474ce1ef2 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/gpu/kinfu/pixel_rgb.h>
-#include <pcl/make_shared.h>
 #include <Eigen/Geometry>
 
 namespace pcl
index 2efa4d31f5995419ff4d35057588dcc65303b38d..366e71e3de001dda63695ac5a3e2f235e247c375 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/point_types.h>
index e009f71433774598f954b60084215e21cf7a9845..04cf5f4d254009ceadbb0e7e2cb3d23868ce81cd 100644 (file)
@@ -114,7 +114,7 @@ pcl::gpu::KinfuTracker::setDepthIntrinsics (float fx, float fy, float cx, float
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::gpu::KinfuTracker::getDepthIntrinsics (float& fx, float& fy, float& cx, float& cy)
+pcl::gpu::KinfuTracker::getDepthIntrinsics (float& fx, float& fy, float& cx, float& cy) const
 {
   fx = fx_;
   fy = fy_;
index 51ea931205aabdae10c17afe8937b283c9c5fc6d..c708a768e9706f5bd5264cbd5ffd2b84e6177816 100644 (file)
@@ -304,7 +304,9 @@ pcl::gpu::TsdfVolume::downloadTsdf (std::vector<float>& tsdf) const
   tsdf.resize (volume_.cols() * volume_.rows());
   volume_.download(&tsdf[0], volume_.cols() * sizeof(int));
 
-#pragma omp parallel for
+#pragma omp parallel for \
+  default(none) \
+  shared(tsdf)
   for(int i = 0; i < (int) tsdf.size(); ++i)
   {
     float tmp = reinterpret_cast<short2*>(&tsdf[i])->x;
@@ -322,7 +324,9 @@ pcl::gpu::TsdfVolume::downloadTsdfAndWeighs (std::vector<float>& tsdf, std::vect
   weights.resize (volumeSize);
   volume_.download(&tsdf[0], volume_.cols() * sizeof(int));
 
-#pragma omp parallel for
+#pragma omp parallel for \
+  default(none) \
+  shared(weights, tsdf)
   for(int i = 0; i < (int) tsdf.size(); ++i)
   {
     short2 elem = *reinterpret_cast<short2*>(&tsdf[i]);
index e54ba72380dc763158ccd5e3d59bd6ea25411d3e..2bf9a18f6c4887ce08e658d07a737b1c0dfdb8d2 100644 (file)
@@ -43,7 +43,7 @@
 #include <Eigen/Geometry>
 #include <fstream>
 
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 /**
  * @brief The CameraPoseProcessor class is an interface to extract
index 0ea5ad9ecb29a638697a53b6a75fc4289e8b878e..552a1f588f404678c84825b7114287ffda068c95 100644 (file)
@@ -39,7 +39,7 @@
 #include <pcl/gpu/containers/kernel_containers.h>
 #include <pcl/gpu/kinfu/kinfu.h>
 
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include <memory>
 #include <string>
index f8c4ed1ead93a980076c7d87b21a8b2aa04afd9b..e1572b80810fa14f9df9f30b63ced8c6fae64194 100644 (file)
@@ -68,7 +68,7 @@
 #include "evaluation.h"
 
 #include <pcl/common/angles.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include "tsdf_volume.h"
 #include "tsdf_volume.hpp"
@@ -404,7 +404,7 @@ struct ImageView
   }
 
   void
-  showDepth (const PtrStepSz<const unsigned short>& depth) 
+  showDepth (const PtrStepSz<const unsigned short>& depth) const 
   { 
      if (viz_)
        viewerDepth_->showShortImage (depth.data, depth.cols, depth.rows, 0, 5000, true, "short_image"); 
@@ -582,7 +582,7 @@ struct SceneCloudView
   }
 
   void
-  clearClouds (bool print_message = false)
+  clearClouds (bool print_message = false) const
   {
     if (!viz_)
         return;
index fa5c7dc0169562e3f651f8fbf35c3ae637987380..ca7d427163c987dc9fb4e12ce10583f666e5e4e7 100644 (file)
@@ -84,7 +84,7 @@
 #include "evaluation.h"
 
 #include <pcl/common/angles.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include "tsdf_volume.h"
 #include "tsdf_volume.hpp"
@@ -101,7 +101,7 @@ using ScopeTimeT = pcl::ScopeTime;
 #include <Eigen/Dense>
 #include <cmath>
 #include <iostream>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef _WIN32
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
@@ -112,8 +112,6 @@ using ScopeTimeT = pcl::ScopeTime;
 #include "pcl/common/common.h"
 #include "pcl/common/transforms.h"
 #include <pcl/console/print.h>
-// define the following in order to eliminate the deprecated headers warning
-#define VTK_EXCLUDE_STRSTREAM_HEADERS
 #include <pcl/io/vtk_lib_io.h>
 //
 #include <pcl/simulation/camera.h>
index 18f34a79dbefc2419e1060f47397adee799ce51e..fb5b4ebb9373b346b31632d388e079b933ff3336 100644 (file)
@@ -181,7 +181,9 @@ DeviceVolume::getVolume (pcl::TSDFVolume<VoxelT, WeightT>::Ptr &volume)
 
   device_volume_.download (&volume_vec[0], device_volume_.cols() * sizeof(int));
 
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none) \
+    shared(volume, volume_vec, weights_vec)
   for(int i = 0; i < (int) volume->size(); ++i)
   {
     short2 *elem = (short2*)&volume_vec[i];
index ecf3feaa15d0c2fba61471ae4805a2328fbaa2f8..5b700d6e6573e8e1656898adfad87eb01d8429d9 100644 (file)
@@ -36,6 +36,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
@@ -225,7 +226,7 @@ public:
     // Functionality
 
     /** \brief Converts volume to cloud of TSDF values
-      * \param[ou] cloud - the output point cloud
+      * \param[out] cloud - the output point cloud
       * \param[in] step - the decimation step to use
       */
     void
index 86bb94cd1851ee88ef2298707c0162bce86ace39..6ffa5a44eeec988e2579dcb3693edce772244ce2 100644 (file)
@@ -168,7 +168,6 @@ pcl::TSDFVolume<VoxelT, WeightT>::convertToTsdfCloud (pcl::PointCloud<pcl::Point
   cloud->reserve (std::min (cloud_size/10, 500000));
 
   int volume_idx = 0, cloud_idx = 0;
-//#pragma omp parallel for // if used, increment over idx not possible! use index calculation
   for (int z = 0; z < sz; z+=step)
     for (int y = 0; y < sy; y+=step)
       for (int x = 0; x < sx; x+=step, ++cloud_idx)
@@ -245,7 +244,8 @@ pcl::TSDFVolume<VoxelT, WeightT>::extractNeighborhood (const Eigen::Vector3i &vo
   const Eigen::RowVector3i offset_vector (1, neighborhood_size, neighborhood_size*neighborhood_size);
 
   // loop over all voxels in 3D neighborhood
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none)
   for (int z = min_index(2); z <= max_index(2); ++z)
   {
     for (int y = min_index(1); y <= max_index(1); ++y)
@@ -297,7 +297,8 @@ pcl::TSDFVolume<VoxelT, WeightT>::addNeighborhood (const Eigen::Vector3i &voxel_
 
   Eigen::Vector3i index = min_index;
   // loop over all voxels in 3D neighborhood
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none)
   for (int z = min_index(2); z <= max_index(2); ++z)
   {
     for (int y = min_index(1); y <= max_index(1); ++y)
@@ -329,7 +330,8 @@ pcl::TSDFVolume<VoxelT, WeightT>::addNeighborhood (const Eigen::Vector3i &voxel_
 template <typename VoxelT, typename WeightT> void
 pcl::TSDFVolume<VoxelT, WeightT>::averageValues ()
 {
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none)
   for (std::size_t i = 0; i < volume_->size(); ++i)
   {
     WeightT &w = weights_->at(i);
index 35379a19cab38e74ada8e3f456aa97e0b8a9c6b8..5b58dcab878b351185ac062c62088ad11128c839 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/point_types.h>
index 06d889939ac1e1353cd135344c279fe51123486b..a20af684801d5b1d34020a80f8e0b4b0da3c948c 100644 (file)
@@ -39,7 +39,7 @@
 #define PCL_STANDALONE_MARCHING_CUBES_IMPL_HPP_
 
 #include <pcl/gpu/kinfu_large_scale/standalone_marching_cubes.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 ///////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
@@ -191,8 +191,9 @@ pcl::gpu::kinfuLS::StandaloneMarchingCubes<PointT>::convertTsdfVectors (const Po
        constexpr int DIVISOR = std::numeric_limits<short>::max();
 
     ///For every point in the cloud
-#pragma omp parallel for
-       
+#pragma omp parallel for \
+  default(none) \
+  shared(cloud, output)        
        for(int i = 0; i < (int) cloud.points.size (); ++i)
        {
          int x = cloud.points[i].x;
index fe97d5fc797d2563537b3b98fee934c12805a3ae..6c8f1f359f5bf63e8f55eca6da4723b57d9b40e8 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
index aeb6ed8a0b23b57a3360c3425fae9b614b36edf5..8cf8236ecb829ca07a0d94f6c1a68dde47681cfd 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <Eigen/Core>
index a581256ea17572b615e141a9850e6c63ac130302..97e1f6098a0ef77bc2c4eba6f0f6731a732beef9 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <iostream>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
index f29c1079a3905fbf0914d871ce124563f5f2a58d..c1513a1196f53e0bcd58f1828774927c6debbe70 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/gpu/kinfu_large_scale/pixel_rgb.h>
-#include <boost/shared_ptr.hpp>
 //#include <boost/graph/buffer_concepts.hpp>
 #include <Eigen/Geometry>
 
index 261b86bf61bdfbf7cb77e265fd57546fa4ddc79c..fc03d4fb8d2d8c45afdbec4bb31fd6fbb19b085c 100644 (file)
@@ -91,7 +91,7 @@ namespace pcl
 
           /**Write camera pose to file*/
           void 
-          writePose(const std::string &filename_pose, const Eigen::Vector3f &teVecs, const Eigen::Matrix<float, 3, 3, Eigen::RowMajor> &erreMats);
+          writePose(const std::string &filename_pose, const Eigen::Vector3f &teVecs, const Eigen::Matrix<float, 3, 3, Eigen::RowMajor> &erreMats) const;
 
           /**Counter of the number of screenshots taken*/
           int screenshot_counter;
index 9f5bee572ea5b312129ec1bcfc5b9d10bb70e228..d44785792e308d1b22e4c0a44e55f4bc42864127 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
 #include <pcl/point_types.h>
@@ -244,7 +245,7 @@ namespace pcl
         }
 
         /** \brief Converts volume stored on host to cloud of TSDF values
-          * \param[ou] cloud - the output point cloud
+          * \param[out] cloud - the output point cloud
           * \param[in] step - the decimation step to use
           */
         void
index f37e41a40b26240757c066277bc374aaab7a9198..15e6a9a8dfdb8b1aafc9b6d383dfd70f9ece1991 100644 (file)
@@ -97,7 +97,7 @@ namespace pcl
       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
       void 
-      ScreenshotManager::writePose(const std::string &filename_pose, const Eigen::Vector3f &teVecs, const Eigen::Matrix<float, 3, 3, Eigen::RowMajor> &erreMats)
+      ScreenshotManager::writePose(const std::string &filename_pose, const Eigen::Vector3f &teVecs, const Eigen::Matrix<float, 3, 3, Eigen::RowMajor> &erreMats) const
       {
           std::ofstream poseFile;
           poseFile.open (filename_pose.c_str());
index 7cfc12e1498c8b9d05b75371e470a8b438b769a5..3c6de779b72b00712e7cae9b031cf901ece56644 100644 (file)
@@ -367,7 +367,6 @@ pcl::gpu::kinfuLS::TsdfVolume::convertToTsdfCloud ( pcl::PointCloud<pcl::PointXY
   cloud->reserve (std::min (cloud_size/10, 500000));
 
   int volume_idx = 0, cloud_idx = 0;
-  // #pragma omp parallel for // if used, increment over idx not possible! use index calculation
   for (int z = 0; z < sz; z+=step)
     for (int y = 0; y < sy; y+=step)
       for (int x = 0; x < sx; x+=step, ++cloud_idx)
@@ -393,7 +392,9 @@ pcl::gpu::kinfuLS::TsdfVolume::downloadTsdf (std::vector<float>& tsdf) const
   tsdf.resize (volume_.cols() * volume_.rows());
   volume_.download(&tsdf[0], volume_.cols() * sizeof(int));
 
-#pragma omp parallel for
+#pragma omp parallel for \
+  default(none) \
+  shared(tsdf)
   for(int i = 0; i < (int) tsdf.size(); ++i)
   {
     float tmp = reinterpret_cast<short2*>(&tsdf[i])->x;
@@ -418,7 +419,9 @@ pcl::gpu::kinfuLS::TsdfVolume::downloadTsdfAndWeights (std::vector<float>& tsdf,
   weights.resize (volumeSize);
   volume_.download(&tsdf[0], volume_.cols() * sizeof(int));
   
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none) \
+    shared(tsdf, weights)
   for(int i = 0; i < (int) tsdf.size(); ++i)
   {
     short2 elem = *reinterpret_cast<short2*>(&tsdf[i]);
index 0fd6537cce02c939ab3f939698a0302f814097a2..b4fa69a270303d39fa881db11773348220dea41e 100644 (file)
@@ -39,7 +39,7 @@
 #include <pcl/gpu/containers/kernel_containers.h>
 #include <pcl/gpu/kinfu_large_scale/kinfu.h>
 
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include <memory>
 #include <string>
index 82cf19e836ba58e9c693fcba2a9f2e70968fb5ef..350fd615cb2b37401bf650d2b62f464513b40c3d 100644 (file)
@@ -51,6 +51,7 @@ Work in progress: patch by Marco (AUG,19th 2012)
 #include <iostream>
 #include <thread>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/console/parse.h>
 
@@ -83,7 +84,7 @@ Work in progress: patch by Marco (AUG,19th 2012)
 #include "evaluation.h"
 
 #include <pcl/common/angles.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #ifdef HAVE_OPENCV  
 #include <opencv2/highgui/highgui.hpp>
index f57aaeab1df834148a66a2dd7ed59a7b86ff7b21..fa8ab9156a02dce8f7509fa91f0ad5cd0aaba816 100644 (file)
@@ -84,7 +84,7 @@
 #include "evaluation.h"
 
 #include <pcl/common/angles.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 //#include "tsdf_volume.h"
 //#include "tsdf_volume.hpp"
@@ -99,7 +99,6 @@ using ScopeTimeT = pcl::ScopeTime;
 #include <Eigen/Dense>
 #include <cmath>
 #include <iostream>
-#include <boost/shared_ptr.hpp>
 #ifdef _WIN32
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
@@ -110,8 +109,6 @@ using ScopeTimeT = pcl::ScopeTime;
 #include "pcl/common/common.h"
 #include "pcl/common/transforms.h"
 #include <pcl/console/print.h>
-// define the following in order to eliminate the deprecated headers warning
-#define VTK_EXCLUDE_STRSTREAM_HEADERS
 #include <pcl/io/vtk_lib_io.h>
 //
 #include <pcl/simulation/camera.h>
index 080ba8d1ac1d6e77266cad2efa632dc4656f0f8f..483c38c91958a8745cfc4addb6804aba03681e2c 100644 (file)
@@ -34,7 +34,7 @@
 
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <pcl/io/openni_grabber.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/common/time.h> //fps calculations
index 731066c698c492f090910bd7de638ed8bc301f87..937fdef2fba2e506aa32a36188cfab37446fc497 100644 (file)
@@ -179,7 +179,9 @@ DeviceVolume::getVolume (pcl::TSDFVolume<VoxelT, WeightT>::Ptr &volume)
 
   device_volume_.download (&volume_vec[0], device_volume_.cols() * sizeof(int));
 
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none) \
+    shared(volume, volume_vec, weights_vec)
   for(int i = 0; i < (int) volume->size(); ++i)
   {
     short2 *elem = (short2*)&volume_vec[i];
index a3305d75875b475be195fbbf030288e969a4ecdc..fbb418092c854e0f7a0e38eea3375dbf2fd65154 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <vector>
 
+#include <pcl/memory.h>
 #include <pcl/point_types.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/gpu/containers/device_array.h>
@@ -94,7 +95,7 @@ namespace pcl
                        void build();
 
             /** \brief Returns true if tree has been built */
-            bool isBuilt();
+            bool isBuilt() const;
 
             /** \brief Downloads Octree from GPU to search using CPU function. It use useful for single (not-batch) search */
             void internalDownload();
index aa848851afa8eccbd784e3ee90b7e2777c1ec90f..f28ad10b557400849680fe3e1d2f722823a02d1f 100644 (file)
@@ -78,7 +78,6 @@ pcl::gpu::Octree::~Octree() { clear(); }
 
 void pcl::gpu::Octree::clear()
 {
-    if (impl)
         delete static_cast<OctreeImpl*>(impl);
 }
 
@@ -95,7 +94,7 @@ void pcl::gpu::Octree::build()
     built_ = true;
 }
 
-bool pcl::gpu::Octree::isBuilt()
+bool pcl::gpu::Octree::isBuilt() const
 {
     return built_;
 }
index 80d67cc8bcd1e47332b772f2bb48f58808a84083..31503620384910b685aea75903e71804d018b99b 100644 (file)
@@ -34,6 +34,7 @@
  *  Author: Anatoly Baskeheev, Itseez Ltd, (myname.mysurname@mycompany.com)
  */
 
+
 #ifndef _PCL_TEST_GPU_OCTREE_DATAGEN_
 #define _PCL_TEST_GPU_OCTREE_DATAGEN_
 
     EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(pcl::PointXYZ)
 #endif
 
+
+namespace pcl
+{
+
+namespace gpu
+{
+
 struct DataGenerator
 {
-    using PointType = pcl::gpu::Octree::PointType;
+    using PointType = Octree::PointType;
 
-    std::size_t data_size;            
+    std::size_t data_size;
     std::size_t tests_num;
 
     float cube_size;
-    float max_radius;     
+    float max_radius;
 
     float shared_radius;
 
@@ -74,43 +82,43 @@ struct DataGenerator
     }
 
     void operator()()
-    {             
+    {
         srand (0);
 
         points.resize(data_size);
         for(std::size_t i = 0; i < data_size; ++i)
-        {            
-            points[i].x = ((float)rand())/RAND_MAX * cube_size;  
-            points[i].y = ((float)rand())/RAND_MAX * cube_size;  
+        {
+            points[i].x = ((float)rand())/RAND_MAX * cube_size;
+            points[i].y = ((float)rand())/RAND_MAX * cube_size;
             points[i].z = ((float)rand())/RAND_MAX * cube_size;
         }
-        
+
 
         queries.resize(tests_num);
         radiuses.resize(tests_num);
         for (std::size_t i = 0; i < tests_num; ++i)
-        {            
-            queries[i].x = ((float)rand())/RAND_MAX * cube_size;  
-            queries[i].y = ((float)rand())/RAND_MAX * cube_size;  
-            queries[i].z = ((float)rand())/RAND_MAX * cube_size;               
-            radiuses[i]  = ((float)rand())/RAND_MAX * max_radius;      
-        };        
+        {
+            queries[i].x = ((float)rand())/RAND_MAX * cube_size;
+            queries[i].y = ((float)rand())/RAND_MAX * cube_size;
+            queries[i].z = ((float)rand())/RAND_MAX * cube_size;
+            radiuses[i]  = ((float)rand())/RAND_MAX * max_radius;
+        };
 
         for(std::size_t i = 0; i < tests_num/2; ++i)
             indices.push_back(i*2);
     }
 
     void bruteForceSearch(bool log = false, float radius = -1.f)
-    {        
+    {
         if (log)
             std::cout << "BruteForceSearch";
 
         int value100 = std::min<int>(tests_num, 50);
-        int step = tests_num/value100;        
+        int step = tests_num/value100;
 
         bfresutls.resize(tests_num);
         for(std::size_t i = 0; i < tests_num; ++i)
-        {            
+        {
             if (log && i % step == 0)
             {
                 std::cout << ".";
@@ -119,7 +127,7 @@ struct DataGenerator
 
             std::vector<int>& curr_res = bfresutls[i];
             curr_res.clear();
-                        
+
             float query_radius = radius > 0 ? radius : radiuses[i];
             const PointType& query = queries[i];
 
@@ -141,8 +149,8 @@ struct DataGenerator
             std::cout << "Done" << std::endl;
     }
 
-    void printParams() const 
-    {        
+    void printParams() const
+    {
         std::cout << "Points number  = " << data_size << std::endl;
         std::cout << "Queries number = " << tests_num << std::endl;
         std::cout << "Cube size      = " << cube_size << std::endl;
@@ -152,8 +160,8 @@ struct DataGenerator
 
     template<typename Dst>
     struct ConvPoint
-    {    
-        Dst operator()(const PointType& src) const 
+    {
+        Dst operator()(const PointType& src) const
         {
             Dst dst;
             dst.x = src.x;
@@ -162,10 +170,10 @@ struct DataGenerator
             return dst;
         }
     };
-
 };
 
-#endif  /* _PCL_TEST_GPU_OCTREE_DATAGEN_ */
-
+} // namespace gpu
+} // namespace pcl
 
+#endif  /* _PCL_TEST_GPU_OCTREE_DATAGEN_ */
 
index d1d7b6f28ba774343835a1e36929a9ffeb5043f5..ee560dc88db844a14c816deef7e1568d0840ec80 100644 (file)
@@ -36,6 +36,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
@@ -44,8 +45,7 @@
 #include <pcl/gpu/people/label_blob2.h>
 #include <pcl/gpu/people/label_common.h>
 #include "pcl/gpu/people/person_attribs.h"
-#include <boost/shared_ptr.hpp>
-#include <memory>
+
 #include <string>
 #include <vector>
 
index 57321de6e4346c4a173a2080177edc79a4df8786..31a53b7ba6a502429a800da780209537a87fd2eb 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
 
-#include <boost/shared_ptr.hpp>
+
 #include <string>
 #include <vector>
 
@@ -162,7 +163,7 @@ namespace pcl
 
           /** \brief Get the cuda GPU device id in use **/
           int
-          getDeviceId() {return cuda_dev_id_;}
+          getDeviceId() const {return cuda_dev_id_;}
 
         private:
           bool                largest_object_;      /** \brief only give back largest object **/
index 9ae24ffb6ae1457a5a9e0521e4c49552ff6f1ca6..e4be7d67f357bac3d2f0693f906445c9c9aa7354 100644 (file)
@@ -36,6 +36,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
@@ -45,7 +46,6 @@
 #include <pcl/common/transforms.h>
 #include <pcl/gpu/people/label_common.h>
 
-#include <boost/shared_ptr.hpp>
 #include <string>
 #include <vector>
 
index 6b81bb42e577869ef99746c41fce26bde53e1d2d..fd9201bd157da3868559195b029ec2ba7d3596a8 100644 (file)
@@ -3,7 +3,7 @@
 #include <string>
 #include <vector>
 #include <iosfwd>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include <pcl/pcl_exports.h>
 
index ca21e0e297f3fe6049c27d3cb37ba14c7154bb46..c1a1b69ce00e88b20b1159c32be865ada92023d9 100644 (file)
@@ -138,27 +138,27 @@ struct HaarFeatureDescriptor32
       return NCV_SUCCESS;
     }
 
-    __device__ __host__ NcvBool isTilted()
+    __device__ __host__ NcvBool isTilted() const
     {
       return (this->desc & HaarFeatureDescriptor32_Interpret_MaskFlagTilted) != 0;
     }
 
-    __device__ __host__ NcvBool isLeftNodeLeaf()
+    __device__ __host__ NcvBool isLeftNodeLeaf() const
     {
       return (this->desc & HaarFeatureDescriptor32_Interpret_MaskFlagLeftNodeLeaf) != 0;
     }
 
-    __device__ __host__ NcvBool isRightNodeLeaf()
+    __device__ __host__ NcvBool isRightNodeLeaf() const
     {
       return (this->desc & HaarFeatureDescriptor32_Interpret_MaskFlagRightNodeLeaf) != 0;
     }
 
-    __device__ __host__ Ncv32u getNumFeatures()
+    __device__ __host__ Ncv32u getNumFeatures() const
     {
       return (this->desc >> HaarFeatureDescriptor32_NumFeatures_Shift) & HaarFeatureDescriptor32_CreateCheck_MaxNumFeatures;
     }
 
-    __device__ __host__ Ncv32u getFeaturesOffset()
+    __device__ __host__ Ncv32u getFeaturesOffset() const
     {
       return this->desc & HaarFeatureDescriptor32_CreateCheck_MaxFeatureOffset;
     }
@@ -185,7 +185,7 @@ struct HaarClassifierNodeDescriptor32
       return (*(Ncv32f *)&this->_ui1.x);
     }
 
-    __host__ bool isLeaf()                                  // TODO: check this hack don't know if is correct
+    __host__ bool isLeaf() const                                  // TODO: check this hack don't know if is correct
     {
       return ( _ui1.x != 0);
     }
@@ -291,12 +291,12 @@ struct HaarStage64
       return *(Ncv32f*)&this->_ui2.x;
     }
 
-    __host__ __device__ Ncv32u getStartClassifierRootNodeOffset()
+    __host__ __device__ Ncv32u getStartClassifierRootNodeOffset() const
     {
       return (this->_ui2.y >> HaarStage64_Interpret_ShiftRootNodeOffset);
     }
 
-    __host__ __device__ Ncv32u getNumClassifierRootNodes()
+    __host__ __device__ Ncv32u getNumClassifierRootNodes() const
     {
       return (this->_ui2.y & HaarStage64_Interpret_MaskRootNodes);
     }
index dfc0c219b76a37071a312e71b14a0905fc0cc822..c42dedddf5c7989afc923ae2b3158ff652e9bc8c 100644 (file)
@@ -75,7 +75,7 @@ NCV_EXPORTS
 cudaStream_t nppStSetActiveCUDAstream(cudaStream_t cudaStream);
 
 
-/*@}*/
+/**@}*/
 
 
 /** \defgroup nppi NPPST Image Processing
@@ -131,7 +131,7 @@ enum NppStInterpMode
 
 
 /** Size of a buffer required for interpolation.
- * 
+ *
  * Requires several such buffers. See \see NppStInterpolationState.
  *
  * \param srcSize           [IN]  Frame size (both frames must be of the same size)
@@ -177,17 +177,17 @@ NCVStatus nppiStInterpolateFrames(const NppStInterpolationState *pState);
  * \return NCV status code
  */
 NCV_EXPORTS
-NCVStatus nppiStFilterRowBorder_32f_C1R(const Ncv32f *pSrc, 
-                                        NcvSize32u srcSize, 
+NCVStatus nppiStFilterRowBorder_32f_C1R(const Ncv32f *pSrc,
+                                        NcvSize32u srcSize,
                                         Ncv32u nSrcStep,
-                                        Ncv32f *pDst, 
-                                        NcvSize32u dstSize, 
+                                        Ncv32f *pDst,
+                                        NcvSize32u dstSize,
                                         Ncv32u nDstStep,
-                                        NcvRect32u oROI, 
+                                        NcvRect32u oROI,
                                         NppStBorderType borderType,
-                                        const Ncv32f *pKernel, 
+                                        const Ncv32f *pKernel,
                                         Ncv32s nKernelSize,
-                                        Ncv32s nAnchor, 
+                                        Ncv32s nAnchor,
                                         Ncv32f multiplier);
 
 
@@ -226,14 +226,14 @@ NCVStatus nppiStFilterColumnBorder_32f_C1R(const Ncv32f *pSrc,
 
 
 /** Size of buffer required for vector image warping.
- * 
+ *
  * \param srcSize           [IN]  Source image size
  * \param nSrcStep          [IN]  Source image line step
  * \param hpSize            [OUT] Where to store computed size (host memory)
  *
  * \return NCV status code
  */
-NCV_EXPORTS 
+NCV_EXPORTS
 NCVStatus nppiStVectorWarpGetBufferSize(NcvSize32u srcSize,
                                         Ncv32u nSrcStep,
                                         Ncv32u *hpSize);
@@ -318,7 +318,7 @@ NCVStatus nppiStVectorWarp_PSF2x2_32f_C1(const Ncv32f *pSrc,
  * \param xFactor           [IN]  Row scale factor
  * \param yFactor           [IN]  Column scale factor
  * \param interpolation     [IN]  Interpolation type
- * 
+ *
  * \return NCV status code
  */
 NCV_EXPORTS
@@ -790,7 +790,7 @@ NCVStatus nppiStSqrIntegral_8u64u_C1R_host(Ncv8u *h_src, Ncv32u srcStep,
                                            Ncv64u *h_dst, Ncv32u dstStep, NcvSize32u roiSize);
 
 
-/*@}*/
+/**@}*/
 
 
 /** \defgroup npps NPPST Signal Processing
@@ -902,7 +902,7 @@ NCVStatus nppsStCompact_32f_host(Ncv32f *h_src, Ncv32u srcLen,
                                  Ncv32f *h_dst, Ncv32u *dstLen, Ncv32f elemRemove);
 
 
-/*@}*/
+/**@}*/
 
 
 #endif // _npp_staging_hpp_
index 1dfae5ac17ad23e95e2e8cce5c102b5396aa98e1..aa801de206c1d10050f53d6f9b5adb072a4c8647 100644 (file)
@@ -178,7 +178,6 @@ void optimized_shs5(const PointCloud<PointXYZRGB> &cloud, float tolerance, const
 
     //  omp_set_num_threads(1);
     // Process all points in the indices vector
-    //#pragma omp parallel for
     for (int k = 0; k < static_cast<int> (indices_in.indices.size ()); ++k)
     {
         int i = indices_in.indices[k];
index 39e13733a058aa7782d37beba8b9b77ee21756a1..711d9e33312bc48b8b7ca6e92445277d6b09d538 100644 (file)
@@ -102,7 +102,7 @@ pcl::gpu::people::FaceDetector::loadFromXML2(const std::string
   {
     read_xml(filename,pt);
   }
-  catch(boost::exception const&  exb)
+  catch(boost::exception const&)
   {
     PCL_DEBUG("[pcl::gpu::people::FaceDetector::loadFromXML2] : (D) : Unable to read filename with boost exception\n");
     return NCV_HAAR_XML_LOADING_EXCEPTION;
@@ -301,7 +301,7 @@ pcl::gpu::people::FaceDetector::loadFromXML2(const std::string
       level1++;
     }
   }
-  catch(boost::exception const&  exb)
+  catch(boost::exception const&)
   {
     PCL_DEBUG("[pcl::gpu::people::FaceDetector::loadFromXML2] : (D) : Unable to process content with boost exception\n");
     return (NCV_HAAR_XML_LOADING_EXCEPTION);
index 7f07745d762c9c8d28276aca75ccd9375b42fff8..cd284138584d009c231df3dc4a4c1ce42596b923 100644 (file)
@@ -486,9 +486,9 @@ pcl::gpu::people::PeopleDetector::shs5(const pcl::PointCloud<PointT> &cloud, con
 
   // Process all points in the indices vector
   int total = static_cast<int> (indices.size ());
-#ifdef _OPENMP
-#pragma omp parallel for
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(cloud, intr, hue, indices, mask, squared_radius, storage, total)
   for (int k = 0; k < total; ++k)
   {
     int i = indices[k];
index b17c1d33851a3eab20cb0c67a6d75738ef271732..616983d77109af0d1b48e7d1da7eacf48b85f4cd 100644 (file)
@@ -65,7 +65,7 @@ namespace pcl
         {
                  Tex2Dfetcher( const std::uint16_t* dmap, int W, int H ) : m_dmap(dmap), m_W(W), m_H(H) {}
 
-          inline std::uint16_t operator () ( float uf, float vf ) 
+          inline std::uint16_t operator () ( float uf, float vf ) const 
           {
             int u = static_cast<int>(uf);
             int v = static_cast<int>(vf);
index 697363a002eae6ecc2a1d5d01f828eeea304bff7..845eec3e191724572195c91e83c056120f71f5e2 100644 (file)
@@ -139,7 +139,7 @@ class PeoplePCDApp
     }
 
     void
-    writeXMLFile(std::string& filename)
+    writeXMLFile(std::string& filename) const
     {
       filebuf fb;
       fb.open (filename.c_str(), ios::out);
@@ -149,7 +149,7 @@ class PeoplePCDApp
     }
 
     void
-    readXMLFile(std::string& filename)
+    readXMLFile(std::string& filename) const
     {
       filebuf fb;
       fb.open (filename.c_str(), ios::in);
index 70a58ad365fa7c8f385a3b5dafdaacc1ff2ed01e..5b6263e7ed5e73605d41ecc13a93ff89e156d2a4 100644 (file)
@@ -72,12 +72,27 @@ class PeopleTrackingApp
       interface->stop ();
     }
 
-    pcl::visualization::CloudViewer         viewer;
-    pcl::people::trees::MultiTreeLiveProc*  m_proc;
-    cv::Mat                                 m_lmap;
-    cv::Mat                                 m_cmap;
-    cv::Mat                                 cmap;
-    cv::Mat                                 m_bmap;
+    void load_tree(std::string treeFilenames[4], int numTrees)
+    {
+      std::ifstream fin0 (treeFilenames[0]);
+      assert(fin0.is_open());
+      m_proc = std::make_unique<pcl::people::trees::MultiTreeLiveProc> (fin0);
+
+      /// Load the other tree files
+      for (const auto& file : treeFilenames)
+      {
+        std::ifstream fin (file);
+        assert (fin.is_open());
+        m_proc->addTree(fin);
+      }
+    }
+
+    pcl::visualization::CloudViewer                        viewer;
+    std::unique_ptr<pcl::people::trees::MultiTreeLiveProc> m_proc;
+    cv::Mat                                                m_lmap;
+    cv::Mat                                                m_cmap;
+    cv::Mat                                                cmap;
+    cv::Mat                                                m_bmap;
 };
 
 int print_help()
@@ -111,18 +126,8 @@ int main(int argc, char** argv)
   PeopleTrackingApp app;
 
   /// Load the first tree
-  std::ifstream fin0(treeFilenames[0].c_str() );
-  assert(fin0.is_open() );
-  app.m_proc = new pcl::people::trees::MultiTreeLiveProc(fin0);
-  fin0.close();
-
-  /// Load the other tree files
-  for(int ti=1;ti<numTrees;++ti) {
-    std::ifstream fin(treeFilenames[ti].c_str() );
-    assert(fin.is_open() );
-    app.m_proc->addTree(fin);
-    fin.close();
-  }
+  app.load_tree(treeFilenames, numTrees);
+
   /// Run the app
   app.run();
   return 0;
index 522a2d7325cfe3aa5fb60ee07f7b3d6df374d2e3..7c4410f6df8ec0c0e1e35d71be4e7f74dfc0d0ce 100644 (file)
@@ -59,7 +59,7 @@ pcl::device::FacetStream::FacetStream(std::size_t buffer_size)
 }
 
 bool 
-pcl::device::FacetStream::canSplit()
+pcl::device::FacetStream::canSplit() const
 {
   return facet_count * 3 < verts_inds.cols();
 }
index 783c3c2b007baba2d9fefe4ce36717a6a5714e2a..47c76fbae7fb5d102eb94a172c7384b31304aaed 100644 (file)
@@ -80,7 +80,7 @@ namespace pcl
 
                  void compactFacets();
 
-                 bool canSplit();
+                 bool canSplit() const;
                  void splitFacets();
          private:
                  
index ca33ac0fb8c59b833cefecf4f7ec2900060e9424..e2444ca7097a1849dc0c9991578aa09ae61f0aaf 100644 (file)
@@ -60,10 +60,10 @@ namespace pcl
                 cudaEventDestroy(stop_);
             }
 
-            void start() { cudaEventRecord(start_, 0); }
+            void start() const { cudaEventRecord(start_, 0); }
             Timer& stop()  { cudaEventRecord(stop_, 0); cudaEventSynchronize(stop_); return *this; }
 
-            float time()
+            float time() const
             {
                 float elapsed_time; 
                 cudaEventElapsedTime(&elapsed_time, start_, stop_);
index 1741230d1a2b8b915026e1290ede8558eb1a607a..f234971002090fb1a2c56ea7c8d67aff953217c4 100644 (file)
@@ -288,7 +288,6 @@ set(incs
   ${DSSDK_GRABBER_INCLUDES}
   ${RSSDK_GRABBER_INCLUDES}
   ${RSSDK2_GRABBER_INCLUDES}
-  "include/pcl/${SUBSYS_NAME}/pxc_grabber.h"  # contains only depreciation note
 )
 
 set(compression_incs
index 5ab9333e250769a9e519c2a16e4de26d6267ebe2..52b4a608d99a7192e8057236bee2e1682fcde1a3 100644 (file)
 
 namespace pcl
 {
-  namespace octree
+
+namespace octree
+{
+
+using namespace std;
+
+/** \brief @b ColorCoding class
+ *  \note This class encodes 8-bit color information for octree-based point cloud compression.
+ *  \note
+ *  \note typename: PointT: type of point used in pointcloud
+ *  \author Julius Kammerl (julius@kammerl.de)
+ */
+template<typename PointT>
+class ColorCoding
+{
+  // public typedefs
+  using PointCloud = pcl::PointCloud<PointT>;
+  using PointCloudPtr = typename PointCloud::Ptr;
+  using PointCloudConstPtr = typename PointCloud::ConstPtr;
+
+public:
+  /** \brief Constructor.
+   *
+   * */
+  ColorCoding () :
+    output_ (), colorBitReduction_ (0)
+  {
+  }
+
+  /** \brief Empty class constructor. */
+  virtual
+  ~ColorCoding ()
+  {
+  }
+
+  /** \brief Define color bit depth of encoded color information.
+    * \param bitDepth_arg: amounts of bits for representing one color component
+    */
+  inline
+  void
+  setBitDepth (unsigned char bitDepth_arg)
+  {
+    colorBitReduction_ = static_cast<unsigned char> (8 - bitDepth_arg);
+  }
+
+  /** \brief Retrieve color bit depth of encoded color information.
+    * \return amounts of bits for representing one color component
+    */
+  inline unsigned char
+  getBitDepth ()
+  {
+    return (static_cast<unsigned char> (8 - colorBitReduction_));
+  }
+
+  /** \brief Set amount of voxels containing point color information and reserve memory
+    * \param voxelCount_arg: amounts of voxels
+    */
+  inline void
+  setVoxelCount (unsigned int voxelCount_arg)
+  {
+    pointAvgColorDataVector_.reserve (voxelCount_arg * 3);
+  }
+
+  /** \brief Set amount of points within point cloud to be encoded and reserve memory
+   *  \param pointCount_arg: amounts of points within point cloud
+   * */
+  inline
+  void
+  setPointCount (unsigned int pointCount_arg)
+  {
+    pointDiffColorDataVector_.reserve (pointCount_arg * 3);
+  }
+
+  /** \brief Initialize encoding of color information
+   * */
+  void
+  initializeEncoding ()
+  {
+    pointAvgColorDataVector_.clear ();
+
+    pointDiffColorDataVector_.clear ();
+  }
+
+  /** \brief Initialize decoding of color information
+   * */
+  void
+  initializeDecoding ()
+  {
+    pointAvgColorDataVector_Iterator_ = pointAvgColorDataVector_.begin ();
+
+    pointDiffColorDataVector_Iterator_ = pointDiffColorDataVector_.begin ();
+  }
+
+  /** \brief Get reference to vector containing averaged color data
+   * */
+  std::vector<char>&
+  getAverageDataVector ()
+  {
+    return pointAvgColorDataVector_;
+  }
+
+  /** \brief Get reference to vector containing differential color data
+   * */
+  std::vector<char>&
+  getDifferentialDataVector ()
   {
-    using namespace std;
-
-    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    /** \brief @b ColorCoding class
-     *  \note This class encodes 8-bit color information for octree-based point cloud compression.
-     *  \note
-     *  \note typename: PointT: type of point used in pointcloud
-     *  \author Julius Kammerl (julius@kammerl.de)
-     */
-    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    template<typename PointT>
-      class ColorCoding
+    return pointDiffColorDataVector_;
+  }
+
+  /** \brief Encode averaged color information for a subset of points from point cloud
+   * \param indexVector_arg indices defining a subset of points from points cloud
+   * \param rgba_offset_arg offset to color information
+   * \param inputCloud_arg input point cloud
+   * */
+  void
+  encodeAverageOfPoints (const typename std::vector<int>& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
+  {
+    unsigned int avgRed = 0;
+    unsigned int avgGreen = 0;
+    unsigned int avgBlue = 0;
+
+    // iterate over points
+    std::size_t len = indexVector_arg.size ();
+    for (std::size_t i = 0; i < len; i++)
+    {
+      // get color information from points
+      const int& idx = indexVector_arg[i];
+      const char* idxPointPtr = reinterpret_cast<const char*> (&inputCloud_arg->points[idx]);
+      const int& colorInt = *reinterpret_cast<const int*> (idxPointPtr+rgba_offset_arg);
+
+      // add color information
+      avgRed += (colorInt >> 0) & 0xFF;
+      avgGreen += (colorInt >> 8) & 0xFF;
+      avgBlue += (colorInt >> 16) & 0xFF;
+
+    }
+
+    // calculated average color information
+    if (len > 1)
+    {
+      avgRed   /= static_cast<unsigned int> (len);
+      avgGreen /= static_cast<unsigned int> (len);
+      avgBlue  /= static_cast<unsigned int> (len);
+    }
+
+    // remove least significant bits
+    avgRed >>= colorBitReduction_;
+    avgGreen >>= colorBitReduction_;
+    avgBlue >>= colorBitReduction_;
+
+    // add to average color vector
+    pointAvgColorDataVector_.push_back (static_cast<char> (avgRed));
+    pointAvgColorDataVector_.push_back (static_cast<char> (avgGreen));
+    pointAvgColorDataVector_.push_back (static_cast<char> (avgBlue));
+  }
+
+  /** \brief Encode color information of a subset of points from point cloud
+   * \param indexVector_arg indices defining a subset of points from points cloud
+   * \param rgba_offset_arg offset to color information
+   * \param inputCloud_arg input point cloud
+   * */
+  void
+  encodePoints (const typename std::vector<int>& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
+  {
+    unsigned int avgRed;
+    unsigned int avgGreen;
+    unsigned int avgBlue;
+
+    // initialize
+    avgRed = avgGreen = avgBlue = 0;
+
+    // iterate over points
+    std::size_t len = indexVector_arg.size ();
+    for (std::size_t i = 0; i < len; i++)
+    {
+      // get color information from point
+      const int& idx = indexVector_arg[i];
+      const char* idxPointPtr = reinterpret_cast<const char*> (&inputCloud_arg->points[idx]);
+      const int& colorInt = *reinterpret_cast<const int*> (idxPointPtr+rgba_offset_arg);
+
+      // add color information
+      avgRed += (colorInt >> 0) & 0xFF;
+      avgGreen += (colorInt >> 8) & 0xFF;
+      avgBlue += (colorInt >> 16) & 0xFF;
+
+    }
+
+    if (len > 1)
+    {
+      unsigned char diffRed;
+      unsigned char diffGreen;
+      unsigned char diffBlue;
+
+      // calculated average color information
+      avgRed   /= static_cast<unsigned int> (len);
+      avgGreen /= static_cast<unsigned int> (len);
+      avgBlue  /= static_cast<unsigned int> (len);
+
+      // iterate over points for differential encoding
+      for (std::size_t i = 0; i < len; i++)
       {
+        const int& idx = indexVector_arg[i];
+        const char* idxPointPtr = reinterpret_cast<const char*> (&inputCloud_arg->points[idx]);
+        const int& colorInt = *reinterpret_cast<const int*> (idxPointPtr+rgba_offset_arg);
+
+        // extract color components and do XOR encoding with predicted average color
+        diffRed = (static_cast<unsigned char> (avgRed)) ^ static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
+        diffGreen = (static_cast<unsigned char> (avgGreen)) ^ static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
+        diffBlue = (static_cast<unsigned char> (avgBlue)) ^ static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
+
+        // remove least significant bits
+        diffRed = static_cast<unsigned char> (diffRed >> colorBitReduction_);
+        diffGreen = static_cast<unsigned char> (diffGreen >> colorBitReduction_);
+        diffBlue = static_cast<unsigned char> (diffBlue >> colorBitReduction_);
+
+        // add to differential color vector
+        pointDiffColorDataVector_.push_back (static_cast<char> (diffRed));
+        pointDiffColorDataVector_.push_back (static_cast<char> (diffGreen));
+        pointDiffColorDataVector_.push_back (static_cast<char> (diffBlue));
+      }
+    }
+
+    // remove least significant bits from average color information
+    avgRed   >>= colorBitReduction_;
+    avgGreen >>= colorBitReduction_;
+    avgBlue  >>= colorBitReduction_;
+
+    // add to differential color vector
+    pointAvgColorDataVector_.push_back (static_cast<char> (avgRed));
+    pointAvgColorDataVector_.push_back (static_cast<char> (avgGreen));
+    pointAvgColorDataVector_.push_back (static_cast<char> (avgBlue));
 
-      // public typedefs
-        using PointCloud = pcl::PointCloud<PointT>;
-        using PointCloudPtr = typename PointCloud::Ptr;
-        using PointCloudConstPtr = typename PointCloud::ConstPtr;
-
-      public:
-
-        /** \brief Constructor.
-         *
-         * */
-        ColorCoding () :
-          output_ (), colorBitReduction_ (0)
-        {
-        }
-
-        /** \brief Empty class constructor. */
-        virtual
-        ~ColorCoding ()
-        {
-        }
-
-        /** \brief Define color bit depth of encoded color information.
-          * \param bitDepth_arg: amounts of bits for representing one color component
-          */
-        inline
-        void
-        setBitDepth (unsigned char bitDepth_arg)
-        {
-          colorBitReduction_ = static_cast<unsigned char> (8 - bitDepth_arg);
-        }
-
-        /** \brief Retrieve color bit depth of encoded color information.
-          * \return amounts of bits for representing one color component
-          */
-        inline unsigned char
-        getBitDepth ()
-        {
-          return (static_cast<unsigned char> (8 - colorBitReduction_));
-        }
-
-        /** \brief Set amount of voxels containing point color information and reserve memory
-          * \param voxelCount_arg: amounts of voxels
-          */
-        inline void
-        setVoxelCount (unsigned int voxelCount_arg)
-        {
-          pointAvgColorDataVector_.reserve (voxelCount_arg * 3);
-        }
-
-        /** \brief Set amount of points within point cloud to be encoded and reserve memory
-         *  \param pointCount_arg: amounts of points within point cloud
-         * */
-        inline
-        void
-        setPointCount (unsigned int pointCount_arg)
-        {
-          pointDiffColorDataVector_.reserve (pointCount_arg * 3);
-        }
-
-        /** \brief Initialize encoding of color information
-         * */
-        void
-        initializeEncoding ()
-        {
-          pointAvgColorDataVector_.clear ();
-
-          pointDiffColorDataVector_.clear ();
-        }
-
-        /** \brief Initialize decoding of color information
-         * */
-        void
-        initializeDecoding ()
-        {
-          pointAvgColorDataVector_Iterator_ = pointAvgColorDataVector_.begin ();
-
-          pointDiffColorDataVector_Iterator_ = pointDiffColorDataVector_.begin ();
-        }
-
-        /** \brief Get reference to vector containing averaged color data
-         * */
-        std::vector<char>&
-        getAverageDataVector ()
-        {
-          return pointAvgColorDataVector_;
-        }
-
-        /** \brief Get reference to vector containing differential color data
-         * */
-        std::vector<char>&
-        getDifferentialDataVector ()
-        {
-          return pointDiffColorDataVector_;
-        }
-
-        /** \brief Encode averaged color information for a subset of points from point cloud
-         * \param indexVector_arg indices defining a subset of points from points cloud
-         * \param rgba_offset_arg offset to color information
-         * \param inputCloud_arg input point cloud
-         * */
-        void
-        encodeAverageOfPoints (const typename std::vector<int>& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
-        {
-          unsigned int avgRed = 0;
-          unsigned int avgGreen = 0;
-          unsigned int avgBlue = 0;
-
-          // iterate over points
-          std::size_t len = indexVector_arg.size ();
-          for (std::size_t i = 0; i < len; i++)
-          {
-            // get color information from points
-            const int& idx = indexVector_arg[i];
-            const char* idxPointPtr = reinterpret_cast<const char*> (&inputCloud_arg->points[idx]);
-            const int& colorInt = *reinterpret_cast<const int*> (idxPointPtr+rgba_offset_arg);
-
-            // add color information
-            avgRed += (colorInt >> 0) & 0xFF;
-            avgGreen += (colorInt >> 8) & 0xFF;
-            avgBlue += (colorInt >> 16) & 0xFF;
-
-          }
-
-          // calculated average color information
-          if (len > 1)
-          {
-            avgRed   /= static_cast<unsigned int> (len);
-            avgGreen /= static_cast<unsigned int> (len);
-            avgBlue  /= static_cast<unsigned int> (len);
-          }
-
-          // remove least significant bits
-          avgRed >>= colorBitReduction_;
-          avgGreen >>= colorBitReduction_;
-          avgBlue >>= colorBitReduction_;
-
-          // add to average color vector
-          pointAvgColorDataVector_.push_back (static_cast<char> (avgRed));
-          pointAvgColorDataVector_.push_back (static_cast<char> (avgGreen));
-          pointAvgColorDataVector_.push_back (static_cast<char> (avgBlue));
-        }
-
-        /** \brief Encode color information of a subset of points from point cloud
-         * \param indexVector_arg indices defining a subset of points from points cloud
-         * \param rgba_offset_arg offset to color information
-         * \param inputCloud_arg input point cloud
-         * */
-        void
-        encodePoints (const typename std::vector<int>& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
-        {
-          unsigned int avgRed;
-          unsigned int avgGreen;
-          unsigned int avgBlue;
-
-          // initialize
-          avgRed = avgGreen = avgBlue = 0;
-
-          // iterate over points
-          std::size_t len = indexVector_arg.size ();
-          for (std::size_t i = 0; i < len; i++)
-          {
-            // get color information from point
-            const int& idx = indexVector_arg[i];
-            const char* idxPointPtr = reinterpret_cast<const char*> (&inputCloud_arg->points[idx]);
-            const int& colorInt = *reinterpret_cast<const int*> (idxPointPtr+rgba_offset_arg);
-
-            // add color information
-            avgRed += (colorInt >> 0) & 0xFF;
-            avgGreen += (colorInt >> 8) & 0xFF;
-            avgBlue += (colorInt >> 16) & 0xFF;
-
-          }
-
-          if (len > 1)
-          {
-            unsigned char diffRed;
-            unsigned char diffGreen;
-            unsigned char diffBlue;
-
-            // calculated average color information
-            avgRed   /= static_cast<unsigned int> (len);
-            avgGreen /= static_cast<unsigned int> (len);
-            avgBlue  /= static_cast<unsigned int> (len);
-
-            // iterate over points for differential encoding
-            for (std::size_t i = 0; i < len; i++)
-            {
-              const int& idx = indexVector_arg[i];
-              const char* idxPointPtr = reinterpret_cast<const char*> (&inputCloud_arg->points[idx]);
-              const int& colorInt = *reinterpret_cast<const int*> (idxPointPtr+rgba_offset_arg);
-
-              // extract color components and do XOR encoding with predicted average color
-              diffRed = (static_cast<unsigned char> (avgRed)) ^ static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
-              diffGreen = (static_cast<unsigned char> (avgGreen)) ^ static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
-              diffBlue = (static_cast<unsigned char> (avgBlue)) ^ static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
-
-              // remove least significant bits
-              diffRed = static_cast<unsigned char> (diffRed >> colorBitReduction_);
-              diffGreen = static_cast<unsigned char> (diffGreen >> colorBitReduction_);
-              diffBlue = static_cast<unsigned char> (diffBlue >> colorBitReduction_);
-
-              // add to differential color vector
-              pointDiffColorDataVector_.push_back (static_cast<char> (diffRed));
-              pointDiffColorDataVector_.push_back (static_cast<char> (diffGreen));
-              pointDiffColorDataVector_.push_back (static_cast<char> (diffBlue));
-            }
-          }
-
-          // remove least significant bits from average color information
-          avgRed   >>= colorBitReduction_;
-          avgGreen >>= colorBitReduction_;
-          avgBlue  >>= colorBitReduction_;
-
-          // add to differential color vector
-          pointAvgColorDataVector_.push_back (static_cast<char> (avgRed));
-          pointAvgColorDataVector_.push_back (static_cast<char> (avgGreen));
-          pointAvgColorDataVector_.push_back (static_cast<char> (avgBlue));
-
-        }
-
-        /** \brief Decode color information
-          * \param outputCloud_arg output point cloud
-          * \param beginIdx_arg index indicating first point to be assigned with color information
-          * \param endIdx_arg index indicating last point to be assigned with color information
-          * \param rgba_offset_arg offset to color information
-          */
-        void
-        decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg)
-        {
-          assert (beginIdx_arg <= endIdx_arg);
-
-          // amount of points to be decoded
-          unsigned int pointCount = static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
-
-          // get averaged color information for current voxel
-          unsigned char avgRed = *(pointAvgColorDataVector_Iterator_++);
-          unsigned char avgGreen = *(pointAvgColorDataVector_Iterator_++);
-          unsigned char avgBlue = *(pointAvgColorDataVector_Iterator_++);
-
-          // invert bit shifts during encoding
-          avgRed = static_cast<unsigned char> (avgRed << colorBitReduction_);
-          avgGreen = static_cast<unsigned char> (avgGreen << colorBitReduction_);
-          avgBlue = static_cast<unsigned char> (avgBlue << colorBitReduction_);
-
-          // iterate over points
-          for (std::size_t i = 0; i < pointCount; i++)
-          {
-            unsigned int colorInt;
-            if (pointCount > 1)
-            {
-              // get differential color information from input vector
-              unsigned char diffRed   = static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
-              unsigned char diffGreen = static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
-              unsigned char diffBlue  = static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
-
-              // invert bit shifts during encoding
-              diffRed = static_cast<unsigned char> (diffRed << colorBitReduction_);
-              diffGreen = static_cast<unsigned char> (diffGreen << colorBitReduction_);
-              diffBlue = static_cast<unsigned char> (diffBlue << colorBitReduction_);
-
-              // decode color information
-              colorInt = ((avgRed ^ diffRed) << 0) |
-                         ((avgGreen ^ diffGreen) << 8) |
-                         ((avgBlue ^ diffBlue) << 16);
-            }
-            else
-            {
-              // decode color information
-              colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
-            }
-
-            char* idxPointPtr = reinterpret_cast<char*> (&outputCloud_arg->points[beginIdx_arg + i]);
-            int& pointColor = *reinterpret_cast<int*> (idxPointPtr+rgba_offset_arg);
-            // assign color to point from point cloud
-            pointColor=colorInt;
-          }
-        }
-
-        /** \brief Set default color to points
-         * \param outputCloud_arg output point cloud
-         * \param beginIdx_arg index indicating first point to be assigned with color information
-         * \param endIdx_arg index indicating last point to be assigned with color information
-         * \param rgba_offset_arg offset to color information
-         * */
-        void
-        setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg)
-        {
-          assert (beginIdx_arg <= endIdx_arg);
-
-          // amount of points to be decoded
-          unsigned int pointCount = static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
-
-          // iterate over points
-          for (std::size_t i = 0; i < pointCount; i++)
-          {
-            char* idxPointPtr = reinterpret_cast<char*> (&outputCloud_arg->points[beginIdx_arg + i]);
-            int& pointColor = *reinterpret_cast<int*> (idxPointPtr+rgba_offset_arg);
-            // assign color to point from point cloud
-            pointColor = defaultColor_;
-          }
-        }
-
-
-      protected:
-
-        /** \brief Pointer to output point cloud dataset. */
-        PointCloudPtr output_;
-
-        /** \brief Vector for storing average color information  */
-        std::vector<char> pointAvgColorDataVector_;
-
-        /** \brief Iterator on average color information vector */
-        std::vector<char>::const_iterator pointAvgColorDataVector_Iterator_;
-
-        /** \brief Vector for storing differential color information  */
-        std::vector<char> pointDiffColorDataVector_;
-
-        /** \brief Iterator on differential color information vector */
-        std::vector<char>::const_iterator pointDiffColorDataVector_Iterator_;
-
-        /** \brief Amount of bits to be removed from color components before encoding */
-        unsigned char colorBitReduction_;
-
-        // frame header identifier
-        static const int defaultColor_;
-
-      };
-
-    // define default color
-    template<typename PointT>
-    const int ColorCoding<PointT>::defaultColor_ = ((255) << 0) |
-                                                   ((255) << 8) |
-                                                   ((255) << 16);
+  }
 
+  /** \brief Decode color information
+    * \param outputCloud_arg output point cloud
+    * \param beginIdx_arg index indicating first point to be assigned with color information
+    * \param endIdx_arg index indicating last point to be assigned with color information
+    * \param rgba_offset_arg offset to color information
+    */
+  void
+  decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg)
+  {
+    assert (beginIdx_arg <= endIdx_arg);
+
+    // amount of points to be decoded
+    unsigned int pointCount = static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
+
+    // get averaged color information for current voxel
+    unsigned char avgRed = *(pointAvgColorDataVector_Iterator_++);
+    unsigned char avgGreen = *(pointAvgColorDataVector_Iterator_++);
+    unsigned char avgBlue = *(pointAvgColorDataVector_Iterator_++);
+
+    // invert bit shifts during encoding
+    avgRed = static_cast<unsigned char> (avgRed << colorBitReduction_);
+    avgGreen = static_cast<unsigned char> (avgGreen << colorBitReduction_);
+    avgBlue = static_cast<unsigned char> (avgBlue << colorBitReduction_);
+
+    // iterate over points
+    for (std::size_t i = 0; i < pointCount; i++)
+    {
+      unsigned int colorInt;
+      if (pointCount > 1)
+      {
+        // get differential color information from input vector
+        unsigned char diffRed   = static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
+        unsigned char diffGreen = static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
+        unsigned char diffBlue  = static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
+
+        // invert bit shifts during encoding
+        diffRed = static_cast<unsigned char> (diffRed << colorBitReduction_);
+        diffGreen = static_cast<unsigned char> (diffGreen << colorBitReduction_);
+        diffBlue = static_cast<unsigned char> (diffBlue << colorBitReduction_);
+
+        // decode color information
+        colorInt = ((avgRed ^ diffRed) << 0) |
+                   ((avgGreen ^ diffGreen) << 8) |
+                   ((avgBlue ^ diffBlue) << 16);
+      }
+      else
+      {
+        // decode color information
+        colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
+      }
+
+      char* idxPointPtr = reinterpret_cast<char*> (&outputCloud_arg->points[beginIdx_arg + i]);
+      int& pointColor = *reinterpret_cast<int*> (idxPointPtr+rgba_offset_arg);
+      // assign color to point from point cloud
+      pointColor=colorInt;
+    }
+  }
+
+  /** \brief Set default color to points
+   * \param outputCloud_arg output point cloud
+   * \param beginIdx_arg index indicating first point to be assigned with color information
+   * \param endIdx_arg index indicating last point to be assigned with color information
+   * \param rgba_offset_arg offset to color information
+   * */
+  void
+  setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg)
+  {
+    assert (beginIdx_arg <= endIdx_arg);
+
+    // amount of points to be decoded
+    unsigned int pointCount = static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
+
+    // iterate over points
+    for (std::size_t i = 0; i < pointCount; i++)
+    {
+      char* idxPointPtr = reinterpret_cast<char*> (&outputCloud_arg->points[beginIdx_arg + i]);
+      int& pointColor = *reinterpret_cast<int*> (idxPointPtr+rgba_offset_arg);
+      // assign color to point from point cloud
+      pointColor = defaultColor_;
+    }
   }
-}
+
+protected:
+  /** \brief Pointer to output point cloud dataset. */
+  PointCloudPtr output_;
+
+  /** \brief Vector for storing average color information  */
+  std::vector<char> pointAvgColorDataVector_;
+
+  /** \brief Iterator on average color information vector */
+  std::vector<char>::const_iterator pointAvgColorDataVector_Iterator_;
+
+  /** \brief Vector for storing differential color information  */
+  std::vector<char> pointDiffColorDataVector_;
+
+  /** \brief Iterator on differential color information vector */
+  std::vector<char>::const_iterator pointDiffColorDataVector_Iterator_;
+
+  /** \brief Amount of bits to be removed from color components before encoding */
+  unsigned char colorBitReduction_;
+
+  // frame header identifier
+  static const int defaultColor_;
+};
+
+// define default color
+template<typename PointT>
+const int ColorCoding<PointT>::defaultColor_ = ((255) << 0) |
+                                               ((255) << 8) |
+                                               ((255) << 16);
+
+} // namespace octree
+} // namespace pcl
 
 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;
+
index 34adb11f8d695557e25160509016e2a74593e3ee..74bfcfe585c7255e3bfa668ca4490aec5a3c4098 100644 (file)
@@ -170,7 +170,7 @@ namespace pcl
        * \param n_arg: some value
        * \return binary logarithm (log2) of argument n_arg
        */
-      PCL_DEPRECATED("use std::log2 instead")
+      PCL_DEPRECATED(1, 12, "use std::log2 instead")
       inline double
       Log2 (double n_arg)
       {
index 541d7253d089631e34a69be36f6541c43cc1591a..70330e1b56e5816ab4f562aefff8ce67da05117a 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 
 #include <vector>
 #include <limits>
 
 namespace pcl
 {
-  namespace io
-  {
+namespace io
+{
 
-    template<typename PointT> struct CompressionPointTraits
-    {
-        static const bool hasColor = false;
-        static const unsigned int channels = 1;
-        static const std::size_t bytesPerPoint = 3 * sizeof(float);
-    };
+template<typename PointT> struct CompressionPointTraits
+{
+    static const bool hasColor = false;
+    static const unsigned int channels = 1;
+    static const std::size_t bytesPerPoint = 3 * sizeof(float);
+};
 
-    template<>
-    struct CompressionPointTraits<PointXYZRGB>
-    {
-        static const bool hasColor = true;
-        static const unsigned int channels = 4;
-        static const std::size_t bytesPerPoint = 3 * sizeof(float) + 3 * sizeof(std::uint8_t);
-    };
+template<>
+struct CompressionPointTraits<PointXYZRGB>
+{
+    static const bool hasColor = true;
+    static const unsigned int channels = 4;
+    static const std::size_t bytesPerPoint = 3 * sizeof(float) + 3 * sizeof(std::uint8_t);
+};
 
-    template<>
-    struct CompressionPointTraits<PointXYZRGBA>
-    {
-        static const bool hasColor = true;
-        static const unsigned int channels = 4;
-        static const std::size_t bytesPerPoint = 3 * sizeof(float) + 3 * sizeof(std::uint8_t);
-    };
-
-    //////////////////////////////////////////////////////////////////////////////////////////////
-    template <typename PointT, bool enableColor = CompressionPointTraits<PointT>::hasColor >
-    struct OrganizedConversion;
-
-    //////////////////////////////////////////////////////////////////////////////////////////////
-    // Uncolored point cloud specialization
-    //////////////////////////////////////////////////////////////////////////////////////////////
-    template<typename PointT>
-    struct OrganizedConversion<PointT, false>
-    {
-      /** \brief Convert point cloud to disparity image
-        * \param[in] cloud_arg input point cloud
-        * \param[in] focalLength_arg focal length
-        * \param[in] disparityShift_arg disparity shift
-        * \param[in] disparityScale_arg disparity scaling
-        * \param[out] disparityData_arg output disparity image
-        * \ingroup io
-        */
-      static void convert(const pcl::PointCloud<PointT>& cloud_arg,
-                          float focalLength_arg,
-                          float disparityShift_arg,
-                          float disparityScale_arg,
-                          bool ,
-                          typename std::vector<std::uint16_t>& disparityData_arg,
-                          typename std::vector<std::uint8_t>&)
-      {
-        std::size_t cloud_size = cloud_arg.points.size ();
+template<>
+struct CompressionPointTraits<PointXYZRGBA>
+{
+    static const bool hasColor = true;
+    static const unsigned int channels = 4;
+    static const std::size_t bytesPerPoint = 3 * sizeof(float) + 3 * sizeof(std::uint8_t);
+};
 
-        // Clear image data
-        disparityData_arg.clear ();
+template <typename PointT, bool enableColor = CompressionPointTraits<PointT>::hasColor >
+struct OrganizedConversion;
 
-        disparityData_arg.reserve (cloud_size);
+// Uncolored point cloud specialization
+template<typename PointT>
+struct OrganizedConversion<PointT, false>
+{
+  /** \brief Convert point cloud to disparity image
+    * \param[in] cloud_arg input point cloud
+    * \param[in] focalLength_arg focal length
+    * \param[in] disparityShift_arg disparity shift
+    * \param[in] disparityScale_arg disparity scaling
+    * \param[out] disparityData_arg output disparity image
+    * \ingroup io
+    */
+  static void convert(const pcl::PointCloud<PointT>& cloud_arg,
+                      float focalLength_arg,
+                      float disparityShift_arg,
+                      float disparityScale_arg,
+                      bool ,
+                      typename std::vector<std::uint16_t>& disparityData_arg,
+                      typename std::vector<std::uint8_t>&)
+  {
+    std::size_t cloud_size = cloud_arg.points.size ();
 
-        for (std::size_t i = 0; i < cloud_size; ++i)
-        {
-          // Get point from cloud
-          const PointT& point = cloud_arg.points[i];
+    // Clear image data
+    disparityData_arg.clear ();
 
-          if (pcl::isFinite (point))
-          {
-            // Inverse depth quantization
-            std::uint16_t disparity = static_cast<std::uint16_t> ( focalLength_arg / (disparityScale_arg * point.z) + disparityShift_arg / disparityScale_arg);
-            disparityData_arg.push_back (disparity);
-          }
-          else
-          {
-            // Non-valid points are encoded with zeros
-            disparityData_arg.push_back (0);
-          }
-        }
-      }
+    disparityData_arg.reserve (cloud_size);
 
-      /** \brief Convert disparity image to point cloud
-        * \param[in] disparityData_arg input depth image
-        * \param[in] width_arg width of disparity image
-        * \param[in] height_arg height of disparity image
-        * \param[in] focalLength_arg focal length
-        * \param[in] disparityShift_arg disparity shift
-        * \param[in] disparityScale_arg disparity scaling
-        * \param[out] cloud_arg output point cloud
-        * \ingroup io
-        */
-      static void convert(typename std::vector<std::uint16_t>& disparityData_arg,
-                          typename std::vector<std::uint8_t>&,
-                          bool,
-                          std::size_t width_arg,
-                          std::size_t height_arg,
-                          float focalLength_arg,
-                          float disparityShift_arg,
-                          float disparityScale_arg,
-                          pcl::PointCloud<PointT>& cloud_arg)
+    for (std::size_t i = 0; i < cloud_size; ++i)
+    {
+      // Get point from cloud
+      const PointT& point = cloud_arg.points[i];
+
+      if (pcl::isFinite (point))
       {
-        std::size_t cloud_size = width_arg * height_arg;
+        // Inverse depth quantization
+        std::uint16_t disparity = static_cast<std::uint16_t> ( focalLength_arg / (disparityScale_arg * point.z) + disparityShift_arg / disparityScale_arg);
+        disparityData_arg.push_back (disparity);
+      }
+      else
+      {
+        // Non-valid points are encoded with zeros
+        disparityData_arg.push_back (0);
+      }
+    }
+  }
 
-        assert(disparityData_arg.size()==cloud_size);
+  /** \brief Convert disparity image to point cloud
+    * \param[in] disparityData_arg input depth image
+    * \param[in] width_arg width of disparity image
+    * \param[in] height_arg height of disparity image
+    * \param[in] focalLength_arg focal length
+    * \param[in] disparityShift_arg disparity shift
+    * \param[in] disparityScale_arg disparity scaling
+    * \param[out] cloud_arg output point cloud
+    * \ingroup io
+    */
+  static void convert(typename std::vector<std::uint16_t>& disparityData_arg,
+                      typename std::vector<std::uint8_t>&,
+                      bool,
+                      std::size_t width_arg,
+                      std::size_t height_arg,
+                      float focalLength_arg,
+                      float disparityShift_arg,
+                      float disparityScale_arg,
+                      pcl::PointCloud<PointT>& cloud_arg)
+  {
+    std::size_t cloud_size = width_arg * height_arg;
 
-        // Reset point cloud
-        cloud_arg.points.clear ();
-        cloud_arg.points.reserve (cloud_size);
+    assert(disparityData_arg.size()==cloud_size);
 
-        // Define point cloud parameters
-        cloud_arg.width = static_cast<std::uint32_t> (width_arg);
-        cloud_arg.height = static_cast<std::uint32_t> (height_arg);
-        cloud_arg.is_dense = false;
+    // Reset point cloud
+    cloud_arg.points.clear ();
+    cloud_arg.points.reserve (cloud_size);
 
-        // Calculate center of disparity image
-        int centerX = static_cast<int> (width_arg / 2);
-        int centerY = static_cast<int> (height_arg / 2);
+    // Define point cloud parameters
+    cloud_arg.width = static_cast<std::uint32_t> (width_arg);
+    cloud_arg.height = static_cast<std::uint32_t> (height_arg);
+    cloud_arg.is_dense = false;
 
-        const float fl_const = 1.0f / focalLength_arg;
-        static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
+    // Calculate center of disparity image
+    int centerX = static_cast<int> (width_arg / 2);
+    int centerY = static_cast<int> (height_arg / 2);
 
-        std::size_t i = 0;
-        for (int y = -centerY; y < centerY; ++y )
-          for (int x = -centerX; x < centerX; ++x )
-          {
-            PointT newPoint;
-            const std::uint16_t& pixel_disparity = disparityData_arg[i];
-            ++i;
+    const float fl_const = 1.0f / focalLength_arg;
+    static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
 
-            if (pixel_disparity)
-            {
-              // Inverse depth decoding
-              float depth = focalLength_arg / (static_cast<float> (pixel_disparity) * disparityScale_arg + disparityShift_arg);
+    std::size_t i = 0;
+    for (int y = -centerY; y < centerY; ++y )
+      for (int x = -centerX; x < centerX; ++x )
+      {
+        PointT newPoint;
+        const std::uint16_t& pixel_disparity = disparityData_arg[i];
+        ++i;
 
-              // Generate new points
-              newPoint.x = static_cast<float> (x) * depth * fl_const;
-              newPoint.y = static_cast<float> (y) * depth * fl_const;
-              newPoint.z = depth;
+        if (pixel_disparity)
+        {
+          // Inverse depth decoding
+          float depth = focalLength_arg / (static_cast<float> (pixel_disparity) * disparityScale_arg + disparityShift_arg);
 
-            }
-            else
-            {
-              // Generate bad point
-              newPoint.x = newPoint.y = newPoint.z = bad_point;
-            }
+          // Generate new points
+          newPoint.x = static_cast<float> (x) * depth * fl_const;
+          newPoint.y = static_cast<float> (y) * depth * fl_const;
+          newPoint.z = depth;
 
-            cloud_arg.points.push_back (newPoint);
-          }
+        }
+        else
+        {
+          // Generate bad point
+          newPoint.x = newPoint.y = newPoint.z = bad_point;
+        }
 
+        cloud_arg.points.push_back (newPoint);
       }
+  }
 
+  /** \brief Convert disparity image to point cloud
+    * \param[in] depthData_arg input depth image
+    * \param[in] width_arg width of disparity image
+    * \param[in] height_arg height of disparity image
+    * \param[in] focalLength_arg focal length
+    * \param[out] cloud_arg output point cloud
+    * \ingroup io
+    */
+  static void convert(typename std::vector<float>& depthData_arg,
+                      typename std::vector<std::uint8_t>&,
+                      bool,
+                      std::size_t width_arg,
+                      std::size_t height_arg,
+                      float focalLength_arg,
+                      pcl::PointCloud<PointT>& cloud_arg)
+  {
+    std::size_t cloud_size = width_arg * height_arg;
 
-      /** \brief Convert disparity image to point cloud
-        * \param[in] depthData_arg input depth image
-        * \param[in] width_arg width of disparity image
-        * \param[in] height_arg height of disparity image
-        * \param[in] focalLength_arg focal length
-        * \param[out] cloud_arg output point cloud
-        * \ingroup io
-        */
-      static void convert(typename std::vector<float>& depthData_arg,
-                          typename std::vector<std::uint8_t>&,
-                          bool,
-                          std::size_t width_arg,
-                          std::size_t height_arg,
-                          float focalLength_arg,
-                          pcl::PointCloud<PointT>& cloud_arg)
-      {
-        std::size_t cloud_size = width_arg * height_arg;
-
-        assert(depthData_arg.size()==cloud_size);
-
-        // Reset point cloud
-        cloud_arg.points.clear ();
-        cloud_arg.points.reserve (cloud_size);
+    assert(depthData_arg.size()==cloud_size);
 
-        // Define point cloud parameters
-        cloud_arg.width = static_cast<std::uint32_t> (width_arg);
-        cloud_arg.height = static_cast<std::uint32_t> (height_arg);
-        cloud_arg.is_dense = false;
+    // Reset point cloud
+    cloud_arg.points.clear ();
+    cloud_arg.points.reserve (cloud_size);
 
-        // Calculate center of disparity image
-        int centerX = static_cast<int> (width_arg / 2);
-        int centerY = static_cast<int> (height_arg / 2);
+    // Define point cloud parameters
+    cloud_arg.width = static_cast<std::uint32_t> (width_arg);
+    cloud_arg.height = static_cast<std::uint32_t> (height_arg);
+    cloud_arg.is_dense = false;
 
-        const float fl_const = 1.0f / focalLength_arg;
-        static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
+    // Calculate center of disparity image
+    int centerX = static_cast<int> (width_arg / 2);
+    int centerY = static_cast<int> (height_arg / 2);
 
-        std::size_t i = 0;
-        for (int y = -centerY; y < centerY; ++y )
-          for (int x = -centerX; x < centerX; ++x )
-          {
-            PointT newPoint;
-            const float& pixel_depth = depthData_arg[i];
-            ++i;
+    const float fl_const = 1.0f / focalLength_arg;
+    static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
 
-            if (pixel_depth)
-            {
-              // Inverse depth decoding
-              float depth = focalLength_arg / pixel_depth;
+    std::size_t i = 0;
+    for (int y = -centerY; y < centerY; ++y )
+      for (int x = -centerX; x < centerX; ++x )
+      {
+        PointT newPoint;
+        const float& pixel_depth = depthData_arg[i];
+        ++i;
 
-              // Generate new points
-              newPoint.x = static_cast<float> (x) * depth * fl_const;
-              newPoint.y = static_cast<float> (y) * depth * fl_const;
-              newPoint.z = depth;
+        if (pixel_depth)
+        {
+          // Inverse depth decoding
+          float depth = focalLength_arg / pixel_depth;
 
-            }
-            else
-            {
-              // Generate bad point
-              newPoint.x = newPoint.y = newPoint.z = bad_point;
-            }
+          // Generate new points
+          newPoint.x = static_cast<float> (x) * depth * fl_const;
+          newPoint.y = static_cast<float> (y) * depth * fl_const;
+          newPoint.z = depth;
 
-            cloud_arg.points.push_back (newPoint);
-          }
+        }
+        else
+        {
+          // Generate bad point
+          newPoint.x = newPoint.y = newPoint.z = bad_point;
+        }
 
+        cloud_arg.points.push_back (newPoint);
       }
+  }
+};
+
+// Colored point cloud specialization
+template <typename PointT>
+struct OrganizedConversion<PointT, true>
+{
+  /** \brief Convert point cloud to disparity image and rgb image
+    * \param[in] cloud_arg input point cloud
+    * \param[in] focalLength_arg focal length
+    * \param[in] disparityShift_arg disparity shift
+    * \param[in] disparityScale_arg disparity scaling
+    * \param[in] convertToMono convert color to mono/grayscale
+    * \param[out] disparityData_arg output disparity image
+    * \param[out] rgbData_arg output rgb image
+    * \ingroup io
+    */
+  static void convert(const pcl::PointCloud<PointT>& cloud_arg,
+                      float focalLength_arg,
+                      float disparityShift_arg,
+                      float disparityScale_arg,
+                      bool convertToMono,
+                      typename std::vector<std::uint16_t>& disparityData_arg,
+                      typename std::vector<std::uint8_t>& rgbData_arg)
+  {
+    std::size_t cloud_size = cloud_arg.points.size ();
 
-    };
+    // Reset output vectors
+    disparityData_arg.clear ();
+    rgbData_arg.clear ();
 
-    //////////////////////////////////////////////////////////////////////////////////////////////
-    // Colored point cloud specialization
-    //////////////////////////////////////////////////////////////////////////////////////////////
-    template <typename PointT>
-    struct OrganizedConversion<PointT, true>
+    // Allocate memory
+    disparityData_arg.reserve (cloud_size);
+    if (convertToMono)
     {
-      /** \brief Convert point cloud to disparity image and rgb image
-        * \param[in] cloud_arg input point cloud
-        * \param[in] focalLength_arg focal length
-        * \param[in] disparityShift_arg disparity shift
-        * \param[in] disparityScale_arg disparity scaling
-        * \param[in] convertToMono convert color to mono/grayscale
-        * \param[out] disparityData_arg output disparity image
-        * \param[out] rgbData_arg output rgb image
-        * \ingroup io
-        */
-      static void convert(const pcl::PointCloud<PointT>& cloud_arg,
-                          float focalLength_arg,
-                          float disparityShift_arg,
-                          float disparityScale_arg,
-                          bool convertToMono,
-                          typename std::vector<std::uint16_t>& disparityData_arg,
-                          typename std::vector<std::uint8_t>& rgbData_arg)
-      {
-        std::size_t cloud_size = cloud_arg.points.size ();
+      rgbData_arg.reserve (cloud_size);
+    } else
+    {
+      rgbData_arg.reserve (cloud_size * 3);
+    }
 
-        // Reset output vectors
-        disparityData_arg.clear ();
-        rgbData_arg.clear ();
+    for (std::size_t i = 0; i < cloud_size; ++i)
+    {
+      const PointT& point = cloud_arg.points[i];
 
-        // Allocate memory
-        disparityData_arg.reserve (cloud_size);
+      if (pcl::isFinite (point))
+      {
         if (convertToMono)
         {
-          rgbData_arg.reserve (cloud_size);
+          // Encode point color
+          std::uint8_t grayvalue = static_cast<std::uint8_t>(0.2989 * point.r
+                                                    + 0.5870 * point.g
+                                                    + 0.1140 * point.b);
+
+          rgbData_arg.push_back (grayvalue);
         } else
         {
-          rgbData_arg.reserve (cloud_size * 3);
+          // Encode point color
+          rgbData_arg.push_back (point.r);
+          rgbData_arg.push_back (point.g);
+          rgbData_arg.push_back (point.b);
         }
 
+        // Inverse depth quantization
+        std::uint16_t disparity = static_cast<std::uint16_t> (focalLength_arg / (disparityScale_arg * point.z) + disparityShift_arg / disparityScale_arg);
 
-        for (std::size_t i = 0; i < cloud_size; ++i)
+        // Encode disparity
+        disparityData_arg.push_back (disparity);
+      }
+      else
+      {
+        // Encode black point
+        if (convertToMono)
         {
-          const PointT& point = cloud_arg.points[i];
-
-          if (pcl::isFinite (point))
-          {
-            if (convertToMono)
-            {
-              // Encode point color
-              std::uint8_t grayvalue = static_cast<std::uint8_t>(0.2989 * point.r
-                                                        + 0.5870 * point.g
-                                                        + 0.1140 * point.b);
+          rgbData_arg.push_back (0);
+        } else
+        {
+          rgbData_arg.push_back (0);
+          rgbData_arg.push_back (0);
+          rgbData_arg.push_back (0);
+        }
 
-              rgbData_arg.push_back (grayvalue);
-            } else
-            {
-              // Encode point color
-              rgbData_arg.push_back (point.r);
-              rgbData_arg.push_back (point.g);
-              rgbData_arg.push_back (point.b);
-            }
+        // Encode bad point
+        disparityData_arg.push_back (0);
+      }
+    }
+  }
 
+  /** \brief Convert disparity image to point cloud
+    * \param[in] disparityData_arg output disparity image
+    * \param[in] rgbData_arg output rgb image
+    * \param[in] monoImage_arg input image is a single-channel mono image
+    * \param[in] width_arg width of disparity image
+    * \param[in] height_arg height of disparity image
+    * \param[in] focalLength_arg focal length
+    * \param[in] disparityShift_arg disparity shift
+    * \param[in] disparityScale_arg disparity scaling
+    * \param[out] cloud_arg output point cloud
+    * \ingroup io
+    */
+  static void convert(typename std::vector<std::uint16_t>& disparityData_arg,
+                      typename std::vector<std::uint8_t>& rgbData_arg,
+                      bool monoImage_arg,
+                      std::size_t width_arg,
+                      std::size_t height_arg,
+                      float focalLength_arg,
+                      float disparityShift_arg,
+                      float disparityScale_arg,
+                      pcl::PointCloud<PointT>& cloud_arg)
+  {
+    std::size_t cloud_size = width_arg*height_arg;
+    bool hasColor = (!rgbData_arg.empty ());
 
-            // Inverse depth quantization
-            std::uint16_t disparity = static_cast<std::uint16_t> (focalLength_arg / (disparityScale_arg * point.z) + disparityShift_arg / disparityScale_arg);
+    // Check size of input data
+    assert (disparityData_arg.size()==cloud_size);
+    if (hasColor)
+    {
+      if (monoImage_arg)
+      {
+        assert (rgbData_arg.size()==cloud_size);
+      } else
+      {
+        assert (rgbData_arg.size()==cloud_size*3);
+      }
+    }
 
-            // Encode disparity
-            disparityData_arg.push_back (disparity);
-          }
-          else
-          {
+    // Reset point cloud
+    cloud_arg.points.clear();
+    cloud_arg.points.reserve(cloud_size);
 
-            // Encode black point
-            if (convertToMono)
-            {
-              rgbData_arg.push_back (0);
-            } else
-            {
-              rgbData_arg.push_back (0);
-              rgbData_arg.push_back (0);
-              rgbData_arg.push_back (0);
-            }
+    // Define point cloud parameters
+    cloud_arg.width = static_cast<std::uint32_t>(width_arg);
+    cloud_arg.height = static_cast<std::uint32_t>(height_arg);
+    cloud_arg.is_dense = false;
 
-            // Encode bad point
-            disparityData_arg.push_back (0);
-          }
-        }
+    // Calculate center of disparity image
+    int centerX = static_cast<int>(width_arg/2);
+    int centerY = static_cast<int>(height_arg/2);
 
-      }
+    const float fl_const = 1.0f/focalLength_arg;
+    static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
 
-      /** \brief Convert disparity image to point cloud
-        * \param[in] disparityData_arg output disparity image
-        * \param[in] rgbData_arg output rgb image
-        * \param[in] monoImage_arg input image is a single-channel mono image
-        * \param[in] width_arg width of disparity image
-        * \param[in] height_arg height of disparity image
-        * \param[in] focalLength_arg focal length
-        * \param[in] disparityShift_arg disparity shift
-        * \param[in] disparityScale_arg disparity scaling
-        * \param[out] cloud_arg output point cloud
-        * \ingroup io
-        */
-      static void convert(typename std::vector<std::uint16_t>& disparityData_arg,
-                          typename std::vector<std::uint8_t>& rgbData_arg,
-                          bool monoImage_arg,
-                          std::size_t width_arg,
-                          std::size_t height_arg,
-                          float focalLength_arg,
-                          float disparityShift_arg,
-                          float disparityScale_arg,
-                          pcl::PointCloud<PointT>& cloud_arg)
+    std::size_t i = 0;
+    for (int y = -centerY; y < centerY; ++y )
+      for (int x = -centerX; x < centerX; ++x )
       {
-        std::size_t cloud_size = width_arg*height_arg;
-        bool hasColor = (!rgbData_arg.empty ());
-
-        // Check size of input data
-        assert (disparityData_arg.size()==cloud_size);
-        if (hasColor)
-        {
-          if (monoImage_arg)
-          {
-            assert (rgbData_arg.size()==cloud_size);
-          } else
-          {
-            assert (rgbData_arg.size()==cloud_size*3);
-          }
-        }
-
-        // Reset point cloud
-        cloud_arg.points.clear();
-        cloud_arg.points.reserve(cloud_size);
+        PointT newPoint;
 
-        // Define point cloud parameters
-        cloud_arg.width = static_cast<std::uint32_t>(width_arg);
-        cloud_arg.height = static_cast<std::uint32_t>(height_arg);
-        cloud_arg.is_dense = false;
+        const std::uint16_t& pixel_disparity = disparityData_arg[i];
 
-        // Calculate center of disparity image
-        int centerX = static_cast<int>(width_arg/2);
-        int centerY = static_cast<int>(height_arg/2);
+        if (pixel_disparity && (pixel_disparity!=0x7FF))
+        {
+          float depth = focalLength_arg / (static_cast<float> (pixel_disparity) * disparityScale_arg + disparityShift_arg);
 
-        const float fl_const = 1.0f/focalLength_arg;
-        static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
+          // Define point location
+          newPoint.z = depth;
+          newPoint.x = static_cast<float> (x) * depth * fl_const;
+          newPoint.y = static_cast<float> (y) * depth * fl_const;
 
-        std::size_t i = 0;
-        for (int y = -centerY; y < centerY; ++y )
-          for (int x = -centerX; x < centerX; ++x )
+          if (hasColor)
           {
-            PointT newPoint;
-
-            const std::uint16_t& pixel_disparity = disparityData_arg[i];
-
-            if (pixel_disparity && (pixel_disparity!=0x7FF))
+            if (monoImage_arg)
             {
-              float depth = focalLength_arg / (static_cast<float> (pixel_disparity) * disparityScale_arg + disparityShift_arg);
-
-              // Define point location
-              newPoint.z = depth;
-              newPoint.x = static_cast<float> (x) * depth * fl_const;
-              newPoint.y = static_cast<float> (y) * depth * fl_const;
-
-              if (hasColor)
-              {
-                if (monoImage_arg)
-                {
-                  // Define point color
-                  newPoint.r = rgbData_arg[i];
-                  newPoint.g = rgbData_arg[i];
-                  newPoint.b = rgbData_arg[i];
-                } else
-                {
-                  // Define point color
-                  newPoint.r = rgbData_arg[i*3+0];
-                  newPoint.g = rgbData_arg[i*3+1];
-                  newPoint.b = rgbData_arg[i*3+2];
-                }
-
-              } else
-              {
-                // Set white point color
-                newPoint.rgba = 0xffffffffu;
-              }
+              // Define point color
+              newPoint.r = rgbData_arg[i];
+              newPoint.g = rgbData_arg[i];
+              newPoint.b = rgbData_arg[i];
             } else
             {
-              // Define bad point
-              newPoint.x = newPoint.y = newPoint.z = bad_point;
-              newPoint.rgb = 0.0f;
+              // Define point color
+              newPoint.r = rgbData_arg[i*3+0];
+              newPoint.g = rgbData_arg[i*3+1];
+              newPoint.b = rgbData_arg[i*3+2];
             }
 
-            // Add point to cloud
-            cloud_arg.points.push_back(newPoint);
-            // Increment point iterator
-            ++i;
-        }
-      }
-
-      /** \brief Convert disparity image to point cloud
-        * \param[in] depthData_arg output disparity image
-        * \param[in] rgbData_arg output rgb image
-        * \param[in] monoImage_arg input image is a single-channel mono image
-        * \param[in] width_arg width of disparity image
-        * \param[in] height_arg height of disparity image
-        * \param[in] focalLength_arg focal length
-        * \param[out] cloud_arg output point cloud
-        * \ingroup io
-        */
-      static void convert(typename std::vector<float>& depthData_arg,
-                          typename std::vector<std::uint8_t>& rgbData_arg,
-                          bool monoImage_arg,
-                          std::size_t width_arg,
-                          std::size_t height_arg,
-                          float focalLength_arg,
-                          pcl::PointCloud<PointT>& cloud_arg)
-      {
-        std::size_t cloud_size = width_arg*height_arg;
-        bool hasColor = (!rgbData_arg.empty ());
-
-        // Check size of input data
-        assert (depthData_arg.size()==cloud_size);
-        if (hasColor)
-        {
-          if (monoImage_arg)
-          {
-            assert (rgbData_arg.size()==cloud_size);
           } else
           {
-            assert (rgbData_arg.size()==cloud_size*3);
+            // Set white point color
+            newPoint.rgba = 0xffffffffu;
           }
+        } else
+        {
+          // Define bad point
+          newPoint.x = newPoint.y = newPoint.z = bad_point;
+          newPoint.rgb = 0.0f;
         }
 
-        // Reset point cloud
-        cloud_arg.points.clear();
-        cloud_arg.points.reserve(cloud_size);
+        // Add point to cloud
+        cloud_arg.points.push_back(newPoint);
+        // Increment point iterator
+        ++i;
+    }
+  }
 
-        // Define point cloud parameters
-        cloud_arg.width = static_cast<std::uint32_t>(width_arg);
-        cloud_arg.height = static_cast<std::uint32_t>(height_arg);
-        cloud_arg.is_dense = false;
+  /** \brief Convert disparity image to point cloud
+    * \param[in] depthData_arg output disparity image
+    * \param[in] rgbData_arg output rgb image
+    * \param[in] monoImage_arg input image is a single-channel mono image
+    * \param[in] width_arg width of disparity image
+    * \param[in] height_arg height of disparity image
+    * \param[in] focalLength_arg focal length
+    * \param[out] cloud_arg output point cloud
+    * \ingroup io
+    */
+  static void convert(typename std::vector<float>& depthData_arg,
+                      typename std::vector<std::uint8_t>& rgbData_arg,
+                      bool monoImage_arg,
+                      std::size_t width_arg,
+                      std::size_t height_arg,
+                      float focalLength_arg,
+                      pcl::PointCloud<PointT>& cloud_arg)
+  {
+    std::size_t cloud_size = width_arg*height_arg;
+    bool hasColor = (!rgbData_arg.empty ());
 
-        // Calculate center of disparity image
-        int centerX = static_cast<int>(width_arg/2);
-        int centerY = static_cast<int>(height_arg/2);
+    // Check size of input data
+    assert (depthData_arg.size()==cloud_size);
+    if (hasColor)
+    {
+      if (monoImage_arg)
+      {
+        assert (rgbData_arg.size()==cloud_size);
+      } else
+      {
+        assert (rgbData_arg.size()==cloud_size*3);
+      }
+    }
 
-        const float fl_const = 1.0f/focalLength_arg;
-        static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
+    // Reset point cloud
+    cloud_arg.points.clear();
+    cloud_arg.points.reserve(cloud_size);
 
-        std::size_t i = 0;
-        for (int y = -centerY; y < centerY; ++y )
-          for (int x = -centerX; x < centerX; ++x )
-          {
-            PointT newPoint;
+    // Define point cloud parameters
+    cloud_arg.width = static_cast<std::uint32_t>(width_arg);
+    cloud_arg.height = static_cast<std::uint32_t>(height_arg);
+    cloud_arg.is_dense = false;
 
-            const float& pixel_depth = depthData_arg[i];
+    // Calculate center of disparity image
+    int centerX = static_cast<int>(width_arg/2);
+    int centerY = static_cast<int>(height_arg/2);
 
-            if (pixel_depth==pixel_depth)
+    const float fl_const = 1.0f/focalLength_arg;
+    static const float bad_point = std::numeric_limits<float>::quiet_NaN ();
+
+    std::size_t i = 0;
+    for (int y = -centerY; y < centerY; ++y )
+      for (int x = -centerX; x < centerX; ++x )
+      {
+        PointT newPoint;
+
+        const float& pixel_depth = depthData_arg[i];
+
+        if (pixel_depth==pixel_depth)
+        {
+          float depth = focalLength_arg / pixel_depth;
+
+          // Define point location
+          newPoint.z = depth;
+          newPoint.x = static_cast<float> (x) * depth * fl_const;
+          newPoint.y = static_cast<float> (y) * depth * fl_const;
+
+          if (hasColor)
+          {
+            if (monoImage_arg)
             {
-              float depth = focalLength_arg / pixel_depth;
-
-              // Define point location
-              newPoint.z = depth;
-              newPoint.x = static_cast<float> (x) * depth * fl_const;
-              newPoint.y = static_cast<float> (y) * depth * fl_const;
-
-              if (hasColor)
-              {
-                if (monoImage_arg)
-                {
-                  // Define point color
-                  newPoint.r = rgbData_arg[i];
-                  newPoint.g = rgbData_arg[i];
-                  newPoint.b = rgbData_arg[i];
-                } else
-                {
-                  // Define point color
-                  newPoint.r = rgbData_arg[i*3+0];
-                  newPoint.g = rgbData_arg[i*3+1];
-                  newPoint.b = rgbData_arg[i*3+2];
-                }
-
-              } else
-              {
-                // Set white point color
-                newPoint.rgba = 0xffffffffu;
-              }
+              // Define point color
+              newPoint.r = rgbData_arg[i];
+              newPoint.g = rgbData_arg[i];
+              newPoint.b = rgbData_arg[i];
             } else
             {
-              // Define bad point
-              newPoint.x = newPoint.y = newPoint.z = bad_point;
-              newPoint.rgb = 0.0f;
+              // Define point color
+              newPoint.r = rgbData_arg[i*3+0];
+              newPoint.g = rgbData_arg[i*3+1];
+              newPoint.b = rgbData_arg[i*3+2];
             }
 
-            // Add point to cloud
-            cloud_arg.points.push_back(newPoint);
-            // Increment point iterator
-            ++i;
+          } else
+          {
+            // Set white point color
+            newPoint.rgba = 0xffffffffu;
+          }
+        } else
+        {
+          // Define bad point
+          newPoint.x = newPoint.y = newPoint.z = bad_point;
+          newPoint.rgb = 0.0f;
         }
-      }
-    };
 
+        // Add point to cloud
+        cloud_arg.points.push_back(newPoint);
+        // Increment point iterator
+        ++i;
+    }
   }
-}
+};
+
+} // namespace io
+} // namespace pcl
+
index fe5041a8f61caf19b4ce3e09f02c9cf93294c787..3ff520745eb97bbda1ecc5f4bb17caaa7d88fdc2 100644 (file)
 
 namespace pcl
 {
-  namespace octree
-  {
-    /** \brief @b PointCoding class
-      * \note This class encodes 8-bit differential point information for octree-based point cloud compression.
-      * \note typename: PointT: type of point used in pointcloud
-      * \author Julius Kammerl (julius@kammerl.de)
+namespace octree
+{
+/** \brief @b PointCoding class
+  * \note This class encodes 8-bit differential point information for octree-based point cloud compression.
+  * \note typename: PointT: type of point used in pointcloud
+  * \author Julius Kammerl (julius@kammerl.de)
+  */
+template<typename PointT>
+class PointCoding
+{
+    // public typedefs
+    using PointCloud = pcl::PointCloud<PointT>;
+    using PointCloudPtr = typename PointCloud::Ptr;
+    using PointCloudConstPtr = typename PointCloud::ConstPtr;
+
+  public:
+    /** \brief Constructor. */
+    PointCoding () :
+      output_ (),
+      pointCompressionResolution_ (0.001f) // 1mm
+    {
+    }
+
+    /** \brief Empty class constructor. */
+    virtual
+    ~PointCoding ()
+    {
+    }
+
+    /** \brief Define precision of point information
+      * \param precision_arg: precision
+      */
+    inline void
+    setPrecision (float precision_arg)
+    {
+      pointCompressionResolution_ = precision_arg;
+    }
+
+    /** \brief Retrieve precision of point information
+      * \return precision
       */
-    template<typename PointT>
-    class PointCoding
+    inline float
+    getPrecision ()
     {
-        // public typedefs
-        using PointCloud = pcl::PointCloud<PointT>;
-        using PointCloudPtr = typename PointCloud::Ptr;
-        using PointCloudConstPtr = typename PointCloud::ConstPtr;
-
-      public:
-        /** \brief Constructor. */
-        PointCoding () :
-          output_ (),
-          pointCompressionResolution_ (0.001f) // 1mm
-        {
-        }
-
-        /** \brief Empty class constructor. */
-        virtual
-        ~PointCoding ()
-        {
-        }
-
-        /** \brief Define precision of point information
-          * \param precision_arg: precision
-          */
-        inline void
-        setPrecision (float precision_arg)
-        {
-          pointCompressionResolution_ = precision_arg;
-        }
-
-        /** \brief Retrieve precision of point information
-          * \return precision
-          */
-        inline float
-        getPrecision ()
-        {
-          return (pointCompressionResolution_);
-        }
-
-        /** \brief Set amount of points within point cloud to be encoded and reserve memory
-          * \param pointCount_arg: amounts of points within point cloud
-          */
-        inline void
-        setPointCount (unsigned int pointCount_arg)
-        {
-          pointDiffDataVector_.reserve (pointCount_arg * 3);
-        }
-
-        /** \brief Initialize encoding of differential point */
-        void
-        initializeEncoding ()
-        {
-          pointDiffDataVector_.clear ();
-        }
-
-        /** \brief Initialize decoding of differential point */
-        void
-        initializeDecoding ()
-        {
-          pointDiffDataVectorIterator_ = pointDiffDataVector_.begin ();
-        }
-
-        /** \brief Get reference to vector containing differential color data */
-        std::vector<char>&
-        getDifferentialDataVector ()
-        {
-          return (pointDiffDataVector_);
-        }
-
-        /** \brief Encode differential point information for a subset of points from point cloud
-          * \param indexVector_arg indices defining a subset of points from points cloud
-          * \param referencePoint_arg coordinates of reference point
-          * \param inputCloud_arg input point cloud
-          */
-        void
-        encodePoints (const typename std::vector<int>& indexVector_arg, const double* referencePoint_arg,
-                      PointCloudConstPtr inputCloud_arg)
-        {
-          std::size_t len = indexVector_arg.size ();
-
-          // iterate over points within current voxel
-          for (std::size_t i = 0; i < len; i++)
-          {
-            unsigned char diffX, diffY, diffZ;
-
-            // retrieve point from cloud
-            const int& idx = indexVector_arg[i];
-            const PointT& idxPoint = inputCloud_arg->points[idx];
-
-            // differentially encode point coordinates and truncate overflow
-            diffX = static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.x - referencePoint_arg[0])  / pointCompressionResolution_))));
-            diffY = static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.y - referencePoint_arg[1])  / pointCompressionResolution_))));
-            diffZ = static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.z - referencePoint_arg[2])  / pointCompressionResolution_))));
-
-            // store information in differential point vector
-            pointDiffDataVector_.push_back (diffX);
-            pointDiffDataVector_.push_back (diffY);
-            pointDiffDataVector_.push_back (diffZ);
-          }
-        }
-
-        /** \brief Decode differential point information
-          * \param outputCloud_arg output point cloud
-          * \param referencePoint_arg coordinates of reference point
-          * \param beginIdx_arg index indicating first point to be assigned with color information
-          * \param endIdx_arg index indicating last point to be assigned with color information
-          */
-        void
-        decodePoints (PointCloudPtr outputCloud_arg, const double* referencePoint_arg, std::size_t beginIdx_arg,
-                      std::size_t endIdx_arg)
-        {
-          assert (beginIdx_arg <= endIdx_arg);
-
-          unsigned int pointCount = static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
-
-          // iterate over points within current voxel
-          for (std::size_t i = 0; i < pointCount; i++)
-          {
-            // retrieve differential point information
-            const unsigned char& diffX = static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
-            const unsigned char& diffY = static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
-            const unsigned char& diffZ = static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
-
-            // retrieve point from point cloud
-            PointT& point = outputCloud_arg->points[beginIdx_arg + i];
-
-            // decode point position
-            point.x = static_cast<float> (referencePoint_arg[0] + diffX * pointCompressionResolution_);
-            point.y = static_cast<float> (referencePoint_arg[1] + diffY * pointCompressionResolution_);
-            point.z = static_cast<float> (referencePoint_arg[2] + diffZ * pointCompressionResolution_);
-          }
-        }
-
-      protected:
-        /** \brief Pointer to output point cloud dataset. */
-        PointCloudPtr output_;
-
-        /** \brief Vector for storing differential point information  */
-        std::vector<char> pointDiffDataVector_;
-
-        /** \brief Iterator on differential point information vector */
-        std::vector<char>::const_iterator pointDiffDataVectorIterator_;
-
-        /** \brief Precision of point coding*/
-        float pointCompressionResolution_;
-    };
-  }
-}
+      return (pointCompressionResolution_);
+    }
+
+    /** \brief Set amount of points within point cloud to be encoded and reserve memory
+      * \param pointCount_arg: amounts of points within point cloud
+      */
+    inline void
+    setPointCount (unsigned int pointCount_arg)
+    {
+      pointDiffDataVector_.reserve (pointCount_arg * 3);
+    }
+
+    /** \brief Initialize encoding of differential point */
+    void
+    initializeEncoding ()
+    {
+      pointDiffDataVector_.clear ();
+    }
+
+    /** \brief Initialize decoding of differential point */
+    void
+    initializeDecoding ()
+    {
+      pointDiffDataVectorIterator_ = pointDiffDataVector_.begin ();
+    }
+
+    /** \brief Get reference to vector containing differential color data */
+    std::vector<char>&
+    getDifferentialDataVector ()
+    {
+      return (pointDiffDataVector_);
+    }
+
+    /** \brief Encode differential point information for a subset of points from point cloud
+      * \param indexVector_arg indices defining a subset of points from points cloud
+      * \param referencePoint_arg coordinates of reference point
+      * \param inputCloud_arg input point cloud
+      */
+    void
+    encodePoints (const typename std::vector<int>& indexVector_arg, const double* referencePoint_arg,
+                  PointCloudConstPtr inputCloud_arg)
+    {
+      std::size_t len = indexVector_arg.size ();
+
+      // iterate over points within current voxel
+      for (std::size_t i = 0; i < len; i++)
+      {
+        unsigned char diffX, diffY, diffZ;
+
+        // retrieve point from cloud
+        const int& idx = indexVector_arg[i];
+        const PointT& idxPoint = inputCloud_arg->points[idx];
+
+        // differentially encode point coordinates and truncate overflow
+        diffX = static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.x - referencePoint_arg[0])  / pointCompressionResolution_))));
+        diffY = static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.y - referencePoint_arg[1])  / pointCompressionResolution_))));
+        diffZ = static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.z - referencePoint_arg[2])  / pointCompressionResolution_))));
+
+        // store information in differential point vector
+        pointDiffDataVector_.push_back (diffX);
+        pointDiffDataVector_.push_back (diffY);
+        pointDiffDataVector_.push_back (diffZ);
+      }
+    }
+
+    /** \brief Decode differential point information
+      * \param outputCloud_arg output point cloud
+      * \param referencePoint_arg coordinates of reference point
+      * \param beginIdx_arg index indicating first point to be assigned with color information
+      * \param endIdx_arg index indicating last point to be assigned with color information
+      */
+    void
+    decodePoints (PointCloudPtr outputCloud_arg, const double* referencePoint_arg, std::size_t beginIdx_arg,
+                  std::size_t endIdx_arg)
+    {
+      assert (beginIdx_arg <= endIdx_arg);
+
+      unsigned int pointCount = static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
+
+      // iterate over points within current voxel
+      for (std::size_t i = 0; i < pointCount; i++)
+      {
+        // retrieve differential point information
+        const unsigned char& diffX = static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
+        const unsigned char& diffY = static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
+        const unsigned char& diffZ = static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
+
+        // retrieve point from point cloud
+        PointT& point = outputCloud_arg->points[beginIdx_arg + i];
+
+        // decode point position
+        point.x = static_cast<float> (referencePoint_arg[0] + diffX * pointCompressionResolution_);
+        point.y = static_cast<float> (referencePoint_arg[1] + diffY * pointCompressionResolution_);
+        point.z = static_cast<float> (referencePoint_arg[2] + diffZ * pointCompressionResolution_);
+      }
+    }
+
+  protected:
+    /** \brief Pointer to output point cloud dataset. */
+    PointCloudPtr output_;
+
+    /** \brief Vector for storing differential point information  */
+    std::vector<char> pointDiffDataVector_;
+
+    /** \brief Iterator on differential point information vector */
+    std::vector<char>::const_iterator pointDiffDataVectorIterator_;
+
+    /** \brief Precision of point coding*/
+    float pointCompressionResolution_;
+};
+
+} // namespace octree
+} // namespace pcl
 
 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;
+
index c7ebf40a49af9c7eb1c722e2c36183db905ee6ca..8ba242417541d9a638f473412cf5f90d7ca489bb 100644 (file)
@@ -117,7 +117,7 @@ namespace pcl
         * \param[in] p  a point type
         */
       template<typename PointT>
-      PCL_DEPRECATED("use parameterless setInputFields<PointT>() instead")
+      PCL_DEPRECATED(1, 12, "use parameterless setInputFields<PointT>() instead")
       inline void setInputFields (const PointT p)
       {
         (void) p;
index 395f1949bf461aa8955c044bfacc58a62680ab97..685b36ae8e770fb5eb7a53ed5d73874008ab9830 100644 (file)
@@ -38,7 +38,7 @@
 #pragma once
 
 #if defined __GNUC__
-#  pragma GCC system_header 
+#  pragma GCC system_header
 #endif
 //https://bugreports.qt-project.org/browse/QTBUG-22829
 #ifndef Q_MOC_RUN
@@ -46,8 +46,6 @@
 #include <boost/version.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
 #include <boost/mpl/fold.hpp>
 #include <boost/mpl/inherit.hpp>
 #include <boost/mpl/inherit_linearly.hpp>
index c445e6c0b74cdc352c372e9d82ce49ec05e444a5..e95dd4485eb79fedfbec8b6afc82b9edec09c632 100644 (file)
@@ -169,7 +169,7 @@ namespace pcl
        * @return True if successful, false otherwise
        * @warning A device must be opened and not running */
       bool
-      grabSingleCloud (pcl::PointCloud<pcl::PointXYZ> &cloud);
+      grabSingleCloud (pcl::PointCloud<pcl::PointXYZ> &cloud) const;
 
       /** @brief Set up the Ensenso sensor and API to do 3D extrinsic calibration using the Ensenso 2D patterns
        * @param[in] grid_spacing
@@ -256,7 +256,7 @@ namespace pcl
       setExtrinsicCalibration (const double euler_angle,
                                Eigen::Vector3d &rotation_axis,
                                const Eigen::Vector3d &translation,
-                               const std::string target = "Hand");
+                               const std::string target = "Hand") const;
 
       /** @brief Update Link node in NxLib tree with an identity matrix
        * @param[in] target "Hand" or "Workspace" for example
index b94d42d002ce3ed49c7b8b022ba3e5060aa0f2e9..378b81a8e2f444078d73a25f88aff8dbb55ecdaa 100644 (file)
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
  */
+
 #pragma once
 
 #include <pcl/pcl_config.h>
 
 // needed for the grabber interface / observers
 #include <map>
+#include <memory>
 #include <iostream>
 #include <string>
 #include <typeinfo>
+#include <tuple>
 #include <vector>
 #include <sstream>
 #include <pcl/pcl_macros.h>
@@ -57,8 +59,37 @@ namespace pcl
   class PCL_EXPORTS Grabber
   {
     public:
+      /**
+       * \brief Default ctor
+       */
+      Grabber() = default;
+
+      /**
+       * \brief No copy ctor since Grabber can't be copied
+       */
+      Grabber(const Grabber&) = delete;
+
+      /**
+       * \brief No copy assign operator since Grabber can't be copied
+       */
+      Grabber& operator=(const Grabber&) = delete;
+
+      /**
+       * \brief Move ctor
+       */
+      Grabber(Grabber&&) = default;
+
+      /**
+       * \brief Move assign operator
+       */
+      Grabber& operator=(Grabber&&) = default;
+
       /** \brief virtual destructor. */
-      virtual inline ~Grabber () noexcept;
+      #if defined(_MSC_VER)
+        virtual inline ~Grabber () noexcept {}
+      #else
+        virtual inline ~Grabber () noexcept = default;
+      #endif
 
       /** \brief registers a callback function/method to a signal with the corresponding signature
         * \param[in] callback: the callback function/method
@@ -72,7 +103,7 @@ namespace pcl
         * \return Connection object, that can be used to disconnect the callback method from the signal again.
         */
       template<typename T, template<typename> class FunctionT>
-      PCL_DEPRECATED ("please assign the callback to a std::function.")
+      PCL_DEPRECATED (1, 12, "please assign the callback to a std::function.")
       boost::signals2::connection
       registerCallback (const FunctionT<T>& callback)
       {
@@ -82,19 +113,19 @@ namespace pcl
       /** \brief indicates whether a signal with given parameter-type exists or not
         * \return true if signal exists, false otherwise
         */
-      template<typename T> bool 
-      providesCallback () const;
+      template<typename T> bool
+      providesCallback () const noexcept;
 
       /** \brief For devices that are streaming, the streams are started by calling this method.
         *        Trigger-based devices, just trigger the device once for each call of start.
         */
-      virtual void 
+      virtual void
       start () = 0;
 
       /** \brief For devices that are streaming, the streams are stopped.
         *        This method has no effect for triggered devices.
         */
-      virtual void 
+      virtual void
       stop () = 0;
 
       /** \brief For devices that are streaming, stopped streams are started and running stream are stopped.
@@ -107,17 +138,17 @@ namespace pcl
       /** \brief returns the name of the concrete subclass.
         * \return the name of the concrete driver.
         */
-      virtual std::string 
+      virtual std::string
       getName () const = 0;
 
       /** \brief Indicates whether the grabber is streaming or not. This value is not defined for triggered devices.
         * \return true if grabber is running / streaming. False otherwise.
         */
-      virtual bool 
+      virtual bool
       isRunning () const = 0;
 
       /** \brief returns fps. 0 if trigger based. */
-      virtual float 
+      virtual float
       getFramesPerSecond () const = 0;
 
     protected:
@@ -125,41 +156,35 @@ namespace pcl
       virtual void
       signalsChanged () { }
 
-      template<typename T> boost::signals2::signal<T>* 
-      find_signal () const;
+      template<typename T> boost::signals2::signal<T>*
+      find_signal () const noexcept;
 
-      template<typename T> int 
-      num_slots () const;
+      template<typename T> int
+      num_slots () const noexcept;
 
-      template<typename T> void 
+      template<typename T> void
       disconnect_all_slots ();
 
-      template<typename T> void 
+      template<typename T> void
       block_signal ();
-      
-      template<typename T> void 
+
+      template<typename T> void
       unblock_signal ();
-      
-      inline void 
+
+      inline void
       block_signals ();
-      
-      inline void 
+
+      inline void
       unblock_signals ();
 
-      template<typename T> boost::signals2::signal<T>* 
+      template<typename T> boost::signals2::signal<T>*
       createSignal ();
 
-      std::map<std::string, boost::signals2::signal_base*> signals_;
+      std::map<std::string, std::unique_ptr<boost::signals2::signal_base>> signals_;
       std::map<std::string, std::vector<boost::signals2::connection> > connections_;
       std::map<std::string, std::vector<boost::signals2::shared_connection_block> > shared_connections_;
   } ;
 
-  Grabber::~Grabber () noexcept
-  {
-    for (auto &signal : signals_)
-      delete signal.second;
-  }
-
   bool
   Grabber::toggle ()
   {
@@ -174,25 +199,24 @@ namespace pcl
   }
 
   template<typename T> boost::signals2::signal<T>*
-  Grabber::find_signal () const
+  Grabber::find_signal () const noexcept
   {
     using Signal = boost::signals2::signal<T>;
 
-    std::map<std::string, boost::signals2::signal_base*>::const_iterator signal_it = signals_.find (typeid (T).name ());
+    const auto signal_it = signals_.find (typeid (T).name ());
     if (signal_it != signals_.end ())
-      return (dynamic_cast<Signal*> (signal_it->second));
-
-    return (NULL);
+    {
+      return (static_cast<Signal*> (signal_it->second.get ()));
+    }
+    return nullptr;
   }
 
   template<typename T> void
   Grabber::disconnect_all_slots ()
   {
-    using Signal = boost::signals2::signal<T>;
-
-    if (signals_.find (typeid (T).name ()) != signals_.end ())
+    const auto signal = find_signal<T> ();
+    if (signal != nullptr)
     {
-      Signal* signal = dynamic_cast<Signal*> (signals_[typeid (T).name ()]);
       signal->disconnect_all_slots ();
     }
   }
@@ -230,39 +254,56 @@ namespace pcl
   }
 
   template<typename T> int
-  Grabber::num_slots () const
+  Grabber::num_slots () const noexcept
   {
-    using Signal = boost::signals2::signal<T>;
-
-    // see if we have a signal for this type
-    std::map<std::string, boost::signals2::signal_base*>::const_iterator signal_it = signals_.find (typeid (T).name ());
-    if (signal_it != signals_.end ())
+    const auto signal = find_signal<T> ();
+    if (signal != nullptr)
     {
-      Signal* signal = dynamic_cast<Signal*> (signal_it->second);
-      return (static_cast<int> (signal->num_slots ()));
+      return static_cast<int> (signal->num_slots ());
     }
-    return (0);
+    return 0;
   }
 
   template<typename T> boost::signals2::signal<T>*
   Grabber::createSignal ()
   {
     using Signal = boost::signals2::signal<T>;
-
-    if (signals_.find (typeid (T).name ()) == signals_.end ())
+    using Base = boost::signals2::signal_base;
+    // DefferedPtr serves 2 purposes:
+    // * allows MSVC to copy it around, can't do that with unique_ptr<T>
+    // * performs dynamic allocation only when required. If the key is found, this
+    //   struct is a no-op, otherwise it allocates when implicit conversion operator
+    //   is called inside emplace/try_emplace
+    struct DefferedPtr {
+      operator std::unique_ptr<Base>() const { return std::make_unique<Signal>(); }
+    };
+    // TODO: remove later for C++17 features: structured bindings and try_emplace
+    #ifdef __cpp_structured_bindings
+      const auto [iterator, success] =
+    #else
+      typename decltype(signals_)::const_iterator iterator;
+      bool success;
+      std::tie (iterator, success) =
+    #endif
+
+    #ifdef __cpp_lib_map_try_emplace
+      signals_.try_emplace (
+    #else
+      signals_.emplace (
+    #endif
+                         std::string (typeid (T).name ()), DefferedPtr ());
+    if (!success)
     {
-      Signal* signal = new Signal ();
-      signals_[typeid (T).name ()] = signal;
-      return (signal);
+      return nullptr;
     }
-    return (nullptr);
+    return static_cast<Signal*> (iterator->second.get ());
   }
 
   template<typename T> boost::signals2::connection
   Grabber::registerCallback (const std::function<T> & callback)
   {
-    using Signal = boost::signals2::signal<T>;
-    if (signals_.find (typeid (T).name ()) == signals_.end ())
+    const auto signal = find_signal<T> ();
+    if (signal == nullptr)
     {
       std::stringstream sstream;
 
@@ -271,7 +312,6 @@ namespace pcl
       PCL_THROW_EXCEPTION (pcl::IOException, "[" << getName () << "] " << sstream.str ());
       //return (boost::signals2::connection ());
     }
-    Signal* signal = dynamic_cast<Signal*> (signals_[typeid (T).name ()]);
     boost::signals2::connection ret = signal->connect (callback);
 
     connections_[typeid (T).name ()].push_back (ret);
@@ -281,11 +321,9 @@ namespace pcl
   }
 
   template<typename T> bool
-  Grabber::providesCallback () const
+  Grabber::providesCallback () const noexcept
   {
-    if (signals_.find (typeid (T).name ()) == signals_.end ())
-      return (false);
-    return (true);
+    return find_signal<T> ();
   }
 
 } // namespace
index d33352ead4c05093c99ab16937230c813a301f03..c95410c6508f514df44bc29e458f6c4c379ce6e0 100644 (file)
@@ -71,7 +71,7 @@ namespace pcl
        */
       using sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba = void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &, float, float);
 
-      using sig_cb_velodyne_hdl_scan_point_cloud_xyzrgb PCL_DEPRECATED("use sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba instead")
+      using sig_cb_velodyne_hdl_scan_point_cloud_xyzrgb PCL_DEPRECATED(1, 12, "use sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba instead")
               = sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba;
 
       /** \brief Signal used for a single sector
@@ -97,7 +97,7 @@ namespace pcl
        */
       using sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgba = void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &);
 
-      using sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgb PCL_DEPRECATED("use sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgba instead")
+      using sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgb PCL_DEPRECATED(1, 12, "use sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgba instead")
               = sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgba;
 
       /** \brief Constructor taking an optional path to an HDL corrections file.  The Grabber will listen on the default IP/port for data packets [192.168.3.255/2368]
@@ -270,7 +270,7 @@ namespace pcl
       computeXYZI (pcl::PointXYZI& pointXYZI,
                    std::uint16_t azimuth,
                    HDLLaserReturn laserReturn,
-                   HDLLaserCorrection correction);
+                   HDLLaserCorrection correction) const;
 
 
     private:
index 4cb43ee382d41893328053289c491670e36edfbd..187b388ea014575d901990242c32bb37c8714a88 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  *
  */
-#pragma once
 
-#include <chrono>
+#pragma once
 
-#include <pcl/pcl_config.h>
-#include <pcl/pcl_exports.h>
 #include <pcl/io/boost.h>
-
 #include <pcl/io/image_metadata_wrapper.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_config.h>
+#include <pcl/pcl_macros.h>
+
+#include <chrono>
 
 namespace pcl
 {
   namespace io
-  { 
+  {
 
     /**
     * @brief Image interface class providing an interface to fill a RGB or Grayscale image buffer.
@@ -212,3 +212,4 @@ namespace pcl
 
   } // namespace
 }
+
index 0b505c6acf4536d0c0539c92452c38d94ea672f6..b69a0f6df774aef750e8001b3e59adcd4bcdfeaa 100644 (file)
 
 #pragma once
 
+#include <pcl/conversions.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
+#include <pcl/common/time_trigger.h>
 #include <pcl/io/grabber.h>
 #include <pcl/io/file_grabber.h>
-#include <pcl/common/time_trigger.h>
-#include <pcl/conversions.h>
-
-#include <boost/shared_ptr.hpp>
 
 #include <string>
 #include <vector>
 
+
 namespace pcl
 {
   /** \brief Base class for Image file grabber.
@@ -75,59 +75,41 @@ namespace pcl
      */
     ImageGrabberBase (const std::vector<std::string>& depth_image_files, float frames_per_second, bool repeat);
 
-    /** \brief Copy constructor.
-     * \param[in] src the Image Grabber base object to copy into this
-     */
-    ImageGrabberBase (const ImageGrabberBase &src) : impl_ ()
-    {
-      *this = src;
-    }
-
-    /** \brief Copy operator.
-     * \param[in] src the Image Grabber base object to copy into this
-     */
-    ImageGrabberBase&
-    operator = (const ImageGrabberBase &src)
-    {
-      impl_ = src.impl_;
-      return (*this);
-    }
-
     /** \brief Virtual destructor. */
     ~ImageGrabberBase () noexcept;
 
     /** \brief Starts playing the list of PCD files if frames_per_second is > 0. Otherwise it works as a trigger: publishes only the next PCD file in the list. */
-    void 
+    void
     start () override;
-      
+
     /** \brief Stops playing the list of PCD files if frames_per_second is > 0. Otherwise the method has no effect. */
-    void 
+    void
     stop () override;
-      
+
     /** \brief Triggers a callback with new data */
-    virtual void 
+    virtual void
     trigger ();
 
     /** \brief whether the grabber is started (publishing) or not.
      * \return true only if publishing.
      */
-    bool 
+    bool
     isRunning () const override;
-      
+
     /** \return The name of the grabber */
-    std::string 
+    std::string
     getName () const override;
-      
+
     /** \brief Rewinds to the first PCD file in the list.*/
-    virtual void 
+    virtual void
     rewind ();
 
     /** \brief Returns the frames_per_second. 0 if grabber is trigger-based */
-    float 
+    float
     getFramesPerSecond () const override;
 
     /** \brief Returns whether the repeat flag is on */
-    bool 
+    bool
     isRepeatOn () const;
 
     /** \brief Returns if the last frame is reached */
@@ -138,7 +120,7 @@ namespace pcl
     std::string
     getCurrentDepthFileName () const;
 
-    /** \brief Returns the filename of the previous indexed file 
+    /** \brief Returns the filename of the previous indexed file
      *  SDM: adding this back in, but is this useful, or confusing? */
     std::string
     getPrevDepthFileName () const;
@@ -157,18 +139,18 @@ namespace pcl
     void
     setRGBImageFiles (const std::vector<std::string>& rgb_image_files);
 
-    /** \brief Define custom focal length and center pixel. This will override ANY other setting of parameters for the duration of the grabber's life, whether by factory defaults or explicitly read from a frame_[timestamp].xml file. 
+    /** \brief Define custom focal length and center pixel. This will override ANY other setting of parameters for the duration of the grabber's life, whether by factory defaults or explicitly read from a frame_[timestamp].xml file.
      *  \param[in] focal_length_x Horizontal focal length (fx)
      *  \param[in] focal_length_y Vertical focal length (fy)
      *  \param[in] principal_point_x Horizontal coordinates of the principal point (cx)
      *  \param[in] principal_point_y Vertical coordinates of the principal point (cy)
      */
     virtual void
-    setCameraIntrinsics (const double focal_length_x, 
-                         const double focal_length_y, 
-                         const double principal_point_x, 
+    setCameraIntrinsics (const double focal_length_x,
+                         const double focal_length_y,
+                         const double principal_point_x,
                          const double principal_point_y);
-    
+
     /** \brief Get the current focal length and center pixel. If the intrinsics have been manually set with setCameraIntrinsics, this will return those values. Else, if start () has been called and the grabber has found a frame_[timestamp].xml file, this will return the most recent values read. Else, returns factory defaults.
      *  \param[out] focal_length_x Horizontal focal length (fx)
      *  \param[out] focal_length_y Vertical focal length (fy)
@@ -176,16 +158,16 @@ namespace pcl
      *  \param[out] principal_point_y Vertical coordinates of the principal point (cy)
      */
     virtual void
-    getCameraIntrinsics (double &focal_length_x, 
-                         double &focal_length_y, 
-                         double &principal_point_x, 
+    getCameraIntrinsics (double &focal_length_x,
+                         double &focal_length_y,
+                         double &principal_point_x,
                          double &principal_point_y) const;
 
     /** \brief Define the units the depth data is stored in.
      *  Defaults to mm (0.001), meaning a brightness of 1000 corresponds to 1 m*/
     void
     setDepthImageUnits (float units);
-    
+
     /** \brief Set the number of threads, if we wish to use OpenMP for quicker cloud population.
      *  Note that for a standard (< 4 core) machine this is unlikely to yield a drastic speedup.*/
     void
@@ -196,14 +178,14 @@ namespace pcl
       */
     std::size_t
     numFrames () const;
-    
+
     /** \brief Gets the cloud in ROS form at location idx */
     bool
     getCloudAt (std::size_t idx, pcl::PCLPointCloud2 &blob, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation) const;
 
 
     private:
-    virtual void 
+    virtual void
     publish (const pcl::PCLPointCloud2& blob, const Eigen::Vector4f& origin, const Eigen::Quaternionf& orientation) const = 0;
 
 
@@ -220,23 +202,23 @@ namespace pcl
     using Ptr = shared_ptr<ImageGrabber>;
     using ConstPtr = shared_ptr<const ImageGrabber>;
 
-    ImageGrabber (const std::string& dir, 
-                  float frames_per_second = 0, 
-                  bool repeat = false, 
+    ImageGrabber (const std::string& dir,
+                  float frames_per_second = 0,
+                  bool repeat = false,
                   bool pclzf_mode = false);
 
-    ImageGrabber (const std::string& depth_dir, 
-                  const std::string& rgb_dir, 
-                  float frames_per_second = 0, 
+    ImageGrabber (const std::string& depth_dir,
+                  const std::string& rgb_dir,
+                  float frames_per_second = 0,
                   bool repeat = false);
 
-    ImageGrabber (const std::vector<std::string>& depth_image_files, 
-                  float frames_per_second = 0, 
+    ImageGrabber (const std::vector<std::string>& depth_image_files,
+                  float frames_per_second = 0,
                   bool repeat = false);
-      
+
     /** \brief Empty destructor */
     ~ImageGrabber () noexcept {}
-    
+
     // Inherited from FileGrabber
     const typename pcl::PointCloud<PointT>::ConstPtr
     operator[] (std::size_t idx) const override;
@@ -246,29 +228,29 @@ namespace pcl
     size () const override;
 
     protected:
-    void 
+    void
     publish (const pcl::PCLPointCloud2& blob,
-             const Eigen::Vector4f& origin, 
+             const Eigen::Vector4f& origin,
              const Eigen::Quaternionf& orientation) const override;
     boost::signals2::signal<void (const typename pcl::PointCloud<PointT>::ConstPtr&)>* signal_;
   };
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   template<typename PointT>
-  ImageGrabber<PointT>::ImageGrabber (const std::string& dir, 
-                                      float frames_per_second, 
-                                      bool repeat, 
+  ImageGrabber<PointT>::ImageGrabber (const std::string& dir,
+                                      float frames_per_second,
+                                      bool repeat,
                                       bool pclzf_mode)
     : ImageGrabberBase (dir, frames_per_second, repeat, pclzf_mode)
   {
     signal_ = createSignal<void (const typename pcl::PointCloud<PointT>::ConstPtr&)>();
   }
-  
+
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   template<typename PointT>
-  ImageGrabber<PointT>::ImageGrabber (const std::string& depth_dir, 
-                                      const std::string& rgb_dir, 
-                                      float frames_per_second, 
+  ImageGrabber<PointT>::ImageGrabber (const std::string& depth_dir,
+                                      const std::string& rgb_dir,
+                                      float frames_per_second,
                                       bool repeat)
     : ImageGrabberBase (depth_dir, rgb_dir, frames_per_second, repeat)
   {
@@ -277,8 +259,8 @@ namespace pcl
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   template<typename PointT>
-  ImageGrabber<PointT>::ImageGrabber (const std::vector<std::string>& depth_image_files, 
-                                      float frames_per_second, 
+  ImageGrabber<PointT>::ImageGrabber (const std::vector<std::string>& depth_image_files,
+                                      float frames_per_second,
                                       bool repeat)
     : ImageGrabberBase (depth_image_files, frames_per_second, repeat), signal_ ()
   {
index ad6c27535c99c46821d6ab193e0a52b8c9b1d604..c0b59311d9eb862733c3f27f45b7ee26d38156f4 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <chrono>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/io/boost.h>
 
index fcc290ff2a547768a28b2bf8e97a6f392f8cda50..d6417d32635b5cd428a556628eaa208196ca52cc 100644 (file)
@@ -1,17 +1,17 @@
 /*
  * Software License Agreement (BSD License)
- * 
+ *
  * Point Cloud Library (PCL) - www.pointclouds.org
  * Copyright (c) 2009-2012, Willow Garage, Inc.
  * Copyright (c) 2012-, Open Perception, Inc.
  * Copyright (c) 2014, respective authors.
- * 
+ *
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  *  * Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above
@@ -21,7 +21,7 @@
  *  * Neither the name of the copyright holder(s) nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -39,8 +39,8 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
-#include <pcl/pcl_macros.h>
 
 namespace pcl
 {
@@ -81,3 +81,4 @@ namespace pcl
 
   } // namespace
 }
+
index ba314145b3364c162116e80da8ceec0d645130f4..b92960c21eccbbd80101effa5cf5a268dd9666b7 100644 (file)
  *
  */
 
+
 #ifndef PCL_IO_ASCII_IO_HPP_
 #define PCL_IO_ASCII_IO_HPP_
 
+
+namespace pcl
+{
+
 template<typename PointT> void
-pcl::ASCIIReader::setInputFields ()
+ASCIIReader::setInputFields ()
 {
   fields_ = pcl::getFields<PointT> ();
 
@@ -55,5 +60,6 @@ pcl::ASCIIReader::setInputFields ()
   }
 }
 
+} // namespace pcl
 
 #endif    //PCL_IO_ASCII_IO_HPP_
index a1645524e6fb77cefd1c5e9863d0a07057fcc8d0..4a90249f39842b7005fd53ed292cf36fe9c7683b 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <pcl/pcl_macros.h>
 
+
 template <typename T>
 struct buffer_traits
 {
@@ -64,38 +65,45 @@ struct buffer_traits <double>
   static bool is_invalid (double value) { return std::isnan (value); };
 };
 
+
+namespace pcl
+{
+
+namespace io
+{
+
 template <typename T>
-pcl::io::Buffer<T>::Buffer (std::size_t size)
+Buffer<T>::Buffer (std::size_t size)
 : size_ (size)
 {
 }
 
 template <typename T>
-pcl::io::Buffer<T>::~Buffer ()
+Buffer<T>::~Buffer ()
 {
 }
 
 template <typename T>
-pcl::io::SingleBuffer<T>::SingleBuffer (std::size_t size)
+SingleBuffer<T>::SingleBuffer (std::size_t size)
 : Buffer<T> (size)
 , data_ (size, buffer_traits<T>::invalid ())
 {
 }
 
 template <typename T>
-pcl::io::SingleBuffer<T>::~SingleBuffer ()
+SingleBuffer<T>::~SingleBuffer ()
 {
 }
 
 template <typename T> T
-pcl::io::SingleBuffer<T>::operator[] (std::size_t idx) const
+SingleBuffer<T>::operator[] (std::size_t idx) const
 {
   assert (idx < size_);
   return (data_[idx]);
 }
 
 template <typename T> void
-pcl::io::SingleBuffer<T>::push (std::vector<T>& data)
+SingleBuffer<T>::push (std::vector<T>& data)
 {
   assert (data.size () == size_);
   std::lock_guard<std::mutex> lock (data_mutex_);
@@ -104,8 +112,8 @@ pcl::io::SingleBuffer<T>::push (std::vector<T>& data)
 }
 
 template <typename T>
-pcl::io::MedianBuffer<T>::MedianBuffer (std::size_t size,
-                                        unsigned char window_size)
+MedianBuffer<T>::MedianBuffer (std::size_t size,
+                               unsigned char window_size)
 : Buffer<T> (size)
 , window_size_ (window_size)
 , midpoint_ (window_size_ / 2)
@@ -130,12 +138,12 @@ pcl::io::MedianBuffer<T>::MedianBuffer (std::size_t size,
 }
 
 template <typename T>
-pcl::io::MedianBuffer<T>::~MedianBuffer ()
+MedianBuffer<T>::~MedianBuffer ()
 {
 }
 
 template <typename T> T
-pcl::io::MedianBuffer<T>::operator[] (std::size_t idx) const
+MedianBuffer<T>::operator[] (std::size_t idx) const
 {
   assert (idx < size_);
   int midpoint = (window_size_ - data_invalid_count_[idx]) / 2;
@@ -143,7 +151,7 @@ pcl::io::MedianBuffer<T>::operator[] (std::size_t idx) const
 }
 
 template <typename T> void
-pcl::io::MedianBuffer<T>::push (std::vector<T>& data)
+MedianBuffer<T>::push (std::vector<T>& data)
 {
   assert (data.size () == size_);
   std::lock_guard<std::mutex> lock (data_mutex_);
@@ -206,7 +214,7 @@ pcl::io::MedianBuffer<T>::push (std::vector<T>& data)
 }
 
 template <typename T> int
-pcl::io::MedianBuffer<T>::compare (T a, T b)
+MedianBuffer<T>::compare (T a, T b)
 {
   bool a_is_invalid = buffer_traits<T>::is_invalid (a);
   bool b_is_invalid = buffer_traits<T>::is_invalid (b);
@@ -222,8 +230,8 @@ pcl::io::MedianBuffer<T>::compare (T a, T b)
 }
 
 template <typename T>
-pcl::io::AverageBuffer<T>::AverageBuffer (std::size_t size,
-                                          unsigned char window_size)
+AverageBuffer<T>::AverageBuffer (std::size_t size,
+                                 unsigned char window_size)
 : Buffer<T> (size)
 , window_size_ (window_size)
 , data_current_idx_ (window_size_ - 1)
@@ -240,12 +248,12 @@ pcl::io::AverageBuffer<T>::AverageBuffer (std::size_t size,
 }
 
 template <typename T>
-pcl::io::AverageBuffer<T>::~AverageBuffer ()
+AverageBuffer<T>::~AverageBuffer ()
 {
 }
 
 template <typename T> T
-pcl::io::AverageBuffer<T>::operator[] (std::size_t idx) const
+AverageBuffer<T>::operator[] (std::size_t idx) const
 {
   assert (idx < size_);
   if (data_invalid_count_[idx] == window_size_)
@@ -254,7 +262,7 @@ pcl::io::AverageBuffer<T>::operator[] (std::size_t idx) const
 }
 
 template <typename T> void
-pcl::io::AverageBuffer<T>::push (std::vector<T>& data)
+AverageBuffer<T>::push (std::vector<T>& data)
 {
   assert (data.size () == size_);
   std::lock_guard<std::mutex> lock (data_mutex_);
@@ -288,5 +296,8 @@ pcl::io::AverageBuffer<T>::push (std::vector<T>& data)
   data.clear ();
 }
 
+} // namespace io
+} // namespace pcl
+
 #endif /* PCL_IO_IMPL_BUFFERS_HPP */
 
index fe8360dc5f0366d4beaa65e10815d3d74aced688..0750eab864b117cc8bfb4f5a63df2cb73e5dec6c 100644 (file)
 
 #define CLIP_CHAR(c) static_cast<unsigned char> ((c)>255?255:(c)<0?0:(c))
 
-//////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace io
+{
+
 template <typename PointT> bool
-pcl::io::LZFDepth16ImageReader::read (
+LZFDepth16ImageReader::read (
     const std::string &filename, pcl::PointCloud<PointT> &cloud)
 {
   std::uint32_t uncompressed_size;
@@ -100,9 +106,9 @@ pcl::io::LZFDepth16ImageReader::read (
       }
 
       pt.z = static_cast<float> (val * z_multiplication_factor_);
-      pt.x = (static_cast<float> (u) - static_cast<float> (parameters_.principal_point_x)) 
+      pt.x = (static_cast<float> (u) - static_cast<float> (parameters_.principal_point_x))
         * pt.z * static_cast<float> (constant_x);
-      pt.y = (static_cast<float> (v) - static_cast<float> (parameters_.principal_point_y)) 
+      pt.y = (static_cast<float> (v) - static_cast<float> (parameters_.principal_point_y))
         * pt.z * static_cast<float> (constant_y);
     }
   }
@@ -113,12 +119,12 @@ pcl::io::LZFDepth16ImageReader::read (
   cloud.sensor_orientation_.z () = 0.0f;
   return (true);
 }
-        
-///////////////////////////////////////////////////////////////////////////////
+
+
 template <typename PointT> bool
-pcl::io::LZFDepth16ImageReader::readOMP (const std::string &filename, 
-                                         pcl::PointCloud<PointT> &cloud, 
-                                         unsigned int num_threads)
+LZFDepth16ImageReader::readOMP (const std::string &filename,
+                                pcl::PointCloud<PointT> &cloud,
+                                unsigned int num_threads)
 {
   std::uint32_t uncompressed_size;
   std::vector<char> compressed_data;
@@ -151,7 +157,10 @@ pcl::io::LZFDepth16ImageReader::readOMP (const std::string &filename,
   double constant_x = 1.0 / parameters_.focal_length_x,
          constant_y = 1.0 / parameters_.focal_length_y;
 #ifdef _OPENMP
-#pragma omp parallel for num_threads (num_threads)
+#pragma omp parallel for                                   \
+  default(none)                                            \
+  shared(cloud, constant_x, constant_y, uncompressed_data) \
+  num_threads(num_threads)
 #else
   (void) num_threads; // suppress warning if OMP is not present
 #endif
@@ -168,13 +177,11 @@ pcl::io::LZFDepth16ImageReader::readOMP (const std::string &filename,
       pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN ();
       if (cloud.is_dense)
       {
-#ifdef _OPENMP
 #pragma omp critical
-#endif
-      {
-      if (cloud.is_dense)
-        cloud.is_dense = false;
-      }
+        {
+          if (cloud.is_dense)
+            cloud.is_dense = false;
+        }
       }
       continue;
     }
@@ -184,20 +191,19 @@ pcl::io::LZFDepth16ImageReader::readOMP (const std::string &filename,
       * pt.z * static_cast<float> (constant_x);
     pt.y = (static_cast<float> (v) - static_cast<float> (parameters_.principal_point_y)) 
       * pt.z * static_cast<float> (constant_y);
-    
   }
+
   cloud.sensor_origin_.setZero ();
   cloud.sensor_orientation_.w () = 1.0f;
   cloud.sensor_orientation_.x () = 0.0f;
   cloud.sensor_orientation_.y () = 0.0f;
   cloud.sensor_orientation_.z () = 0.0f;
   return (true);
-
 }
 
-//////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::io::LZFRGB24ImageReader::read (
+LZFRGB24ImageReader::read (
     const std::string &filename, pcl::PointCloud<PointT> &cloud)
 {
   std::uint32_t uncompressed_size;
@@ -244,9 +250,9 @@ pcl::io::LZFRGB24ImageReader::read (
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::io::LZFRGB24ImageReader::readOMP (
+LZFRGB24ImageReader::readOMP (
     const std::string &filename, pcl::PointCloud<PointT> &cloud, unsigned int num_threads)
 {
   std::uint32_t uncompressed_size;
@@ -282,7 +288,10 @@ pcl::io::LZFRGB24ImageReader::readOMP (
   unsigned char *color_b = reinterpret_cast<unsigned char*> (&uncompressed_data[2 * getWidth () * getHeight ()]);
 
 #ifdef _OPENMP
-#pragma omp parallel for num_threads (num_threads)
+#pragma omp parallel for                   \
+  default(none)                            \
+  shared(cloud, color_b, color_g, color_r) \
+  num_threads(num_threads)
 #else
   (void) num_threads; // suppress warning if OMP is not present
 #endif//_OPENMP
@@ -297,9 +306,9 @@ pcl::io::LZFRGB24ImageReader::readOMP (
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::io::LZFYUV422ImageReader::read (
+LZFYUV422ImageReader::read (
     const std::string &filename, pcl::PointCloud<PointT> &cloud)
 {
   std::uint32_t uncompressed_size;
@@ -334,7 +343,7 @@ pcl::io::LZFYUV422ImageReader::read (
   unsigned char *color_u = reinterpret_cast<unsigned char*> (&uncompressed_data[0]);
   unsigned char *color_y = reinterpret_cast<unsigned char*> (&uncompressed_data[wh2]);
   unsigned char *color_v = reinterpret_cast<unsigned char*> (&uncompressed_data[wh2 + getWidth () * getHeight ()]);
-  
+
   int y_idx = 0;
   for (int i = 0; i < wh2; ++i, y_idx += 2)
   {
@@ -355,9 +364,9 @@ pcl::io::LZFYUV422ImageReader::read (
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::io::LZFYUV422ImageReader::readOMP (
+LZFYUV422ImageReader::readOMP (
     const std::string &filename, pcl::PointCloud<PointT> &cloud, unsigned int num_threads)
 {
   std::uint32_t uncompressed_size;
@@ -392,9 +401,12 @@ pcl::io::LZFYUV422ImageReader::readOMP (
   unsigned char *color_u = reinterpret_cast<unsigned char*> (&uncompressed_data[0]);
   unsigned char *color_y = reinterpret_cast<unsigned char*> (&uncompressed_data[wh2]);
   unsigned char *color_v = reinterpret_cast<unsigned char*> (&uncompressed_data[wh2 + getWidth () * getHeight ()]);
-  
+
 #ifdef _OPENMP
-#pragma omp parallel for num_threads (num_threads)
+#pragma omp parallel for                        \
+  default(none)                                 \
+  shared(cloud, color_u, color_v, color_y, wh2) \
+  num_threads(num_threads)
 #else
   (void) num_threads; //suppress warning if OMP is not present
 #endif//_OPENMP
@@ -418,9 +430,9 @@ pcl::io::LZFYUV422ImageReader::readOMP (
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::io::LZFBayer8ImageReader::read (
+LZFBayer8ImageReader::read (
     const std::string &filename, pcl::PointCloud<PointT> &cloud)
 {
   std::uint32_t uncompressed_size;
@@ -448,9 +460,9 @@ pcl::io::LZFBayer8ImageReader::read (
 
   // Convert Bayer8 to RGB24
   std::vector<unsigned char> rgb_buffer (getWidth () * getHeight () * 3);
-  pcl::io::DeBayer i;
-  i.debayerEdgeAware (reinterpret_cast<unsigned char*> (&uncompressed_data[0]), 
-                     static_cast<unsigned char*> (&rgb_buffer[0]), 
+  DeBayer i;
+  i.debayerEdgeAware (reinterpret_cast<unsigned char*> (&uncompressed_data[0]),
+                     static_cast<unsigned char*> (&rgb_buffer[0]),
                      getWidth (), getHeight ());
   // Copy to PointT
   cloud.width  = getWidth ();
@@ -468,9 +480,9 @@ pcl::io::LZFBayer8ImageReader::read (
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::io::LZFBayer8ImageReader::readOMP (
+LZFBayer8ImageReader::readOMP (
     const std::string &filename, pcl::PointCloud<PointT> &cloud, unsigned int num_threads)
 {
   std::uint32_t uncompressed_size;
@@ -498,16 +510,18 @@ pcl::io::LZFBayer8ImageReader::readOMP (
 
   // Convert Bayer8 to RGB24
   std::vector<unsigned char> rgb_buffer (getWidth () * getHeight () * 3);
-  pcl::io::DeBayer i;
-  i.debayerEdgeAware (reinterpret_cast<unsigned char*> (&uncompressed_data[0]), 
-                     static_cast<unsigned char*> (&rgb_buffer[0]), 
+  DeBayer i;
+  i.debayerEdgeAware (reinterpret_cast<unsigned char*> (&uncompressed_data[0]),
+                     static_cast<unsigned char*> (&rgb_buffer[0]),
                      getWidth (), getHeight ());
   // Copy to PointT
   cloud.width  = getWidth ();
   cloud.height = getHeight ();
   cloud.resize (getWidth () * getHeight ());
 #ifdef _OPENMP
-#pragma omp parallel for num_threads (num_threads)
+#pragma omp parallel for \
+  default(none)          \
+  num_threads(num_threads)
 #else
   (void) num_threads; //suppress warning if OMP is not present
 #endif//_OPENMP
@@ -522,5 +536,8 @@ pcl::io::LZFBayer8ImageReader::readOMP (
   return (true);
 }
 
+} // namespace io
+} // namespace pcl
+
 #endif  //#ifndef PCL_LZF_IMAGE_IO_HPP_
 
index 526b3a8a5206afe09b16ef9a7ffdc1c26e16d718..17e5838426c7a5c9f4bf7635e892815047fac3a2 100644 (file)
@@ -35,8 +35,7 @@
  *
  */
 
-#ifndef PCL_POINT_CLOUD_IMAGE_EXTRACTORS_IMPL_HPP_
-#define PCL_POINT_CLOUD_IMAGE_EXTRACTORS_IMPL_HPP_
+#pragma once
 
 #include <set>
 #include <map>
@@ -45,6 +44,7 @@
 
 #include <pcl/common/io.h>
 #include <pcl/common/colors.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
@@ -296,5 +296,3 @@ pcl::io::PointCloudImageExtractorWithScaling<PointT>::extractImpl (const PointCl
   return (true);
 }
 
-#endif      // PCL_POINT_CLOUD_IMAGE_EXTRACTORS_IMPL_HPP_
-
index 19b7c88ae42c159fc95c69493ca4adeac70d2d96..59beb8be2ea11eb8f091253fb5307ba8f5ba14a4 100644 (file)
  *
  */
 
-#ifndef PCL_IO_VTK_IO_IMPL_H_
-#define PCL_IO_VTK_IO_IMPL_H_
+#pragma once
 
 // PCL
 #include <pcl/common/io.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/io/pcd_io.h>
 #include <pcl/point_types.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 
 // VTK
 // Ignore warnings in the above headers
@@ -512,5 +512,3 @@ pcl::io::pointCloudTovtkStructuredGrid (const pcl::PointCloud<PointT>& cloud, vt
 #undef GetTupleValue
 #endif
 
-#endif  //#ifndef PCL_IO_VTK_IO_H_
-
index a9ca88c069ccdf3acf51efde8063cd45262d6f38..144a9832ee0cea416f7cb09edbede25f45dcb073 100644 (file)
@@ -36,6 +36,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/TextureMesh.h>
 #include <pcl/PolygonMesh.h>
index 877ff809c8fe4bb292932d7330661c1d625072ad..8ab4d59bdb99f9ac27aa0badb68926e74018c997 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
 #include <pcl/pcl_macros.h>
 
@@ -93,29 +94,29 @@ namespace pcl
       /** \brief For devices that are streaming, the streams are started by calling this method.
         *        Trigger-based devices, just trigger the device once for each call of start.
         */
-      void 
+      void
       start () override;
 
       /** \brief For devices that are streaming, the streams are stopped.
         *        This method has no effect for triggered devices.
         */
-      void 
+      void
       stop () override;
 
       /** \brief returns the name of the concrete subclass.
         * \return the name of the concrete driver.
         */
-      std::string 
+      std::string
       getName () const override;
 
       /** \brief Indicates whether the grabber is streaming or not. This value is not defined for triggered devices.
         * \return true if grabber is running / streaming. False otherwise.
         */
-      bool 
+      bool
       isRunning () const override;
 
       /** \brief returns the frames pre second. 0 if it is trigger based. */
-      float 
+      float
       getFramesPerSecond () const override;
 
       /** \brief Check if there is any data left in the ONI file to process. */
index 0336500f23bf58a842519dab71301b33ec8477e3..dd4627856269d0686e9bb017d3de828b0fa50da9 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
-#include "openni.h"
-#include "pcl/io/openni2/openni2_video_mode.h"
-#include "pcl/io/io_exception.h"
-
-#include <boost/shared_ptr.hpp>
 
 // Template frame wrappers
 #include <pcl/io/image.h>
 #include <pcl/io/image_depth.h>
 #include <pcl/io/image_ir.h>
 
+#include <pcl/io/io_exception.h>
+#include <pcl/io/openni2/openni2_video_mode.h>
+
+#include "openni.h"
+
 #include <cstdint>
 #include <functional>
 #include <memory>
@@ -49,7 +50,6 @@
 #include <vector>
 
 
-
 namespace openni
 {
   class Device;
index c0678e8b483926f5a36a9d38d87ae008c0bf41cf..183810083cbae08c25308bdab75ff91d0d42ef64 100644 (file)
@@ -31,7 +31,7 @@
 
 #pragma once
 
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 #include <pcl/io/openni2/openni2_device.h>
 #include <pcl/io/openni2/openni2_device_info.h>
@@ -80,7 +80,7 @@ namespace pcl
         getDevice (const std::string& device_URI);
 
         OpenNI2Device::Ptr
-        getDeviceByIndex (int index);
+        getDeviceByIndex (int index) const;
 
         OpenNI2Device::Ptr
         getFileDevice (const std::string& path);
index 83a2aab974dbfa570a38ac1f70cc736ee6a27aa0..edb614e7c6f9425669b8de439e2a153bd7c9c4d1 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
 #include <pcl/pcl_macros.h>
 
index 66e544033f74b840d892a0056c4b55928f6fc150..46a702df51d0179eb44f60978ccd6e31fd980540 100644 (file)
@@ -39,7 +39,7 @@
 #pragma once
  
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni.h"
index afdc35b2421dd83f0366e694684a65df208480cf..b83017f5990cdff406b7b397f96e290607d1d7d1 100644 (file)
@@ -38,7 +38,7 @@
 #pragma once
 
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni_exception.h"
index c719c7ea0b962b223ef9ef7b7493bac5b7cd82c8..549fae20227a532d449e42594f5606d892a6688c 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
 
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni_device.h"
index 913ec8ef14c3c8d87929c33093a96bf7b8042c24..99dbb9dc8f8b51e096bb5f628a2cb3a551b16047 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
 
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni_device.h"
index 08b19df30e3d7ce20ec47bdf46580ff17ff8bc75..0ce0704419713088b0ca0a8f0dcde5d930845b8a 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
  
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni_device.h"
index ec210275a59872c136e3563e9d5467b8e83cac83..ea0735c4bc12f8c1d7a098cc47af8fbb415ee75b 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
 
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni_device.h"
index 6ece494067e4ae9b1ab89c2c8e44853e57a158df..747461e1c8d0c67747a09b7a0ea47358365da47f 100644 (file)
@@ -42,7 +42,8 @@
 #include "openni.h"
 #include "openni_exception.h"
 #include "openni_device.h"
-#include <pcl/io/boost.h>
+
+#include <pcl/memory.h> // for pcl::weak_ptr
 #include <pcl/pcl_macros.h>
 
 #include <map>
@@ -217,7 +218,7 @@ namespace openni_wrapper
       std::shared_ptr<xn::NodeInfo> image_node;
       std::shared_ptr<xn::NodeInfo> depth_node;
       std::shared_ptr<xn::NodeInfo> ir_node;
-      boost::weak_ptr<OpenNIDevice> device;
+      pcl::weak_ptr<OpenNIDevice> device;
     } ;
 
     OpenNIDriver ();
@@ -248,5 +249,8 @@ namespace openni_wrapper
   {
     return static_cast<unsigned> (device_context_.size ());
   }
-} // namespace
+
+} // namespace openni_wrapper
+
 #endif
+
index df8c93188fb05645162681aed9295c070834169b..1791722957200a729ad4a343ade4d49e6d3c42ff 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
  
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include <pcl/pcl_exports.h>
index ca6803a5b5312f64b79edde5ca6831c582e1351b..ce6130356ee0b73a1ac7c3968665b57c61b26822 100644 (file)
@@ -39,7 +39,7 @@
 #pragma once
  
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include <pcl/pcl_macros.h>
index 0ee267ad914cf016c8ef15697d16b1401bedad43..ad17143ff3d24d920271facae44584a9e1087a00 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
  
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include "openni_image.h"
index f7d5208a2ec32f18778b2f68b4aa5e9374308170..ea9e382efa2721f655c7688686c4174b6f7e0d3b 100644 (file)
@@ -37,7 +37,7 @@
 #pragma once
  
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include <pcl/pcl_macros.h>
index fac253d5559fb966fe6333d79be91f708db4b7db..4f32f0e98e961f165e9e16e900a5f75aa3ac0d58 100644 (file)
@@ -37,7 +37,7 @@
 #define __OPENNI_IR_IMAGE__
 
 #include <pcl/pcl_macros.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include "openni.h"
 #include "openni_exception.h"
 #include <pcl/io/boost.h>
index bc16916b62d9e0f49ce1cff50ccb4add6df98b31..4f8a8ca7e6140f87ea5036669f4b8724751b6762 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
 #include <pcl/pcl_macros.h>
 
@@ -127,10 +128,10 @@ namespace pcl
       getName () const override;
 
       /** \brief Obtain the number of frames per second (FPS). */
-      float 
+      float
       getFramesPerSecond () const override;
 
-      /** \brief Get a boost shared pointer to the \ref pcl::openni_wrapper::OpenNIDevice object. */
+      /** \brief Get a pcl::shared pointer to the openni_wrapper::OpenNIDevice object. */
       inline openni_wrapper::OpenNIDevice::Ptr
       getDevice () const;
 
@@ -151,8 +152,8 @@ namespace pcl
         * and the grabber will use the default values from the camera instead.
         */
       inline void
-      setRGBCameraIntrinsics (const double rgb_focal_length_x, 
-                              const double rgb_focal_length_y, 
+      setRGBCameraIntrinsics (const double rgb_focal_length_x,
+                              const double rgb_focal_length_y,
                               const double rgb_principal_point_x,
                               const double rgb_principal_point_y)
       {
@@ -161,7 +162,7 @@ namespace pcl
         rgb_principal_point_x_ = rgb_principal_point_x;
         rgb_principal_point_y_ = rgb_principal_point_y;
       }
-      
+
       /** \brief Get the RGB camera parameters (fx, fy, cx, cy)
         * \param[out] rgb_focal_length_x the RGB focal length (fx)
         * \param[out] rgb_focal_length_y the RGB focal length (fy)
@@ -169,8 +170,8 @@ namespace pcl
         * \param[out] rgb_principal_point_y the RGB principal point (cy)
         */
       inline void
-      getRGBCameraIntrinsics (double &rgb_focal_length_x, 
-                              double &rgb_focal_length_y, 
+      getRGBCameraIntrinsics (double &rgb_focal_length_x,
+                              double &rgb_focal_length_y,
                               double &rgb_principal_point_x,
                               double &rgb_principal_point_y) const
       {
@@ -217,7 +218,7 @@ namespace pcl
         rgb_focal_length_x = rgb_focal_length_x_;
         rgb_focal_length_y = rgb_focal_length_y_;
       }
-      
+
       /** \brief Set the Depth camera parameters (fx, fy, cx, cy)
         * \param[in] depth_focal_length_x the Depth focal length (fx)
         * \param[in] depth_focal_length_y the Depth focal length (fy)
@@ -227,8 +228,8 @@ namespace pcl
         * and the grabber will use the default values from the camera instead.
         */
       inline void
-      setDepthCameraIntrinsics (const double depth_focal_length_x, 
-                                const double depth_focal_length_y, 
+      setDepthCameraIntrinsics (const double depth_focal_length_x,
+                                const double depth_focal_length_y,
                                 const double depth_principal_point_x,
                                 const double depth_principal_point_y)
       {
@@ -237,7 +238,7 @@ namespace pcl
         depth_principal_point_x_ = depth_principal_point_x;
         depth_principal_point_y_ = depth_principal_point_y;
       }
-      
+
       /** \brief Get the Depth camera parameters (fx, fy, cx, cy)
         * \param[out] depth_focal_length_x the Depth focal length (fx)
         * \param[out] depth_focal_length_y the Depth focal length (fy)
@@ -245,8 +246,8 @@ namespace pcl
         * \param[out] depth_principal_point_y the Depth principal point (cy)
         */
       inline void
-      getDepthCameraIntrinsics (double &depth_focal_length_x, 
-                                double &depth_focal_length_y, 
+      getDepthCameraIntrinsics (double &depth_focal_length_x,
+                                double &depth_focal_length_y,
                                 double &depth_principal_point_x,
                                 double &depth_principal_point_y) const
       {
@@ -266,7 +267,7 @@ namespace pcl
       {
         depth_focal_length_x_ = depth_focal_length_y_ = depth_focal_length;
       }
-      
+
 
       /** \brief Set the Depth image focal length
         * \param[in] depth_focal_length_x the Depth focal length (fx)
@@ -427,7 +428,7 @@ namespace pcl
       unsigned image_height_;
       unsigned depth_width_;
       unsigned depth_height_;
-      
+
       bool image_required_;
       bool depth_required_;
       bool ir_required_;
index de546dac7b7b97e4b5cd4340ed292572b6f70786..872e1015553590fe68a90141a036289344f95556 100644 (file)
@@ -44,7 +44,7 @@
 #include <pcl/io/file_grabber.h>
 #include <pcl/common/time_trigger.h>
 #include <pcl/conversions.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #ifdef HAVE_OPENNI
 #include <pcl/io/openni_camera/openni_image.h>
@@ -62,7 +62,7 @@ namespace pcl
     */
   class PCL_EXPORTS PCDGrabberBase : public Grabber
   {
-    public:   
+    public:
       /** \brief Constructor taking just one PCD file or one TAR file containing multiple PCD files.
         * \param[in] pcd_file path to the PCD file
         * \param[in] frames_per_second frames per second. If 0, start() functions like a trigger, publishing the next PCD in the list.
@@ -77,66 +77,48 @@ namespace pcl
         */
       PCDGrabberBase (const std::vector<std::string>& pcd_files, float frames_per_second, bool repeat);
 
-      /** \brief Copy constructor.
-        * \param[in] src the PCD Grabber base object to copy into this
-        */
-      PCDGrabberBase (const PCDGrabberBase &src) : impl_ ()
-      {
-        *this = src;
-      }
-
-      /** \brief Copy operator.
-        * \param[in] src the PCD Grabber base object to copy into this
-        */
-      PCDGrabberBase&
-      operator = (const PCDGrabberBase &src)
-      {
-        impl_ = src.impl_;
-        return (*this);
-      }
-
       /** \brief Virtual destructor. */
       ~PCDGrabberBase () noexcept;
 
       /** \brief Starts playing the list of PCD files if frames_per_second is > 0. Otherwise it works as a trigger: publishes only the next PCD file in the list. */
-      void 
+      void
       start () override;
-      
+
       /** \brief Stops playing the list of PCD files if frames_per_second is > 0. Otherwise the method has no effect. */
-      void 
+      void
       stop () override;
-      
+
       /** \brief Triggers a callback with new data */
-      virtual void 
+      virtual void
       trigger ();
 
       /** \brief Indicates whether the grabber is streaming or not.
         * \return true if grabber is started and hasn't run out of PCD files.
         */
-      bool 
+      bool
       isRunning () const override;
-      
+
       /** \return The name of the grabber */
-      std::string 
+      std::string
       getName () const override;
-      
+
       /** \brief Rewinds to the first PCD file in the list.*/
-      virtual void 
+      virtual void
       rewind ();
 
       /** \brief Returns the frames_per_second. 0 if grabber is trigger-based */
-      float 
+      float
       getFramesPerSecond () const override;
 
       /** \brief Returns whether the repeat flag is on */
-      bool 
+      bool
       isRepeatOn () const;
-  
+
       /** \brief Get cloud (in ROS form) at a particular location */
       bool
-      getCloudAt (std::size_t idx, 
+      getCloudAt (std::size_t idx,
                   pcl::PCLPointCloud2 &blob,
-                  Eigen::Vector4f &origin, 
+                  Eigen::Vector4f &origin,
                   Eigen::Quaternionf &orientation) const;
 
       /** \brief Returns the size */
@@ -144,7 +126,7 @@ namespace pcl
       numFrames () const;
 
     private:
-      virtual void 
+      virtual void
       publish (const pcl::PCLPointCloud2& blob, const Eigen::Vector4f& origin, const Eigen::Quaternionf& orientation, const std::string& file_name) const = 0;
 
       // to separate and hide the implementation from interface: PIMPL
@@ -162,13 +144,13 @@ namespace pcl
 
       PCDGrabber (const std::string& pcd_path, float frames_per_second = 0, bool repeat = false);
       PCDGrabber (const std::vector<std::string>& pcd_files, float frames_per_second = 0, bool repeat = false);
-      
+
       /** \brief Virtual destructor. */
       ~PCDGrabber () noexcept
       {
         stop ();
       }
-    
+
       // Inherited from FileGrabber
       const typename pcl::PointCloud<PointT>::ConstPtr
       operator[] (std::size_t idx) const override;
@@ -178,9 +160,9 @@ namespace pcl
       size () const override;
     protected:
 
-      void 
+      void
       publish (const pcl::PCLPointCloud2& blob, const Eigen::Vector4f& origin, const Eigen::Quaternionf& orientation, const std::string& file_name) const override;
-      
+
       boost::signals2::signal<void (const typename pcl::PointCloud<PointT>::ConstPtr&)>* signal_;
       boost::signals2::signal<void (const std::string&)>* file_name_signal_;
 
@@ -242,7 +224,7 @@ namespace pcl
   }
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  template<typename PointT> void 
+  template<typename PointT> void
   PCDGrabber<PointT>::publish (const pcl::PCLPointCloud2& blob, const Eigen::Vector4f& origin, const Eigen::Quaternionf& orientation, const std::string& file_name) const
   {
     typename pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT> ());
@@ -304,7 +286,7 @@ namespace pcl
       openni_wrapper::Image::Ptr image (new openni_wrapper::ImageRGB24 (image_meta_data));
       if (image_signal_->num_slots() > 0)
         image_signal_->operator()(image);
-      
+
       if (image_depth_image_signal_->num_slots() > 0)
         image_depth_image_signal_->operator()(image, depth_image, 1.0f / 525.0f);
     }
index 881542ba3c6824b95911340bf39542b6a48ba624..e3b58feff188ae61181c1f8a00f58eef981162d1 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/io/file_io.h>
@@ -69,7 +70,7 @@ namespace pcl
         *   - HEIGHT ...
         *   - POINTS ...
         *   - DATA ascii/binary
-        * 
+        *
         * Everything that follows \b DATA is interpreted as data points and
         * will be read accordingly.
         *
@@ -100,19 +101,19 @@ namespace pcl
         * \param[out] origin the sensor acquisition origin (only for > PCD_V7 - null if not present)
         * \param[out] orientation the sensor acquisition orientation (only for > PCD_V7 - identity if not present)
         * \param[out] pcd_version the PCD version of the file (i.e., PCD_V6, PCD_V7)
-        * \param[out] data_type the type of data (0 = ASCII, 1 = Binary, 2 = Binary compressed) 
+        * \param[out] data_type the type of data (0 = ASCII, 1 = Binary, 2 = Binary compressed)
         * \param[out] data_idx the offset of cloud data within the file
         *
         * \return
         *  * < 0 (-1) on error
         *  * == 0 on success
         */
-      int 
+      int
       readHeader (std::istream &binary_istream, pcl::PCLPointCloud2 &cloud,
                   Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version,
                   int &data_type, unsigned int &data_idx);
 
-      /** \brief Read a point cloud data header from a PCD file. 
+      /** \brief Read a point cloud data header from a PCD file.
         *
         * Load only the meta information (number of points, their types, etc),
         * and not the points themselves, from a given PCD file. Useful for fast
@@ -128,7 +129,7 @@ namespace pcl
         * \param[out] origin the sensor acquisition origin (only for > PCD_V7 - null if not present)
         * \param[out] orientation the sensor acquisition orientation (only for > PCD_V7 - identity if not present)
         * \param[out] pcd_version the PCD version of the file (i.e., PCD_V6, PCD_V7)
-        * \param[out] data_type the type of data (0 = ASCII, 1 = Binary, 2 = Binary compressed) 
+        * \param[out] data_type the type of data (0 = ASCII, 1 = Binary, 2 = Binary compressed)
         * \param[out] data_idx the offset of cloud data within the file
         * \param[in] offset the offset of where to expect the PCD Header in the
         * file (optional parameter). One usage example for setting the offset
@@ -141,13 +142,13 @@ namespace pcl
         *  * < 0 (-1) on error
         *  * == 0 on success
         */
-      int 
+      int
       readHeader (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
                   Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version,
                   int &data_type, unsigned int &data_idx, const int offset = 0) override;
 
 
-      /** \brief Read a point cloud data header from a PCD file. 
+      /** \brief Read a point cloud data header from a PCD file.
         *
         * Load only the meta information (number of points, their types, etc),
         * and not the points themselves, from a given PCD file. Useful for fast
@@ -171,10 +172,10 @@ namespace pcl
         *  * < 0 (-1) on error
         *  * == 0 on success
         */
-      int 
+      int
       readHeader (const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset = 0);
 
-      /** \brief Read the point cloud data (body) from a PCD stream. 
+      /** \brief Read the point cloud data (body) from a PCD stream.
         *
         * Reads the cloud points from a text-formatted stream.  For use after
         * readHeader(), when the resulting data_type == 0.
@@ -193,7 +194,7 @@ namespace pcl
       int
       readBodyASCII (std::istream &stream, pcl::PCLPointCloud2 &cloud, int pcd_version);
 
-      /** \brief Read the point cloud data (body) from a block of memory. 
+      /** \brief Read the point cloud data (body) from a block of memory.
         *
         * Reads the cloud points from a binary-formatted memory block.  For use
         * after readHeader(), when the resulting data_type is nonzero.
@@ -230,16 +231,16 @@ namespace pcl
         *  * < 0 (-1) on error
         *  * == 0 on success
         */
-      int 
+      int
       read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
             Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, const int offset = 0) override;
 
       /** \brief Read a point cloud data from a PCD (PCD_V6) and store it into a pcl/PCLPointCloud2.
-        * 
+        *
         * \note This function is provided for backwards compatibility only and
         * it can only read PCD_V6 files correctly, as pcl::PCLPointCloud2
-        * does not contain a sensor origin/orientation. Reading any file 
-        * > PCD_V6 will generate a warning. 
+        * does not contain a sensor origin/orientation. Reading any file
+        * > PCD_V6 will generate a warning.
         *
         * \param[in] file_name the name of the file containing the actual PointCloud data
         * \param[out] cloud the resultant PointCloud message read from disk
@@ -254,7 +255,7 @@ namespace pcl
         *  * < 0 (-1) on error
         *  * == 0 on success
         */
-      int 
+      int
       read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset = 0);
 
       /** \brief Read a point cloud data from any PCD file, and convert it to the given template format.
@@ -276,7 +277,7 @@ namespace pcl
       {
         pcl::PCLPointCloud2 blob;
         int pcd_version;
-        int res = read (file_name, blob, cloud.sensor_origin_, cloud.sensor_orientation_, 
+        int res = read (file_name, blob, cloud.sensor_origin_, cloud.sensor_orientation_,
                         pcd_version, offset);
 
         // If no error, convert the data
@@ -298,7 +299,7 @@ namespace pcl
       PCDWriter() : map_synchronization_(false) {}
       ~PCDWriter() {}
 
-      /** \brief Set whether mmap() synchornization via msync() is desired before munmap() calls. 
+      /** \brief Set whether mmap() synchornization via msync() is desired before munmap() calls.
         * Setting this to true could prevent NFS data loss (see
         * http://www.pcl-developers.org/PCD-IO-consistency-on-NFS-msync-needed-td4885942.html).
         * Default: false
@@ -319,7 +320,7 @@ namespace pcl
         */
       std::string
       generateHeaderBinary (const pcl::PCLPointCloud2 &cloud,
-                            const Eigen::Vector4f &origin, 
+                            const Eigen::Vector4f &origin,
                             const Eigen::Quaternionf &orientation);
 
       /** \brief Generate the header of a BINARY_COMPRESSED PCD file format
@@ -335,18 +336,17 @@ namespace pcl
       int
       generateHeaderBinaryCompressed (std::ostream &os,
                                       const pcl::PCLPointCloud2 &cloud,
-                                      const Eigen::Vector4f &origin, 
+                                      const Eigen::Vector4f &origin,
                                       const Eigen::Quaternionf &orientation);
 
       /** \brief Generate the header of a BINARY_COMPRESSED PCD file format
-        * \param[out] os the stream into which to write the header
         * \param[in] cloud the point cloud data message
         * \param[in] origin the sensor acquisition origin
         * \param[in] orientation the sensor acquisition orientation
         */
       std::string
       generateHeaderBinaryCompressed (const pcl::PCLPointCloud2 &cloud,
-                                      const Eigen::Vector4f &origin, 
+                                      const Eigen::Vector4f &origin,
                                       const Eigen::Quaternionf &orientation);
 
       /** \brief Generate the header of a PCD file format
@@ -356,7 +356,7 @@ namespace pcl
         */
       std::string
       generateHeaderASCII (const pcl::PCLPointCloud2 &cloud,
-                           const Eigen::Vector4f &origin, 
+                           const Eigen::Vector4f &origin,
                            const Eigen::Quaternionf &orientation);
 
       /** \brief Generate the header of a PCD file format
@@ -365,7 +365,7 @@ namespace pcl
         * By default, nr_points is set to INTMAX, and the data in the header is used instead.
         */
       template <typename PointT> static std::string
-      generateHeader (const pcl::PointCloud<PointT> &cloud, 
+      generateHeader (const pcl::PointCloud<PointT> &cloud,
                       const int nr_points = std::numeric_limits<int>::max ());
 
       /** \brief Save point cloud data to a PCD file containing n-D points, in ASCII format
@@ -384,9 +384,9 @@ namespace pcl
         *
         * As an intermediary solution, precision 8 is used, which guarantees lossless storage for RGB.
         */
-      int 
+      int
       writeASCII (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,
-                  const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (), 
+                  const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
                   const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
                   const int precision = 8);
 
@@ -396,9 +396,9 @@ namespace pcl
         * \param[in] origin the sensor acquisition origin
         * \param[in] orientation the sensor acquisition orientation
         */
-      int 
+      int
       writeBinary (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,
-                   const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (), 
+                   const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
                    const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity ());
 
       /** \brief Save point cloud data to a PCD file containing n-D points, in BINARY_COMPRESSED format
@@ -411,9 +411,9 @@ namespace pcl
         * (-2) if the input cloud is too large for the file format
         * 0 on success
         */
-      int 
+      int
       writeBinaryCompressed (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,
-                             const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (), 
+                             const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
                              const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity ());
 
       /** \brief Save point cloud data to a std::ostream containing n-D points, in BINARY_COMPRESSED format
@@ -450,7 +450,7 @@ namespace pcl
         */
       inline int
       write (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,
-             const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (), 
+             const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
              const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
              const bool binary = false) override
       {
@@ -462,7 +462,7 @@ namespace pcl
       /** \brief Save point cloud data to a PCD file containing n-D points
         * \param[in] file_name the output file name
         * \param[in] cloud the point cloud data message (boost shared pointer)
-        * \param[in] binary set to true if the file is to be written in a binary PCD format, 
+        * \param[in] binary set to true if the file is to be written in a binary PCD format,
         * false (default) for ASCII
         * \param[in] origin the sensor acquisition origin
         * \param[in] orientation the sensor acquisition orientation
@@ -476,7 +476,7 @@ namespace pcl
         */
       inline int
       write (const std::string &file_name, const pcl::PCLPointCloud2::ConstPtr &cloud,
-             const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (), 
+             const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
              const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
              const bool binary = false)
       {
@@ -487,8 +487,8 @@ namespace pcl
         * \param[in] file_name the output file name
         * \param[in] cloud the point cloud data message
         */
-      template <typename PointT> int 
-      writeBinary (const std::string &file_name, 
+      template <typename PointT> int
+      writeBinary (const std::string &file_name,
                    const pcl::PointCloud<PointT> &cloud);
 
       /** \brief Save point cloud data to a binary comprssed PCD file
@@ -499,8 +499,8 @@ namespace pcl
         * (-2) if the input cloud is too large for the file format
         * 0 on success
         */
-      template <typename PointT> int 
-      writeBinaryCompressed (const std::string &file_name, 
+      template <typename PointT> int
+      writeBinaryCompressed (const std::string &file_name,
                              const pcl::PointCloud<PointT> &cloud);
 
       /** \brief Save point cloud data to a PCD file containing n-D points, in BINARY format
@@ -508,9 +508,9 @@ namespace pcl
         * \param[in] cloud the point cloud data message
         * \param[in] indices the set of point indices that we want written to disk
         */
-      template <typename PointT> int 
-      writeBinary (const std::string &file_name, 
-                   const pcl::PointCloud<PointT> &cloud, 
+      template <typename PointT> int
+      writeBinary (const std::string &file_name,
+                   const pcl::PointCloud<PointT> &cloud,
                    const std::vector<int> &indices);
 
       /** \brief Save point cloud data to a PCD file containing n-D points, in ASCII format
@@ -518,8 +518,8 @@ namespace pcl
         * \param[in] cloud the point cloud data message
         * \param[in] precision the specified output numeric stream precision (default: 8)
         */
-      template <typename PointT> int 
-      writeASCII (const std::string &file_name, 
+      template <typename PointT> int
+      writeASCII (const std::string &file_name,
                   const pcl::PointCloud<PointT> &cloud,
                   const int precision = 8);
 
@@ -529,8 +529,8 @@ namespace pcl
         * \param[in] indices the set of point indices that we want written to disk
         * \param[in] precision the specified output numeric stream precision (default: 8)
         */
-      template <typename PointT> int 
-      writeASCII (const std::string &file_name, 
+      template <typename PointT> int
+      writeASCII (const std::string &file_name,
                   const pcl::PointCloud<PointT> &cloud,
                   const std::vector<int> &indices,
                   const int precision = 8);
@@ -549,8 +549,8 @@ namespace pcl
         * future versions of PCL.
         */
       template<typename PointT> inline int
-      write (const std::string &file_name, 
-             const pcl::PointCloud<PointT> &cloud, 
+      write (const std::string &file_name,
+             const pcl::PointCloud<PointT> &cloud,
              const bool binary = false)
       {
         if (binary)
@@ -573,8 +573,8 @@ namespace pcl
         * future versions of PCL.
         */
       template<typename PointT> inline int
-      write (const std::string &file_name, 
-             const pcl::PointCloud<PointT> &cloud, 
+      write (const std::string &file_name,
+             const pcl::PointCloud<PointT> &cloud,
              const std::vector<int> &indices,
              bool binary = false)
       {
@@ -608,7 +608,7 @@ namespace pcl
   namespace io
   {
     /** \brief Load a PCD v.6 file into a templated PointCloud type.
-      * 
+      *
       * Any PCD files > v.6 will generate a warning as a
       * pcl/PCLPointCloud2 message cannot hold the sensor origin.
       *
@@ -616,7 +616,7 @@ namespace pcl
       * \param[out] cloud the resultant templated point cloud
       * \ingroup io
       */
-    inline int 
+    inline int
     loadPCDFile (const std::string &file_name, pcl::PCLPointCloud2 &cloud)
     {
       pcl::PCDReader p;
@@ -631,7 +631,7 @@ namespace pcl
       * PCD_V7 - identity if not present)
       * \ingroup io
       */
-    inline int 
+    inline int
     loadPCDFile (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
                  Eigen::Vector4f &origin, Eigen::Quaternionf &orientation)
     {
@@ -667,9 +667,9 @@ namespace pcl
       * future versions of PCL.
       * \ingroup io
       */
-    inline int 
+    inline int
     savePCDFile (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,
-                 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (), 
+                 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
                  const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
                  const bool binary_mode = false)
     {
@@ -698,7 +698,7 @@ namespace pcl
       return (w.write<PointT> (file_name, cloud, binary_mode));
     }
 
-    /** 
+    /**
       * \brief Templated version for saving point cloud data to a PCD file
       * containing a specific given cloud format.
       *
@@ -721,7 +721,7 @@ namespace pcl
       return (w.write<PointT> (file_name, cloud, false));
     }
 
-    /** 
+    /**
       * \brief Templated version for saving point cloud data to a PCD file
       * containing a specific given cloud format. The resulting file will be an uncompressed binary.
       *
@@ -737,7 +737,7 @@ namespace pcl
       return (w.write<PointT> (file_name, cloud, true));
     }
 
-    /** 
+    /**
       * \brief Templated version for saving point cloud data to a PCD file
       * containing a specific given cloud format
       *
@@ -755,9 +755,9 @@ namespace pcl
       * \ingroup io
       */
     template<typename PointT> int
-    savePCDFile (const std::string &file_name, 
+    savePCDFile (const std::string &file_name,
                  const pcl::PointCloud<PointT> &cloud,
-                 const std::vector<int> &indices, 
+                 const std::vector<int> &indices,
                  const bool binary_mode = false)
     {
       // Save the data
index a689633fef048264d8bedb45a3de7173b20d2b7e..12dd70434ede0789052885bb11165029739a490a 100644 (file)
 
 #pragma once
 
-#ifdef BUILD_Maintainer
-#  if defined __GNUC__
-#    pragma GCC system_header 
-#  elif defined _MSC_VER
-#    pragma warning(push, 1)
-#  endif
-#endif
-
 #include <pcl/io/boost.h>
 #include <pcl/io/ply/ply.h>
 #include <pcl/io/ply/io_operators.h>
@@ -705,14 +697,3 @@ inline bool pcl::io::ply::ply_parser::parse_list_property (format_type format, s
   }
   return (true);
 }
-
-#ifdef BUILD_Maintainer
-#  if defined __GNUC__
-#    if __GNUC__ == 4 && __GNUC_MINOR__ > 3
-#      pragma GCC diagnostic warning "-Weffc++"
-#      pragma GCC diagnostic warning "-pedantic"
-#    endif
-#  elif defined _MSC_VER
-#    pragma warning(pop)
-#  endif
-#endif
index 918db5410db1f082f33320d9b6ce6a0422e79cae..ca0a618f3ef86c3796d2d2897f93ba7282e64acc 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/io/boost.h>
 #include <pcl/io/file_io.h>
diff --git a/io/include/pcl/io/pxc_grabber.h b/io/include/pcl/io/pxc_grabber.h
deleted file mode 100644 (file)
index 245e64f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "PXCGrabber was deprecated and removed, please use DepthSenseGrabber instead"
index 28d36c4435680a54111eac32e7e4543b37495cc5..1691d879d6171b541cd1dbf3874533376e3fbd03 100644 (file)
 
 #pragma once
 
-#include <pcl/pcl_exports.h>
-
 #include <pxcsession.h>
 #include <pxccapture.h>
 #include <pxccapturemanager.h>
 
-#include <boost/utility.hpp>
+#include <pcl/memory.h>  // for pcl::shared_ptr, pcl::weak_ptr
+#include <pcl/pcl_exports.h>  // for PCL_EXPORTS
+
+#include <boost/core/noncopyable.hpp>  // for boost::noncopyable
 
-#include <memory>
+#include <cstddef>  // for std::size_t
+#include <mutex>  // for std::lock_guard, std::mutex
+#include <string>  // for std::string
+#include <vector>  // for std::vector
 
 namespace pcl
 {
@@ -104,7 +108,7 @@ namespace pcl
             pxcUID iuid;
             pxcI32 didx;
             std::string serial;
-            std::weak_ptr<RealSenseDevice> device_ptr;
+            weak_ptr<RealSenseDevice> device_ptr;
             inline bool isCaptured () { return (!device_ptr.expired ()); }
           };
 
@@ -132,8 +136,7 @@ namespace pcl
       {
 
         public:
-
-          using Ptr = std::shared_ptr<RealSenseDevice>;
+          using Ptr = pcl::shared_ptr<RealSenseDevice>;
 
           inline const std::string&
           getSerialNumber () { return (device_id_); }
index 5a197223225d677b6198d2403406833b07155b36..8fe9b1fe1e2dd34b12707ea5ed93e263086d029d 100644 (file)
@@ -160,7 +160,7 @@ namespace pcl
 
     /** \brief template function to convert realsense point cloud to PCL point cloud
     * \param[in] points - realsense point cloud array
-    * \param[in] dynamic function to convert individual point color or intensity values
+    * \param[in] mapColorFunc dynamic function to convert individual point color or intensity values
     */
     template <typename PointT, typename Functor>
     typename pcl::PointCloud<PointT>::Ptr
index 36ac096ff464887a5a2e108359f37d3757ad5e5a..4c2c8d51c983b6795f1ff549d22fe8e54e334f90 100644 (file)
@@ -38,7 +38,7 @@
 #pragma once
 
 #include <pcl/io/grabber.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
 #include <pcl/common/time.h>
index 92487f80a5fb8a8002be41ab612e529e2b8a3260..546b0d7d08abb0f33f7f145ada1ab6177ccb4ed2 100644 (file)
@@ -43,7 +43,7 @@
 #include <pcl/io/impl/synchronized_queue.hpp>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #include <boost/asio.hpp>
 
 #include <memory>
index 6ba3f6b75f228836fcee2a2d87f5bed275624da8..63133c38d33b4d43a8663722138e98fcfe0ddb20 100644 (file)
@@ -290,7 +290,7 @@ pcl::EnsensoGrabber::configureCapture (const bool auto_exposure,
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 bool
-pcl::EnsensoGrabber::grabSingleCloud (pcl::PointCloud<pcl::PointXYZ> &cloud)
+pcl::EnsensoGrabber::grabSingleCloud (pcl::PointCloud<pcl::PointXYZ> &cloud) const
 {
   if (!device_open_)
     return (false);
@@ -575,7 +575,7 @@ bool
 pcl::EnsensoGrabber::setExtrinsicCalibration (const double euler_angle,
                                               Eigen::Vector3d &rotation_axis,
                                               const Eigen::Vector3d &translation,
-                                              const std::string target)
+                                              const std::string target) const
 {
   if (!device_open_)
     return (false);
index 2cd87b594a0fba732cfa3e55c25fa25e4253ee8b..8e116e51beb7c8cf7646c5e993530966341320a4 100644 (file)
@@ -396,7 +396,7 @@ void
 pcl::HDLGrabber::computeXYZI (pcl::PointXYZI& point,
                               std::uint16_t azimuth,
                               HDLLaserReturn laserReturn,
-                              HDLLaserCorrection correction)
+                              HDLLaserCorrection correction) const
 {
   double cos_azimuth, sin_azimuth;
 
@@ -507,7 +507,7 @@ pcl::HDLGrabber::start ()
         }
         hdl_read_socket_ = new udp::socket (hdl_read_socket_service_, udp_listener_endpoint_);
       }
-      catch (const std::exception& bind)
+      catch (const std::exception&)
       {
         delete hdl_read_socket_;
         hdl_read_socket_ = new udp::socket (hdl_read_socket_service_, udp::endpoint (boost::asio::ip::address_v4::any (), udp_listener_endpoint_.port ()));
@@ -550,11 +550,8 @@ pcl::HDLGrabber::stop ()
     queue_consumer_thread_ = nullptr;
   }
 
-  if (hdl_read_socket_ != nullptr)
-  {
-    delete hdl_read_socket_;
-    hdl_read_socket_ = nullptr;
-  }
+  delete hdl_read_socket_;
+  hdl_read_socket_ = nullptr;
 }
 
 /////////////////////////////////////////////////////////////////////////////
index 680e2966cb1b624766fcd77c294b5340c0aee49a..3d23fa1a225896780eb749cdc96e9c3950ce31da 100644 (file)
@@ -39,6 +39,7 @@
 #include <pcl/io/image_grabber.h>
 #include <pcl/io/lzf_image_io.h>
 #include <pcl/io/pcd_io.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 struct pcl::ImageGrabberBase::ImageGrabberImpl
 {
   //! Implementation of ImageGrabber
-  ImageGrabberImpl (pcl::ImageGrabberBase& grabber, 
-                    const std::string& dir, 
-                    float frames_per_second, 
-                    bool repeat, 
+  ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
+                    const std::string& dir,
+                    float frames_per_second,
+                    bool repeat,
                     bool pclzf_mode=false);
   //! For now, split rgb / depth folders only makes sense for VTK images
-  ImageGrabberImpl (pcl::ImageGrabberBase& grabber, 
-                    const std::string& rgb_dir, 
-                    const std::string& depth_dir, 
-                    float frames_per_second, 
+  ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
+                    const std::string& rgb_dir,
+                    const std::string& depth_dir,
+                    float frames_per_second,
                     bool repeat);
-  ImageGrabberImpl (pcl::ImageGrabberBase& grabber, 
-                    const std::vector<std::string>& depth_image_files, 
-                    float frames_per_second, 
+  ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
+                    const std::vector<std::string>& depth_image_files,
+                    float frames_per_second,
                     bool repeat);
-  
-  void 
+
+  void
   trigger ();
   //! Read ahead -- figure out whether we are in VTK image or PCLZF mode
-  void 
+  void
   loadNextCloud ();
-  
+
   //! Get cloud at a particular location
   bool
   getCloudAt (std::size_t idx, pcl::PCLPointCloud2 &blob, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
               double &fx, double &fy, double &cx, double &cy) const;
-  
+
   //! Get cloud at a particular location
   bool
   getCloudVTK (std::size_t idx, pcl::PCLPointCloud2 &blob, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation) const;
@@ -110,7 +111,7 @@ struct pcl::ImageGrabberBase::ImageGrabberImpl
 
   //! True if it is an image we know how to read
   bool
-  isValidExtension (const std::string &extension);
+  isValidExtension (const std::string &extension) const;
 
   //! Convenience function to rewind to the last frame
   void
@@ -124,13 +125,13 @@ struct pcl::ImageGrabberBase::ImageGrabberImpl
   std::size_t
   numFrames () const;
 
-  
+
 #ifdef PCL_BUILT_WITH_VTK
   //! Load an image file, return the vtkImageReader2, return false if it couldn't be opened
   bool
   getVtkImage (const std::string &filename, vtkSmartPointer<vtkImageData> &image) const;
 #endif//PCL_BUILT_WITH_VTK
-  
+
   pcl::ImageGrabberBase& grabber_;
   float frames_per_second_;
   bool repeat_;
@@ -171,10 +172,10 @@ struct pcl::ImageGrabberBase::ImageGrabberImpl
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase& grabber, 
-                                                           const std::string& dir, 
-                                                           float frames_per_second, 
-                                                           bool repeat, 
+pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
+                                                           const std::string& dir,
+                                                           float frames_per_second,
+                                                           bool repeat,
                                                            bool pclzf_mode)
   : grabber_ (grabber)
   , frames_per_second_ (frames_per_second)
@@ -203,10 +204,10 @@ pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase& grabber, 
-                                                           const std::string& depth_dir, 
-                                                           const std::string& rgb_dir, 
-                                                           float frames_per_second, 
+pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
+                                                           const std::string& depth_dir,
+                                                           const std::string& rgb_dir,
+                                                           float frames_per_second,
                                                            bool repeat)
   : grabber_ (grabber)
   , frames_per_second_ (frames_per_second)
@@ -228,9 +229,9 @@ pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase& grabber, 
-                                                           const std::vector<std::string>& depth_image_files, 
-                                                           float frames_per_second, 
+pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
+                                                           const std::vector<std::string>& depth_image_files,
+                                                           float frames_per_second,
                                                            bool repeat)
   : grabber_ (grabber)
   , frames_per_second_ (frames_per_second)
@@ -252,7 +253,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::ImageGrabberImpl (pcl::ImageGrabberBase
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::ImageGrabberBase::ImageGrabberImpl::loadNextCloud ()
 {
   if (cur_frame_ >= numFrames ())
@@ -265,13 +266,13 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadNextCloud ()
       return;
     }
   }
-  valid_ = getCloudAt (cur_frame_, next_cloud_, origin_, orientation_, 
+  valid_ = getCloudAt (cur_frame_, next_cloud_, origin_, orientation_,
       focal_length_x_, focal_length_y_, principal_point_x_, principal_point_y_);
   cur_frame_++;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::ImageGrabberBase::ImageGrabberImpl::trigger ()
 {
   if (valid_)
@@ -301,7 +302,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string
     extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
     pathname = itr->path ().string ();
     basename = boost::filesystem::basename (itr->path ());
-    if (!boost::filesystem::is_directory (itr->status ()) 
+    if (!boost::filesystem::is_directory (itr->status ())
         && isValidExtension (extension))
     {
       if (basename.find ("rgb") < std::string::npos)
@@ -400,7 +401,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadPCLZFFiles (const std::string &dir)
     extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
     pathname = itr->path ().string ();
     basename = boost::filesystem::basename (itr->path ());
-    if (!boost::filesystem::is_directory (itr->status ()) 
+    if (!boost::filesystem::is_directory (itr->status ())
         && isValidExtension (extension))
     {
       if (basename.find ("rgb") < std::string::npos)
@@ -429,7 +430,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadPCLZFFiles (const std::string &dir)
 }
 ///////////////////////////////////////////////////////////////////////////////////////////
 bool
-pcl::ImageGrabberBase::ImageGrabberImpl::isValidExtension (const std::string &extension)
+pcl::ImageGrabberBase::ImageGrabberImpl::isValidExtension (const std::string &extension) const
 {
   bool valid;
   if(pclzf_mode_)
@@ -438,29 +439,29 @@ pcl::ImageGrabberBase::ImageGrabberImpl::isValidExtension (const std::string &ex
   }
   else
   {
-    valid = extension == ".TIFF" || extension == ".PNG" 
+    valid = extension == ".TIFF" || extension == ".PNG"
          || extension == ".JPG" || extension == ".JPEG"
          || extension == ".PPM";
   }
   return (valid);
 }
-  
+
 void
 pcl::ImageGrabberBase::ImageGrabberImpl::rewindOnce ()
 {
   if (cur_frame_ > 0)
     cur_frame_--;
 }
-  
+
 //////////////////////////////////////////////////////////////////////////
 bool
 pcl::ImageGrabberBase::ImageGrabberImpl::getTimestampFromFilepath (
-    const std::string &filepath, 
+    const std::string &filepath,
     std::uint64_t &timestamp) const
 {
   // For now, we assume the file is of the form frame_[22-char POSIX timestamp]_*
   char timestamp_str[256];
-  int result = std::sscanf (boost::filesystem::basename (filepath).c_str (), 
+  int result = std::sscanf (boost::filesystem::basename (filepath).c_str (),
                             "frame_%22s_%*s",
                             timestamp_str);
   if (result > 0)
@@ -474,16 +475,16 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getTimestampFromFilepath (
   }
   return (false);
 }
-  
+
 /////////////////////////////////////////////////////////////////////////////
 bool
-pcl::ImageGrabberBase::ImageGrabberImpl::getCloudAt (std::size_t idx, 
+pcl::ImageGrabberBase::ImageGrabberImpl::getCloudAt (std::size_t idx,
                                                      pcl::PCLPointCloud2 &blob,
-                                                     Eigen::Vector4f &origin, 
-                                                     Eigen::Quaternionf &orientation, 
-                                                     double &fx, 
-                                                     double &fy, 
-                                                     double &cx, 
+                                                     Eigen::Vector4f &origin,
+                                                     Eigen::Quaternionf &orientation,
+                                                     double &fx,
+                                                     double &fy,
+                                                     double &cx,
                                                      double &cy) const
 {
   if (!depth_image_files_.empty ())
@@ -501,9 +502,9 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudAt (std::size_t idx,
 }
 
 bool
-pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (std::size_t idx, 
+pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (std::size_t idx,
                                                       pcl::PCLPointCloud2 &blob,
-                                                      Eigen::Vector4f &origin, 
+                                                      Eigen::Vector4f &origin,
                                                       Eigen::Quaternionf &orientation) const
 {
 #ifdef PCL_BUILT_WITH_VTK
@@ -534,7 +535,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (std::size_t idx,
 
   // Fill in image data
   depth_pixel = static_cast<unsigned short*>(depth_image->GetScalarPointer ());
-  
+
   // Set up intrinsics
   float scaleFactorX, scaleFactorY;
   float centerX, centerY;
@@ -567,12 +568,12 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (std::size_t idx,
       {
         pcl::PointXYZRGBA &pt = cloud_color.at (x,y);
         float depth = static_cast<float> (*depth_pixel) * depth_image_units_;
-        if (depth == 0.0f) 
+        if (depth == 0.0f)
           pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN ();
         else
         {
           pt.x = (static_cast<float> (x) - centerX) * scaleFactorX * depth;
-          pt.y = (static_cast<float> (y) - centerY) * scaleFactorY * depth; 
+          pt.y = (static_cast<float> (y) - centerY) * scaleFactorY * depth;
           pt.z = depth;
         }
 
@@ -604,12 +605,12 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (std::size_t idx,
       {
         pcl::PointXYZ &pt = cloud.at (x,y);
         float depth = static_cast<float> (*depth_pixel) * depth_image_units_;
-        if (depth == 0.0f) 
+        if (depth == 0.0f)
           pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN ();
         else
         {
           pt.x = ((float)x - centerX) * scaleFactorX * depth;
-          pt.y = ((float)y - centerY) * scaleFactorY * depth; 
+          pt.y = ((float)y - centerY) * scaleFactorY * depth;
           pt.z = depth;
         }
       }
@@ -636,13 +637,13 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (std::size_t idx,
 }
 
 bool
-pcl::ImageGrabberBase::ImageGrabberImpl::getCloudPCLZF (std::size_t idx, 
+pcl::ImageGrabberBase::ImageGrabberImpl::getCloudPCLZF (std::size_t idx,
                                                         pcl::PCLPointCloud2 &blob,
-                                                        Eigen::Vector4f &origin, 
-                                                        Eigen::Quaternionf &orientation, 
-                                                        double &fx, 
-                                                        double &fy, 
-                                                        double &cx, 
+                                                        Eigen::Vector4f &origin,
+                                                        Eigen::Quaternionf &orientation,
+                                                        double &fx,
+                                                        double &fy,
+                                                        double &cx,
                                                         double &cy) const
 {
   if (idx > depth_pclzf_files_.size ())
@@ -671,10 +672,10 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudPCLZF (std::size_t idx,
       fy = focal_length_y_;
       cx = principal_point_x_;
       cy = principal_point_y_;
-      rgb.setParameters (manual_params); 
-      yuv.setParameters (manual_params); 
-      bayer.setParameters (manual_params); 
-      depth.setParameters (manual_params); 
+      rgb.setParameters (manual_params);
+      yuv.setParameters (manual_params);
+      bayer.setParameters (manual_params);
+      depth.setParameters (manual_params);
     }
     else
     {
@@ -729,7 +730,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudPCLZF (std::size_t idx,
       fy = focal_length_y_;
       cx = principal_point_x_;
       cy = principal_point_y_;
-      depth.setParameters (manual_params); 
+      depth.setParameters (manual_params);
     }
     else
     {
@@ -759,14 +760,14 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudPCLZF (std::size_t idx,
   origin = Eigen::Vector4f::Zero ();
   orientation = Eigen::Quaternionf::Identity ();
   return (true);
-}     
-   
+}
+
 ////////////////////////////////////////////////////////////////////////
 //
 #ifdef PCL_BUILT_WITH_VTK
 bool
 pcl::ImageGrabberBase::ImageGrabberImpl::getVtkImage (
-    const std::string &filename, 
+    const std::string &filename,
     vtkSmartPointer<vtkImageData> &image) const
 {
 
@@ -855,7 +856,7 @@ pcl::ImageGrabberBase::~ImageGrabberBase () noexcept
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::ImageGrabberBase::start ()
 {
   if (impl_->frames_per_second_ > 0)
@@ -868,7 +869,7 @@ pcl::ImageGrabberBase::start ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::ImageGrabberBase::stop ()
 {
   if (impl_->frames_per_second_ > 0)
@@ -888,35 +889,35 @@ pcl::ImageGrabberBase::trigger ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-bool 
+bool
 pcl::ImageGrabberBase::isRunning () const
 {
   return (impl_->running_);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-std::string 
+std::string
 pcl::ImageGrabberBase::getName () const
 {
   return ("ImageGrabber");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::ImageGrabberBase::rewind ()
 {
   impl_->cur_frame_ = 0;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-float 
+float
 pcl::ImageGrabberBase::getFramesPerSecond () const
 {
   return (impl_->frames_per_second_);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-bool 
+bool
 pcl::ImageGrabberBase::isRepeatOn () const
 {
   return (impl_->repeat_);
@@ -924,7 +925,7 @@ pcl::ImageGrabberBase::isRepeatOn () const
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 void
-pcl::ImageGrabberBase::setRGBImageFiles (const std::vector<std::string>& rgb_image_files) 
+pcl::ImageGrabberBase::setRGBImageFiles (const std::vector<std::string>& rgb_image_files)
 {
   impl_->rgb_image_files_ = rgb_image_files;
   impl_->cur_frame_ = 0;
@@ -933,9 +934,9 @@ pcl::ImageGrabberBase::setRGBImageFiles (const std::vector<std::string>& rgb_ima
 
 ///////////////////////////////////////////////////////
 void
-pcl::ImageGrabberBase::setCameraIntrinsics (const double focal_length_x, 
-                                            const double focal_length_y, 
-                                            const double principal_point_x, 
+pcl::ImageGrabberBase::setCameraIntrinsics (const double focal_length_x,
+                                            const double focal_length_y,
+                                            const double principal_point_x,
                                             const double principal_point_y)
 {
   impl_->focal_length_x_ = focal_length_x;
@@ -952,9 +953,9 @@ pcl::ImageGrabberBase::setCameraIntrinsics (const double focal_length_x,
 }
 
 void
-pcl::ImageGrabberBase::getCameraIntrinsics (double &focal_length_x, 
-                                            double &focal_length_y, 
-                                            double &principal_point_x, 
+pcl::ImageGrabberBase::getCameraIntrinsics (double &focal_length_x,
+                                            double &focal_length_y,
+                                            double &principal_point_x,
                                             double &principal_point_y) const
 {
   focal_length_x = impl_->focal_length_x_;
@@ -982,7 +983,7 @@ pcl::ImageGrabberBase::numFrames () const
 bool
 pcl::ImageGrabberBase::getCloudAt (std::size_t idx,
                                    pcl::PCLPointCloud2 &blob,
-                                   Eigen::Vector4f &origin, 
+                                   Eigen::Vector4f &origin,
                                    Eigen::Quaternionf &orientation) const
 {
   double fx, fy, cx, cy;
@@ -1020,7 +1021,7 @@ pcl::ImageGrabberBase::getPrevDepthFileName () const
   std::string basename = boost::filesystem::basename (pathname);
   return (basename);
 }
-    
+
 /////////////////////////////////////////////////////////////////////////////////////////
 std::string
 pcl::ImageGrabberBase::getDepthFileNameAtIndex (std::size_t idx) const
index 3069ec24dff9f1854dd64a19759da59268111643..5f22614de0ea158eda0bef3a4a9bf5c7da2c9c1b 100644 (file)
@@ -4,7 +4,7 @@
  * Point Cloud Library (PCL) - www.pointclouds.org
  * Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
  * Copyright (c) 2010-2011, Willow Garage, Inc.
- * 
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
@@ -17,7 +17,7 @@
  *     copyright notice, this list of conditions and the following
  *     disclaimer in the documentation and/or other materials provided
  *     with the distribution.
- * 
+ *
  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  *
  */
 
-#include <pcl/io/lzf.h>
-#include <cstring>
-#include <climits>
 #include <pcl/console/print.h>
+#include <pcl/io/lzf.h>
+
 #include <cerrno>
+#include <climits>
+#include <cstddef>
+#include <cstring>
 
 /*
  * Size of hashtable is (1 << HLOG) * sizeof (char *)
@@ -114,7 +116,7 @@ pcl::lzfCompress (const void *const in_data, unsigned int in_len,
 
     hval = (hval << 8) | ip[2];
     hslot = htab + IDX (hval);
-    const unsigned char *ref = *hslot + (static_cast<const unsigned char*> (in_data)); 
+    const unsigned char *ref = *hslot + (static_cast<const unsigned char*> (in_data));
     *hslot = static_cast<unsigned int> (ip - (static_cast<const unsigned char*> (in_data)));
 
     // off requires a type wide enough to hold a general pointer difference.
@@ -125,14 +127,14 @@ pcl::lzfCompress (const void *const in_data, unsigned int in_len,
     // special workaround for it.
 #if defined (WIN32) && defined (_M_X64) && defined (_MSC_VER)
     // workaround for missing POSIX compliance
-    unsigned _int64 off; 
+    unsigned _int64 off;
 #else
     unsigned long off;
 #endif
 
     if (
         // The next test will actually take care of this, but this is faster if htab is initialized
-        ref < ip 
+        ref < ip
         && (off = ip - ref - 1) < (1 << 13)
         && ref > static_cast<const unsigned char *> (in_data)
         && ref[2] == ip[2]
@@ -145,7 +147,7 @@ pcl::lzfCompress (const void *const in_data, unsigned int in_len,
     {
       // Match found at *ref++
       unsigned int len = 2;
-      ptrdiff_t maxlen = in_end - ip - len;
+      std::ptrdiff_t maxlen = in_end - ip - len;
       maxlen = maxlen > ((1 << 8) + (1 << 3)) ? ((1 << 8) + (1 << 3)) : maxlen;
 
       // First a faster conservative test
@@ -248,7 +250,7 @@ pcl::lzfCompress (const void *const in_data, unsigned int in_len,
     }
   }
 
-  // At most 3 bytes can be missing here 
+  // At most 3 bytes can be missing here
   if (op + 3 > out_end)
     return (0);
 
@@ -274,7 +276,7 @@ pcl::lzfCompress (const void *const in_data, unsigned int in_len,
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-unsigned int 
+unsigned int
 pcl::lzfDecompress (const void *const in_data,  unsigned int in_len,
                     void             *out_data, unsigned int out_len)
 {
index 3ef73bf16cac07e4af50bba45e80e1b0cc9da894..58e5f43c44eb8af0c022578501fa4e8cb4a2e578 100644 (file)
@@ -187,7 +187,7 @@ pcl::io::LZFImageWriter::writeParameter (const double &parameter,
   {
     boost::property_tree::xml_parser::read_xml (filename, pt, boost::property_tree::xml_parser::trim_whitespace);
   }
-  catch (std::exception& e)
+  catch (std::exception&)
   {}
 
   pt.put (tag, parameter);
@@ -206,7 +206,7 @@ pcl::io::LZFDepth16ImageWriter::writeParameters (const pcl::io::CameraParameters
   {
     boost::property_tree::xml_parser::read_xml (filename, pt, boost::property_tree::xml_parser::trim_whitespace);
   }
-  catch (std::exception& e)
+  catch (std::exception&)
   {}
 
   pt.put ("depth.focal_length_x", parameters.focal_length_x);
@@ -266,7 +266,7 @@ pcl::io::LZFRGB24ImageWriter::writeParameters (const pcl::io::CameraParameters &
   {
     boost::property_tree::xml_parser::read_xml (filename, pt, boost::property_tree::xml_parser::trim_whitespace);
   }
-  catch (std::exception& e)
+  catch (std::exception&)
   {}
 
   pt.put ("rgb.focal_length_x", parameters.focal_length_x);
index 7c7c9cbeb2dcc17e96bdf4683756d28be050b15e..223f7163da7c40e8355f2a0117860c48da897ebb 100644 (file)
@@ -573,7 +573,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
           }
           ++point_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert %s to vertex coordinates!", line.c_str ());
           return (-1);
@@ -602,7 +602,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
           }
           ++normal_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert line %s to vertex normal!", line.c_str ());
           return (-1);
@@ -715,7 +715,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::TextureMesh &mesh,
           }
           ++v_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert %s to vertex coordinates!", line.c_str ());
           return (-1);
@@ -736,7 +736,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::TextureMesh &mesh,
           }
           ++vn_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert line %s to vertex normal!", line.c_str ());
           return (-1);
@@ -757,7 +757,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::TextureMesh &mesh,
             coordinates.emplace_back(c[0]/c[2], c[1]/c[2]);
           ++vt_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert line %s to texture coordinates!", line.c_str ());
           return (-1);
@@ -905,7 +905,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::PolygonMesh &mesh,
           }
           ++v_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert %s to vertex coordinates!", line.c_str ());
           return (-1);
@@ -927,7 +927,7 @@ pcl::OBJReader::read (const std::string &file_name, pcl::PolygonMesh &mesh,
           }
           ++vn_idx;
         }
-        catch (const boost::bad_lexical_cast &e)
+        catch (const boost::bad_lexical_cast&)
         {
           PCL_ERROR ("Unable to convert line %s to vertex normal!", line.c_str ());
           return (-1);
index 42dd2ae6a7252e7776068d0414f855cf09bb017c..83789a45e0c56e7023e810276f5cb814c0579ede 100644 (file)
 #include <pcl/point_types.h>
 #include <pcl/common/time.h>
 #include <pcl/console/print.h>
-#include <pcl/io/boost.h>
+#include <pcl/io/boost.h>  // for boost::shared_array
+#include <pcl/memory.h>  // for dynamic_pointer_cast
 #include <pcl/exceptions.h>
+
 #include <iostream>
 
 namespace
@@ -82,7 +84,7 @@ ONIGrabber::ONIGrabber (const std::string& file_name, bool repeat, bool stream)
   , point_cloud_rgba_signal_ ()
 {
   openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
-  device_ = boost::dynamic_pointer_cast< openni_wrapper::DeviceONI> (driver.createVirtualDevice (file_name, repeat, stream));
+  device_ = dynamic_pointer_cast< openni_wrapper::DeviceONI> (driver.createVirtualDevice (file_name, repeat, stream));
 
   if (!device_->hasDepthStream ())
     PCL_THROW_EXCEPTION (pcl::IOException, "Device does not provide 3D information.");
index 39f1e712ed508d708b9206970414aae387bfeaca..19416eb31787346c93d9e4bdb3bb0e7b3aeeb4d4 100644 (file)
  *      Author: Julius Kammerl (jkammerl@willowgarage.com)
  */
 
-#include "pcl/io/openni2/openni2_convert.h"
-#include "pcl/io/io_exception.h"
-
-#include <boost/make_shared.hpp>
+#include <pcl/memory.h>
+#include <pcl/io/io_exception.h>
+#include <pcl/io/openni2/openni2_convert.h>
 
 #include <string>
 
+
 namespace pcl
 {
   namespace io
index a6dcb90ee407dd04e8f7f562ad33b956a39b10be..f838e2f5482e2127bad376bcf9523d3874ea348a 100644 (file)
@@ -33,7 +33,7 @@
 #include "pcl/io/openni2/openni2_convert.h"
 #include "pcl/io/openni2/openni2_device.h"
 #include "pcl/io/io_exception.h"
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include <mutex>
 #include <set>
@@ -226,7 +226,7 @@ pcl::io::openni2::OpenNI2DeviceManager::getDevice (const std::string& device_URI
 }
 
 OpenNI2Device::Ptr
-pcl::io::openni2::OpenNI2DeviceManager::getDeviceByIndex (int index)
+pcl::io::openni2::OpenNI2DeviceManager::getDeviceByIndex (int index) const
 {
   auto URIs = getConnectedDeviceURIs ();
   return pcl::make_shared<OpenNI2Device>( URIs->at (index) );
index a0a816e859a6968384593b42617a2bad27eb8430..2a22248af857e2cc892d66553c25bb7bab54dd82 100644 (file)
@@ -36,7 +36,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #ifdef __GNUC__
index 73dbfd08a95891ff8d504622274c01500a6e55cd..fee348e6ac2064813a469fc7e610da08f54039e0 100644 (file)
@@ -36,7 +36,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #ifdef __GNUC__
index 170518a2383e7c07c1bce8e60077c97e6915482d..56641b26a84f67799575d7713a821df0f0689d24 100644 (file)
@@ -36,7 +36,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #ifdef __GNUC__
index c0ae9eb69b09669906cdd99a6d762361a3a7f112..aca1a8a0d3621c06185354d278df596d63ba977d 100644 (file)
@@ -36,7 +36,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #ifdef __GNUC__
index 638b6a43c7fe5da808c81766e398ca5b2781c476..cd06198ca13d5678bfe2f9b180e7d9d78f133005 100644 (file)
@@ -36,7 +36,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #ifdef __GNUC__
index 1ac27ccb89818975cacbfb23a231ea37f904ef6f..2381999c7a2b4ec9fbf64211ffec11d94ddd4f52 100644 (file)
@@ -36,7 +36,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include <pcl/io/openni_camera/openni_image_bayer_grbg.h>
index 9d51d52034040542f953474bd6ed5ea53393e60a..6a3935fd39fc4b77cf1618625b1f3b8173c83866 100644 (file)
@@ -1,5 +1,5 @@
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include <pcl/io/openni_camera/openni_image_rgb24.h>
index fe2e7897e730ccfe54d37cdaa0882e9577793311..961d8a2842b024c4ea5dc2e0fe78cae9d5f4aa37 100644 (file)
@@ -35,7 +35,7 @@
  *
  */
 #include <pcl/pcl_config.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 #ifdef HAVE_OPENNI
 
 #include <pcl/io/openni_camera/openni_image_yuv_422.h>
index 28a1f0c43771efca9fa2b7cf7b2d7523f79a7021..c668297569033a92d93bcd3c2deefb82ddee4971 100644 (file)
@@ -39,6 +39,7 @@
 #include <pcl/io/pcd_grabber.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/io/tar.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
@@ -52,21 +53,21 @@ struct pcl::PCDGrabberBase::PCDGrabberImpl
   PCDGrabberImpl (pcl::PCDGrabberBase& grabber, const std::vector<std::string>& pcd_files, float frames_per_second, bool repeat);
   void trigger ();
   void readAhead ();
-  
+
   // TAR reading I/O
   int openTARFile (const std::string &file_name);
   void closeTARFile ();
   bool readTARHeader ();
-  
+
   //! Initialize (find the locations of all clouds, if we haven't yet)
   void
   scrapeForClouds (bool force=false);
 
   //! Get cloud at a particular location
   bool
-  getCloudAt (std::size_t idx, 
+  getCloudAt (std::size_t idx,
               pcl::PCLPointCloud2 &blob,
-              Eigen::Vector4f &origin, 
+              Eigen::Vector4f &origin,
               Eigen::Quaternionf &orientation);
 
   //! Returns the size
@@ -144,7 +145,7 @@ pcl::PCDGrabberBase::PCDGrabberImpl::PCDGrabberImpl (pcl::PCDGrabberBase& grabbe
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::PCDGrabberBase::PCDGrabberImpl::readAhead ()
 {
   PCDReader reader;
@@ -215,8 +216,8 @@ pcl::PCDGrabberBase::PCDGrabberImpl::readTARHeader ()
     return (false);
   }
 
-  // We only support regular files for now. 
-  // Additional file types in TAR include: hard links, symbolic links, device/special files, block devices, 
+  // We only support regular files for now.
+  // Additional file types in TAR include: hard links, symbolic links, device/special files, block devices,
   // directories, and named pipes.
   if (tar_header_.file_type[0] != '0' && tar_header_.file_type[0] != '\0')
   {
@@ -264,7 +265,7 @@ pcl::PCDGrabberBase::PCDGrabberImpl::openTARFile (const std::string &file_name)
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::PCDGrabberBase::PCDGrabberImpl::trigger ()
 {
   std::lock_guard<std::mutex> read_ahead_lock(read_ahead_mutex_);
@@ -276,7 +277,7 @@ pcl::PCDGrabberBase::PCDGrabberImpl::trigger ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::PCDGrabberBase::PCDGrabberImpl::scrapeForClouds (bool force)
 {
   // Do nothing if we've already scraped (unless force is set)
@@ -328,16 +329,16 @@ pcl::PCDGrabberBase::PCDGrabberImpl::scrapeForClouds (bool force)
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-bool 
-pcl::PCDGrabberBase::PCDGrabberImpl::getCloudAt (std::size_t idx, 
+bool
+pcl::PCDGrabberBase::PCDGrabberImpl::getCloudAt (std::size_t idx,
                                                  pcl::PCLPointCloud2 &blob,
-                                                 Eigen::Vector4f &origin, 
+                                                 Eigen::Vector4f &origin,
                                                  Eigen::Quaternionf &orientation)
 {
   scrapeForClouds (); // Make sure we've scraped
   if (idx >= numFrames ())
     return false;
-  
+
   PCDReader reader;
   int pcd_version;
   std::string filename = pcd_files_[cloud_idx_to_file_idx_[idx]];
@@ -372,7 +373,7 @@ pcl::PCDGrabberBase::~PCDGrabberBase () noexcept
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::PCDGrabberBase::start ()
 {
   if (impl_->frames_per_second_ > 0)
@@ -387,7 +388,7 @@ pcl::PCDGrabberBase::start ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::PCDGrabberBase::stop ()
 {
   if (impl_->frames_per_second_ > 0)
@@ -409,35 +410,35 @@ pcl::PCDGrabberBase::trigger ()
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-bool 
+bool
 pcl::PCDGrabberBase::isRunning () const
 {
   return (impl_->running_ && (impl_->pcd_iterator_ != impl_->pcd_files_.end()));
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-std::string 
+std::string
 pcl::PCDGrabberBase::getName () const
 {
   return ("PCDGrabber");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-void 
+void
 pcl::PCDGrabberBase::rewind ()
 {
   impl_->pcd_iterator_ = impl_->pcd_files_.begin ();
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-float 
+float
 pcl::PCDGrabberBase::getFramesPerSecond () const
 {
   return (impl_->frames_per_second_);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-bool 
+bool
 pcl::PCDGrabberBase::isRepeatOn () const
 {
   return (impl_->repeat_);
@@ -445,9 +446,9 @@ pcl::PCDGrabberBase::isRepeatOn () const
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 bool
-pcl::PCDGrabberBase::getCloudAt (std::size_t idx, 
+pcl::PCDGrabberBase::getCloudAt (std::size_t idx,
                                  pcl::PCLPointCloud2 &blob,
-                                 Eigen::Vector4f &origin, 
+                                 Eigen::Vector4f &origin,
                                  Eigen::Quaternionf &orientation) const
 {
   return (impl_->getCloudAt (idx, blob, origin, orientation));
@@ -459,4 +460,3 @@ pcl::PCDGrabberBase::numFrames () const
 {
   return (impl_->numFrames ());
 }
-
index d96aa35c093e4e040b2fdad80290972f06f2c04c..8ff9d61eb429bec0942ac05e70d0a80f4b6cb96a 100644 (file)
@@ -292,9 +292,9 @@ namespace pcl
     const auto cloud_vertices_ptr = points.get_vertices ();
     const auto cloud_texture_ptr = points.get_texture_coordinates ();
 
-#ifdef _OPENMP
-#pragma omp parallel for 
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(cloud, cloud_vertices_ptr, mapColorFunc)
     for (int index = 0; index < cloud->points.size (); ++index)
     {
       const auto ptr = cloud_vertices_ptr + index;
index 7f7e71cf89018e119c725f5a7a8045f4367f7cc3..ae654a272e054b34bc9ec1f3ff56eabdce087191 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include <pcl/io/robot_eye_grabber.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/console/print.h>
 
 /////////////////////////////////////////////////////////////////////////////
index 39d73b569a319e4e432feb566757eeb8f993f649..dd155ec41c9ba9e6d59abd08c9a3a427eb717d96 100644 (file)
 #include <pcl/io/auto_io.h>
 #include <pcl/io/obj_io.h>
 #include <pcl/io/vtk_lib_io.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 
-#include <boost/make_shared.hpp>
+#include <boost/filesystem.hpp>  // for boost::filesystem::path
+#include <boost/algorithm/string.hpp>  // for boost::algorithm::ends_with
 
 #define ASCII 0
 #define BINARY 1
@@ -169,7 +171,7 @@ saveMesh (pcl::PolygonMesh& input,
   {
     if (!input.polygons.empty ())
       PCL_WARN ("PCD file format does not support meshes! Only points be saved.\n");
-    pcl::PCLPointCloud2::Ptr cloud = boost::make_shared<pcl::PCLPointCloud2> (input.cloud);
+    pcl::PCLPointCloud2::Ptr cloud = pcl::make_shared<pcl::PCLPointCloud2> (input.cloud);
     if (!savePointCloud (cloud, output_file, output_type))
       return (false);
   }
index 90155263a76d7c5d295cff3fd57778080963fe1f..28ddb5b5597636ea1ca26a62fb4e836add77535b 100644 (file)
@@ -50,7 +50,7 @@ class SimpleOpenNIProcessor
     SimpleOpenNIProcessor (openni_wrapper::OpenNIDevice::DepthMode depth_mode = openni_wrapper::OpenNIDevice::OpenNI_12_bit_depth) : mode (depth_mode) {}
 
     void 
-    cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
+    cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud) const
     {
       static unsigned count = 0;
       static double last = pcl::getTime ();
index cd944a2abc41caf0a92237ef3056ee92c71fe555..a49048d05ea2d9e3085f649eed5efcab56c9e678 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <pcl/pcl_macros.h>
 
-PCL_PRAGMA_WARNING("This header is deprecated and will be removed in an upcoming release.")
+PCL_DEPRECATED_HEADER(1, 12, "")
 
 #if defined _MSC_VER
 #  pragma warning(disable: 4267 4244)
index 916187319f2ac89f49fe4a3e1a7b760013063629..df74eebcde7c3842b0aae608acdf4cb5bc27efb1 100644 (file)
@@ -39,6 +39,7 @@
 #pragma once
 
 #include <climits>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_representation.h>
index 159272d6da6d5727addcbb7a8335cb8dfae035b4..6c3d3e71d28882af58b3589bd1b18b20cc390a88 100644 (file)
@@ -92,7 +92,7 @@ namespace pcl
             */
           void 
           detectKeypoints (const std::vector<unsigned char> &intensity_data, 
-                           pcl::PointCloud<pcl::PointUV> &output);
+                           pcl::PointCloud<pcl::PointUV> &output) const;
 
           /** \brief Detects corner points. 
             * \param intensity_data
@@ -100,7 +100,7 @@ namespace pcl
             */
           void 
           detectKeypoints (const std::vector<float> &intensity_data, 
-                           pcl::PointCloud<pcl::PointUV> &output);
+                           pcl::PointCloud<pcl::PointUV> &output) const;
 
           /** \brief Applies non-max-suppression. 
             * \param[in] intensity_data the image data
@@ -227,7 +227,7 @@ namespace pcl
           void 
           computeCornerScores (const unsigned char* im, 
                                const std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > & corners_all, 
-                               std::vector<ScoreIndex> & scores);
+                               std::vector<ScoreIndex> & scores) const;
 
           /** \brief Computes corner scores for the specified points. 
             * \param im
@@ -237,7 +237,7 @@ namespace pcl
           void 
           computeCornerScores (const float* im, 
                                const std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > & corners_all, 
-                               std::vector<ScoreIndex> & scores);
+                               std::vector<ScoreIndex> & scores) const;
 
           /** \brief Width of the image to process. */
           std::size_t width_;
index 0d4412aae402e9422fab163aea15a1cd5fd4a322..fdec9424c6af60e27ed7190dea57203c78d82184 100644 (file)
 
 #pragma once
 
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/keypoints/agast_2d.h>
 
+
 namespace pcl
 {
   /** \brief Detects BRISK interest points based on the original code and paper
index 71eaffc9fd42ea23e1259c2394b4a1cdd9135837..59bdc2204296de76959f6d362347f07b03c539bc 100644 (file)
 
 #include <pcl/common/io.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT, typename IntensityT> bool
-pcl::AgastKeypoint2DBase<PointInT, PointOutT, IntensityT>::initCompute ()
+AgastKeypoint2DBase<PointInT, PointOutT, IntensityT>::initCompute ()
 {
   if (!pcl::Keypoint<PointInT, PointOutT>::initCompute ())
   {
@@ -52,7 +55,7 @@ pcl::AgastKeypoint2DBase<PointInT, PointOutT, IntensityT>::initCompute ()
   }
 
   if (!input_->isOrganized ())
-  {    
+  {
     PCL_ERROR ("[pcl::%s::initCompute] %s doesn't support non organized clouds!\n", name_.c_str ());
     return (false);
   }
@@ -60,9 +63,9 @@ pcl::AgastKeypoint2DBase<PointInT, PointOutT, IntensityT>::initCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> void
-pcl::AgastKeypoint2D<PointInT, PointOutT>::detectKeypoints (PointCloudOut &output)
+AgastKeypoint2D<PointInT, PointOutT>::detectKeypoints (PointCloudOut &output)
 {
   // image size
   const std::size_t width = input_->width;
@@ -97,6 +100,9 @@ pcl::AgastKeypoint2D<PointInT, PointOutT>::detectKeypoints (PointCloudOut &outpu
   output.is_dense = true;
 }
 
+} // namespace pcl
 
 #define AgastKeypoint2D(T,I) template class PCL_EXPORTS pcl::AgastKeypoint2D<T,I>;
-#endif 
+
+#endif
+
index 1e0002770739b591253399751c792d8f452337fe..839a1913a4988f393645a154e80b36d3526f5058 100644 (file)
 
 #include <pcl/common/io.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT, typename IntensityT> bool
-pcl::BriskKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
+BriskKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
 {
   if (!pcl::Keypoint<PointInT, PointOutT>::initCompute ())
   {
@@ -53,7 +56,7 @@ pcl::BriskKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
   }
 
   if (!input_->isOrganized ())
-  {    
+  {
     PCL_ERROR ("[pcl::%s::initCompute] %s doesn't support non organized clouds!\n", name_.c_str ());
     return (false);
   }
@@ -61,9 +64,9 @@ pcl::BriskKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::BriskKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCloudOut &output)
+BriskKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCloudOut &output)
 {
   // image size
   const int width = int (input_->width);
@@ -105,4 +108,7 @@ pcl::BriskKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointClo
   }
 }
 
-#endif 
+} // namespace pcl
+
+#endif
+
index 3bf611152886ebadf37a4ec9541b09622ed183ed..79713f7e63800907411b07c62e64b17b65b6c474 100644 (file)
  *
  */
 
+
 #ifndef PCL_HARRIS_KEYPOINT_2D_IMPL_H_
 #define PCL_HARRIS_KEYPOINT_2D_IMPL_H_
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setMethod (ResponseMethod method)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setMethod (ResponseMethod method)
 {
   method_ = method;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setThreshold (float threshold)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setThreshold (float threshold)
 {
   threshold_= threshold;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setRefine (bool do_refine)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setRefine (bool do_refine)
 {
   refine_ = do_refine;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setNonMaxSupression (bool nonmax)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setNonMaxSupression (bool nonmax)
 {
   nonmax_ = nonmax;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setWindowWidth (int window_width)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setWindowWidth (int window_width)
 {
   window_width_= window_width;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setWindowHeight (int window_height)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setWindowHeight (int window_height)
 {
   window_height_= window_height;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setSkippedPixels (int skipped_pixels)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setSkippedPixels (int skipped_pixels)
 {
   skipped_pixels_= skipped_pixels;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setMinimalDistance (int min_distance)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::setMinimalDistance (int min_distance)
 {
   min_distance_ = min_distance;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::computeSecondMomentMatrix (std::size_t index, float* coefficients) const
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::computeSecondMomentMatrix (std::size_t index, float* coefficients) const
 {
   static const int width = static_cast<int> (input_->width);
   static const int height = static_cast<int> (input_->height);
-  
+
   int x = static_cast<int> (index % input_->width);
   int y = static_cast<int> (index / input_->width);
   // indices        0   1   2
@@ -122,9 +126,9 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::computeSecondMomentMatri
     }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> bool
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
 {
   if (!pcl::Keypoint<PointInT, PointOutT>::initCompute ())
   {
@@ -133,17 +137,17 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
   }
 
   if (!input_->isOrganized ())
-  {    
+  {
     PCL_ERROR ("[pcl::%s::initCompute] %s doesn't support non organized clouds!\n", name_.c_str ());
     return (false);
   }
-  
+
   if (indices_->size () != input_->size ())
   {
     PCL_ERROR ("[pcl::%s::initCompute] %s doesn't support setting indices!\n", name_.c_str ());
     return (false);
   }
-  
+
   if ((window_height_%2) == 0)
   {
     PCL_ERROR ("[pcl::%s::initCompute] Window height must be odd!\n", name_.c_str ());
@@ -161,21 +165,21 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
     PCL_ERROR ("[pcl::%s::initCompute] Window size must be >= 3x3!\n", name_.c_str ());
     return (false);
   }
-  
+
   half_window_width_ = window_width_ / 2;
   half_window_height_ = window_height_ / 2;
 
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCloudOut &output)
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCloudOut &output)
 {
   derivatives_cols_.resize (input_->width, input_->height);
   derivatives_rows_.resize (input_->width, input_->height);
   //Compute cloud intensities first derivatives along columns and rows
-  //!!! nsallem 20120220 : we don't test here for density so if one term in nan the result is nan
+  //!!! nsallem 20120220 : we don't test here for density so if one term is nan the result is nan
   int w = static_cast<int> (input_->width) - 1;
   int h = static_cast<int> (input_->height) - 1;
   // j = 0 --> j-1 out of range ; use 0
@@ -212,9 +216,9 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCl
   derivatives_rows_(0,h) = (intensity_ ((*input_) (1,h)) - intensity_ ((*input_) (0,h))) * 0.5;
 
   for(int i = 1; i < w; ++i)
-       {
+  {
     derivatives_cols_(i,h) = (intensity_ ((*input_) (i,h)) - intensity_ ((*input_) (i,h-1))) * 0.5;
-       }
+  }
   derivatives_rows_(w,h) = (intensity_ ((*input_) (w,h)) - intensity_ ((*input_) (w-1,h))) * 0.5;
   derivatives_cols_(w,h) = (intensity_ ((*input_) (w,h)) - intensity_ ((*input_) (w,h-1))) * 0.5;
 
@@ -233,7 +237,7 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCl
       responseTomasi(*response_);
       break;
   }
-  
+
   if (!nonmax_)
   {
     output = *response_;
@@ -241,18 +245,28 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCl
       keypoints_indices_->indices.push_back (i);
   }
   else
-  {    
+  {
     std::sort (indices_->begin (), indices_->end (), [this] (int p1, int p2) { return greaterIntensityAtIndices (p1, p2); });
-    float threshold = threshold_ * response_->points[indices_->front ()].intensity;
+    const float threshold = threshold_ * response_->points[indices_->front ()].intensity;
     output.clear ();
     output.reserve (response_->size());
-    std::vector<bool> occupency_map (response_->size (), false);    
+    std::vector<bool> occupency_map (response_->size (), false);
     int width (response_->width);
     int height (response_->height);
     const int occupency_map_size (occupency_map.size ());
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output, occupency_map) firstprivate (width, height) num_threads(threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for                                       \
+  default(none)                                                \
+  shared(occupency_map, output)                                \
+  firstprivate(width, height)                                  \
+  num_threads(threads_)
+#else
+#pragma omp parallel for                                       \
+  default(none)                                                \
+  shared(occupency_map, occupency_map_size, output, threshold) \
+  firstprivate(width, height)                                  \
+  num_threads(threads_)        
 #endif
     for (int i = 0; i < occupency_map_size; ++i)
     {
@@ -260,17 +274,15 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCl
       const PointOutT& point_out = response_->points [idx];
       if (occupency_map[idx] || point_out.intensity < threshold || !isFinite (point_out))
         continue;
-        
-#ifdef _OPENMP
+
 #pragma omp critical
-#endif
       {
         output.push_back (point_out);
         keypoints_indices_->indices.push_back (idx);
       }
-      
-                       int u_end = std::min (width, idx % width + min_distance_);
-                       int v_end = std::min (height, idx / width + min_distance_);
+
+      int u_end = std::min (width, idx % width + min_distance_);
+      int v_end = std::min (height, idx / width + min_distance_);
       for(int u = std::max (0, idx % width - min_distance_); u < u_end; ++u)
         for(int v = std::max (0, idx / width - min_distance_); v < v_end; ++v)
           occupency_map[v*input_->width+u] = true;
@@ -287,17 +299,27 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCl
   output.is_dense = input_->is_dense;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseHarris (PointCloudOut &output) const
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseHarris (PointCloudOut &output) const
 {
   PCL_ALIGN (16) float covar [3];
   output.clear ();
   output.resize (input_->size ());
   const int output_size (output.size ());
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (covar) num_threads(threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output)              \
+  private(covar)              \
+  num_threads(threads_)
+#else
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output, output_size) \
+  private(covar)              \
+  num_threads(threads_)
 #endif
   for (int index = 0; index < output_size; ++index)
   {
@@ -323,17 +345,27 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseHarris (PointClo
   output.width = input_->width;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseNoble (PointCloudOut &output) const
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseNoble (PointCloudOut &output) const
 {
   PCL_ALIGN (16) float covar [3];
   output.clear ();
   output.resize (input_->size ());
   const int output_size (output.size ());
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (covar) num_threads(threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output)              \
+  private(covar)              \
+  num_threads(threads_)
+#else
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output, output_size) \
+  private(covar)              \
+  num_threads(threads_)
 #endif
   for (int index = 0; index < output_size; ++index)
   {
@@ -344,7 +376,7 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseNoble (PointClou
     out_point.z = in_point.z;
     out_point.intensity = 0;
     if (isFinite (in_point))
-    {    
+    {
       computeSecondMomentMatrix (index, covar);
       float trace = covar [0] + covar [2];
       if (trace != 0)
@@ -352,26 +384,36 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseNoble (PointClou
         float det = covar[0] * covar[2] - covar[1] * covar[1];
         out_point.intensity = det / trace;
       }
-    }    
+    }
   }
-  
+
   output.height = input_->height;
   output.width = input_->width;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseLowe (PointCloudOut &output) const
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseLowe (PointCloudOut &output) const
 {
   PCL_ALIGN (16) float covar [3];
   output.clear ();
   output.resize (input_->size ());
   const int output_size (output.size ());
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (covar) num_threads(threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output)              \
+  private(covar)              \
+  num_threads(threads_)
+#else
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output, output_size) \
+  private(covar)              \
+  num_threads(threads_)
 #endif
-  for (int index = 0; index < output_size; ++index)      
+  for (int index = 0; index < output_size; ++index)
   {
     PointOutT &out_point = output.points [index];
     const PointInT &in_point = input_->points [index];
@@ -380,7 +422,7 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseLowe (PointCloud
     out_point.z = in_point.z;
     out_point.intensity = 0;
     if (isFinite (in_point))
-    {    
+    {
       computeSecondMomentMatrix (index, covar);
       float trace = covar [0] + covar [2];
       if (trace != 0)
@@ -395,17 +437,27 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseLowe (PointCloud
   output.width = input_->width;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseTomasi (PointCloudOut &output) const
+HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseTomasi (PointCloudOut &output) const
 {
   PCL_ALIGN (16) float covar [3];
   output.clear ();
   output.resize (input_->size ());
   const int output_size (output.size ());
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) private (covar) num_threads(threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output)              \
+  private(covar)              \
+  num_threads(threads_)
+#else
+#pragma omp parallel for      \
+  default(none)               \
+  shared(output, output_size) \
+  private(covar)              \
+  num_threads(threads_)
 #endif
   for (int index = 0; index < output_size; ++index)
   {
@@ -416,60 +468,20 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::responseTomasi (PointClo
     out_point.z = in_point.z;
     out_point.intensity = 0;
     if (isFinite (in_point))
-    {      
+    {
       computeSecondMomentMatrix (index, covar);
       // min egenvalue
       out_point.intensity = ((covar[0] + covar[2] - sqrt((covar[0] - covar[2])*(covar[0] - covar[2]) + 4 * covar[1] * covar[1])) /2.0f);
-    }    
+    }
   }
-  
+
   output.height = input_->height;
   output.width = input_->width;
 }
 
-// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// template <typename PointInT, typename PointOutT, typename IntensityT> void
-// pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::refineCorners (PointCloudOut &corners) const
-// {
-//   std::vector<int> nn_indices;
-//   std::vector<float> nn_dists;
-
-//   Eigen::Matrix2f nnT;
-//   Eigen::Matrix2f NNT;
-//   Eigen::Matrix2f NNTInv;
-//   Eigen::Vector2f NNTp;
-//   float diff;
-//   const unsigned max_iterations = 10;
-// #ifdef _OPENMP
-//   #pragma omp parallel for shared (corners) private (nnT, NNT, NNTInv, NNTp, diff, nn_indices, nn_dists) num_threads(threads_)
-// #endif
-//   for (int cIdx = 0; cIdx < static_cast<int> (corners.size ()); ++cIdx)
-//   {
-//     unsigned iterations = 0;
-//     do {
-//       NNT.setZero();
-//       NNTp.setZero();
-//       PointInT corner;
-//       corner.x = corners[cIdx].x;
-//       corner.y = corners[cIdx].y;
-//       corner.z = corners[cIdx].z;
-//       tree_->radiusSearch (corner, search_radius_, nn_indices, nn_dists);
-//       for (std::vector<int>::const_iterator iIt = nn_indices.begin(); iIt != nn_indices.end(); ++iIt)
-//       {
-//         if (!std::isfinite (normals_->points[*iIt].normal_x))
-//           continue;
-
-//         nnT = normals_->points[*iIt].getNormalVector3fMap () * normals_->points[*iIt].getNormalVector3fMap ().transpose();
-//         NNT += nnT;
-//         NNTp += nnT * surface_->points[*iIt].getVector3fMap ();
-//       }
-//       if (invert3x3SymMatrix (NNT, NNTInv) != 0)
-//         corners[cIdx].getVector3fMap () = NNTInv * NNTp;
-
-//       diff = (corners[cIdx].getVector3fMap () - corner.getVector3fMap()).squaredNorm ();
-//     } while (diff > 1e-6 && ++iterations < max_iterations);
-//   }
-// }
+} // namespace pcl
 
 #define PCL_INSTANTIATE_HarrisKeypoint2D(T,U,I) template class PCL_EXPORTS pcl::HarrisKeypoint2D<T,U,I>;
+
 #endif // #ifndef PCL_HARRIS_KEYPOINT_2D_IMPL_H_
+
index 14e2c2df58569a2b7dd568bafdb9f3255e67abe7..4cc061f1e70852255b112394041b3e9f42671d19 100644 (file)
@@ -276,9 +276,10 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloud
     output.points.clear ();
     output.points.reserve (response->points.size());
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads(threads_)   
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output, response) \
+  num_threads(threads_)
     for (int idx = 0; idx < static_cast<int> (response->points.size ()); ++idx)
     {
       if (!isFinite (response->points[idx]) ||
@@ -299,9 +300,7 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloud
         }
       }
       if (is_maxima)
-#ifdef _OPENMP
 #pragma omp critical
-#endif
       {
         output.points.push_back (response->points[idx]);
         keypoints_indices_->indices.push_back (idx);
@@ -323,9 +322,11 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::responseHarris (PointCloudO
 {
   PCL_ALIGN (16) float covar [8];
   output.resize (input_->size ());
-#ifdef _OPENMP
-  #pragma omp parallel for shared (output) private (covar) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  private(covar) \
+  num_threads(threads_)
   for (int pIdx = 0; pIdx < static_cast<int> (input_->size ()); ++pIdx)
   {
     const PointInT& pointIn = input_->points [pIdx];
@@ -362,9 +363,11 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::responseNoble (PointCloudOu
 {
   PCL_ALIGN (16) float covar [8];
   output.resize (input_->size ());
-#ifdef _OPENMP
-  #pragma omp parallel for shared (output) private (covar) num_threads(threads_)
-#endif
+#pragma omp parallel \
+  for default(none) \
+  shared(output) \
+  private(covar) \
+  num_threads(threads_)
   for (int pIdx = 0; pIdx < static_cast<int> (input_->size ()); ++pIdx)
   {
     const PointInT& pointIn = input_->points [pIdx];
@@ -400,9 +403,11 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::responseLowe (PointCloudOut
 {
   PCL_ALIGN (16) float covar [8];
   output.resize (input_->size ());
-#ifdef _OPENMP
-  #pragma omp parallel for shared (output) private (covar) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  private(covar) \
+  num_threads(threads_)
   for (int pIdx = 0; pIdx < static_cast<int> (input_->size ()); ++pIdx)
   {
     const PointInT& pointIn = input_->points [pIdx];
@@ -457,9 +462,11 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::responseTomasi (PointCloudO
   PCL_ALIGN (16) float covar [8];
   Eigen::Matrix3f covariance_matrix;
   output.resize (input_->size ());
-#ifdef _OPENMP
-  #pragma omp parallel for shared (output) private (covar, covariance_matrix) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output) \
+  private(covar, covariance_matrix) \
+  num_threads(threads_)
   for (int pIdx = 0; pIdx < static_cast<int> (input_->size ()); ++pIdx)
   {
     const PointInT& pointIn = input_->points [pIdx];
@@ -503,9 +510,11 @@ pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::refineCorners (PointCloudOu
   Eigen::Vector3f NNTp;
   float diff;
   const unsigned max_iterations = 10;
-#ifdef _OPENMP
-  #pragma omp parallel for shared (corners) private (nnT, NNT, NNTInv, NNTp, diff) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(corners) \
+  private(nnT, NNT, NNTInv, NNTp, diff) \
+  num_threads(threads_)
   for (int cIdx = 0; cIdx < static_cast<int> (corners.size ()); ++cIdx)
   {
     unsigned iterations = 0;
index 4b05db49ac78019ad3368387a3fef3fc5871fe14..47c56ca2618932c9b89ad83508d4fb1fb807bfe1 100644 (file)
@@ -164,9 +164,9 @@ pcl::HarrisKeypoint6D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloud
 
   pcl::PointCloud<pcl::PointXYZI>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZI>);
   cloud->resize (surface_->size ());
-#ifdef _OPENMP
-  #pragma omp parallel for num_threads(threads_) default(shared)
-#endif  
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
   for (unsigned idx = 0; idx < surface_->size (); ++idx)
   {
     cloud->points [idx].x = surface_->points [idx].x;
@@ -184,9 +184,9 @@ pcl::HarrisKeypoint6D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloud
   grad_est.setRadiusSearch (search_radius_);
   grad_est.compute (*intensity_gradients_);
   
-#ifdef _OPENMP
-  #pragma omp parallel for num_threads(threads_) default (shared)
-#endif    
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
   for (std::size_t idx = 0; idx < intensity_gradients_->size (); ++idx)
   {
     float len = intensity_gradients_->points [idx].gradient_x * intensity_gradients_->points [idx].gradient_x +
@@ -227,9 +227,9 @@ pcl::HarrisKeypoint6D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloud
     output.points.clear ();
     output.points.reserve (response->points.size());
 
-#ifdef _OPENMP
-  #pragma omp parallel for num_threads(threads_) default(shared)
-#endif  
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
     for (std::size_t idx = 0; idx < response->points.size (); ++idx)
     {
       if (!isFinite (response->points[idx]) || response->points[idx].intensity < threshold_)
@@ -248,9 +248,7 @@ pcl::HarrisKeypoint6D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloud
         }
       }
       if (is_maxima)
-#ifdef _OPENMP
         #pragma omp critical
-#endif
       {
         output.points.push_back (response->points[idx]);
         keypoints_indices_->indices.push_back (idx);
@@ -275,9 +273,10 @@ pcl::HarrisKeypoint6D<PointInT, PointOutT, NormalT>::responseTomasi (PointCloudO
   Eigen::SelfAdjointEigenSolver <Eigen::Matrix<float, 6, 6> > solver;
   Eigen::Matrix<float, 6, 6> covariance;
 
-#ifdef _OPENMP
-  #pragma omp parallel for default (shared) private (pointOut, covar, covariance, solver) num_threads(threads_)
-#endif  
+#pragma omp parallel for \
+  default(none) \
+  private(pointOut, covar, covariance, solver) \
+  num_threads(threads_)
   for (unsigned pIdx = 0; pIdx < input_->size (); ++pIdx)
   {
     const PointInT& pointIn = input_->points [pIdx];
@@ -347,10 +346,8 @@ pcl::HarrisKeypoint6D<PointInT, PointOutT, NormalT>::responseTomasi (PointCloudO
     pointOut.x = pointIn.x;
     pointOut.y = pointIn.y;
     pointOut.z = pointIn.z;
-#ifdef _OPENMP
-    #pragma omp critical
-#endif
 
+    #pragma omp critical
     output.points.push_back(pointOut);
   }
   output.height = input_->height;
index 2ee9f0c05cf382e20f7893552ead7e541c1acd9e..5537ad4f5ec963c2202c5d113958b85088a1350a 100644 (file)
@@ -112,9 +112,11 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::getBoundaryPoints (PointCloudI
   pcl::BoundaryEstimation<PointInT, NormalT, pcl::Boundary> boundary_estimator;
   boundary_estimator.setInputCloud (input_);
 
-#ifdef _OPENMP
-#pragma omp parallel for private(u, v) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(angle_threshold, boundary_estimator, border_radius, edge_points, input) \
+  private(u, v) \
+  num_threads(threads_)
   for (int index = 0; index < int (input.points.size ()); index++)
   {
     edge_points[index] = false;
@@ -233,13 +235,11 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::initCompute ()
     return (false);
   }
 
-  if (third_eigen_value_)
     delete[] third_eigen_value_;
 
   third_eigen_value_ = new double[input_->size ()];
   memset(third_eigen_value_, 0, sizeof(double) * input_->size ());
 
-  if (edge_points_)
     delete[] edge_points_;
 
   if (border_radius_ > 0.0)
@@ -299,9 +299,10 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut
 
   bool* borders = new bool [input_->size()];
 
-#ifdef _OPENMP
-  #pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(borders) \
+  num_threads(threads_)
   for (int index = 0; index < int (input_->size ()); index++)
   {
     borders[index] = false;
@@ -342,9 +343,10 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut
   for (std::size_t i = 0; i < input_->size (); i++)
     prg_mem[i] = prg_local_mem + 3 * i;
 
-#ifdef _OPENMP
-  #pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(borders, omp_mem, prg_mem) \
+  num_threads(threads_)
   for (int index = 0; index < static_cast<int> (input_->size ()); index++)
   {
 #ifdef _OPENMP
@@ -395,11 +397,11 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut
   }
 
   bool* feat_max = new bool [input_->size()];
-  bool is_max;
 
-#ifdef _OPENMP
-  #pragma omp parallel for private(is_max) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(feat_max) \
+  num_threads(threads_)
   for (int index = 0; index < int (input_->size ()); index++)
   {
     feat_max [index] = false;
@@ -417,7 +419,7 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut
 
       if (n_neighbors >= min_neighbors_)
       {
-        is_max = true;
+        bool is_max = true;
 
         for (int j = 0 ; j < n_neighbors; j++)
           if (third_eigen_value_[index] < third_eigen_value_[nn_indices[j]])
@@ -428,15 +430,14 @@ pcl::ISSKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut
     }
   }
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(feat_max, output) \
+  num_threads(threads_)
   for (int index = 0; index < int (input_->size ()); index++)
   {
     if (feat_max[index])
-#ifdef _OPENMP
 #pragma omp critical
-#endif
     {
       PointOutT p;
       p.getVector3fMap () = input_->points[index].getVector3fMap ();
index 024534f3fe4e5f5412957487a36cd8981045bb52..5a29c4448ce59546918ce94e49b0a7fb9ef1bea8 100644 (file)
  *
  */
 
+
 #ifndef PCL_KEYPOINT_IMPL_H_
 #define PCL_KEYPOINT_IMPL_H_
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT> bool
-pcl::Keypoint<PointInT, PointOutT>::initCompute ()
+Keypoint<PointInT, PointOutT>::initCompute ()
 {
   if (!PCLBase<PointInT>::initCompute ())
     return (false);
@@ -124,9 +128,9 @@ pcl::Keypoint<PointInT, PointOutT>::initCompute ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT> inline void
-pcl::Keypoint<PointInT, PointOutT>::compute (PointCloudOut &output)
+Keypoint<PointInT, PointOutT>::compute (PointCloudOut &output)
 {
   if (!initCompute ())
   {
@@ -144,5 +148,7 @@ pcl::Keypoint<PointInT, PointOutT>::compute (PointCloudOut &output)
     surface_.reset ();
 }
 
+} // namespace pcl
+
 #endif  //#ifndef PCL_KEYPOINT_IMPL_H_
 
index 11a220b7421b4db4cdf19679c772b4130d1c138d..8e95bb9dceb461a6915208bdfa361244dbdecc2c 100644 (file)
@@ -309,9 +309,6 @@ pcl::SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT>::detectKeypoints (P
   label_idx_ = pcl::getFieldIndex<PointOutT> ("label", out_fields_);
 
   const int input_size = static_cast<int> (input_->size ());
-//#ifdef _OPENMP
-//#pragma omp parallel for shared (response) num_threads(threads_)
-//#endif
   for (int point_index = 0; point_index < input_size; ++point_index)
   {
     const PointInT& point_in = input_->points [point_index];
@@ -362,9 +359,6 @@ pcl::SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT>::detectKeypoints (P
           memcpy (reinterpret_cast<char*> (&point_out) + out_fields_[label_idx_].offset,
                   &label, sizeof (std::uint32_t));
         }
-//#ifdef _OPENMP
-//#pragma omp critical
-//#endif
         response->push_back (point_out);
       }
       else
@@ -398,9 +392,6 @@ pcl::SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT>::detectKeypoints (P
               memcpy (reinterpret_cast<char*> (&point_out) + out_fields_[label_idx_].offset,
                       &label, sizeof (std::uint32_t));
             }
-//#ifdef _OPENMP
-//#pragma omp critical
-//#endif
             response->push_back (point_out);
           }
         }
@@ -424,9 +415,6 @@ pcl::SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT>::detectKeypoints (P
     output.points.clear ();
     output.points.reserve (response->points.size());
     
-//#ifdef _OPENMP
-//#pragma omp parallel for shared (output) num_threads(threads_)   
-//#endif
     for (int idx = 0; idx < static_cast<int> (response->points.size ()); ++idx)
     {
       const PointOutT& point_in = response->points [idx];
@@ -449,9 +437,6 @@ pcl::SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT>::detectKeypoints (P
         }
       }
       if (is_minima)
-//#ifdef _OPENMP
-//#pragma omp critical
-//#endif
       {
         output.points.push_back (response->points[idx]);
         keypoints_indices_->indices.push_back (idx);
index b9c83ed46dc24fb25d8827e223f980ae853931ac..d5edfa207ccb11097c995673c6727be182b4024c 100644 (file)
  *
  */
 
+
 #ifndef PCL_TRAJKOVIC_KEYPOINT_2D_IMPL_H_
 #define PCL_TRAJKOVIC_KEYPOINT_2D_IMPL_H_
 
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT, typename IntensityT> bool
-pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
+TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
 {
   if (!PCLBase<PointInT>::initCompute ())
     return (false);
@@ -76,18 +81,25 @@ pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::initCompute ()
   return (true);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename IntensityT> void
-pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCloudOut &output)
+TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCloudOut &output)
 {
   response_.reset (new pcl::PointCloud<float> (input_->width, input_->height));
-  int w = static_cast<int> (input_->width) - half_window_size_;
-  int h = static_cast<int> (input_->height) - half_window_size_;
+  const int w = static_cast<int> (input_->width) - half_window_size_;
+  const int h = static_cast<int> (input_->height) - half_window_size_;
 
   if (method_ == pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::FOUR_CORNERS)
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(h, w) \
+  num_threads(threads_)
 #endif
     for(int j = half_window_size_; j < h; ++j)
     {
@@ -127,8 +139,15 @@ pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (Poin
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(h, w) \
+  num_threads(threads_)
 #endif
     for(int j = half_window_size_; j < h; ++j)
     {
@@ -216,8 +235,16 @@ pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (Poin
   const int width (input_->width);
   const int height (input_->height);
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  shared(indices, occupency_map, output) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(height, indices, occupency_map, output, width) \
+  num_threads(threads_)
 #endif
   for (std::size_t i = 0; i < indices.size (); ++i)
   {
@@ -229,9 +256,7 @@ pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (Poin
     p.getVector3fMap () = input_->points[idx].getVector3fMap ();
     p.intensity = response_->points [idx];
 
-#ifdef _OPENMP
 #pragma omp critical
-#endif
     {
       output.push_back (p);
       keypoints_indices_->indices.push_back (idx);
@@ -252,5 +277,9 @@ pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (Poin
   output.is_dense = input_->is_dense;
 }
 
+} // namespace pcl
+
 #define PCL_INSTANTIATE_TrajkovicKeypoint2D(T,U,I) template class PCL_EXPORTS pcl::TrajkovicKeypoint2D<T,U,I>;
+
 #endif
+
index a9a679735cda16b54c5794fccd0e3b99f45d360e..d8b4eba1bd28d3ea19e0efa1caf80f9b9532e953 100644 (file)
 
 #include <pcl/features/integral_image_normal.h>
 
+
+namespace pcl
+{
+
 template <typename PointInT, typename PointOutT, typename NormalT> bool
-pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::initCompute ()
+TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::initCompute ()
 {
   if (!PCLBase<PointInT>::initCompute ())
     return (false);
@@ -89,9 +93,9 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::initCompute ()
   return (true);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename PointOutT, typename NormalT> void
-pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut &output)
+TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut &output)
 {
   response_.reset (new pcl::PointCloud<float> (input_->width, input_->height));
   const Normals &normals = *normals_;
@@ -102,8 +106,16 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCl
 
   if (method_ == FOUR_CORNERS)
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  shared(input, normals, response) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(h, input, normals, response, w) \
+  num_threads(threads_)
 #endif
     for(int j = half_window_size_; j < h; ++j)
     {
@@ -144,8 +156,16 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCl
   }
   else
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  shared(input, normals, response) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(h, input, normals, response, w) \
+  num_threads(threads_)
 #endif
     for(int j = half_window_size_; j < h; ++j)
     {
@@ -230,8 +250,16 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCl
   const int width (input_->width);
   const int height (input_->height);
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
+#if OPENMP_LEGACY_CONST_DATA_SHARING_RULE
+#pragma omp parallel for \
+  default(none) \
+  shared(indices, occupency_map, output) \
+  num_threads(threads_)
+#else
+#pragma omp parallel for \
+  default(none) \
+  shared(height, indices, occupency_map, output, width) \
+  num_threads(threads_)
 #endif
   for (int i = 0; i < static_cast<int>(indices.size ()); ++i)
   {
@@ -243,9 +271,7 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCl
     p.getVector3fMap () = input_->points[idx].getVector3fMap ();
     p.intensity = response_->points [idx];
 
-#ifdef _OPENMP
 #pragma omp critical
-#endif
     {
       output.push_back (p);
       keypoints_indices_->indices.push_back (idx);
@@ -266,5 +292,9 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCl
   output.is_dense = true;
 }
 
+} // namespace pcl
+
 #define PCL_INSTANTIATE_TrajkovicKeypoint3D(T,U,N) template class PCL_EXPORTS pcl::TrajkovicKeypoint3D<T,U,N>;
+
 #endif
+
index 29c72f0929e11cd68322911f754b343ff8168464..ef07ae6ab22c97b8f262b4e8b4a3f6b378f68e71 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
index 7266dcfe159b500c6d15ae7ab268f9d9f160a60b..4b9da1352c0661c07eff5e8c94201733e544a37d 100644 (file)
@@ -40,7 +40,7 @@
 #pragma once
 
 #ifdef __DEPRECATED
-#warning UniformSampling is not a Keypoint anymore, use <pcl/filters/uniform_sampling.h> instead.
+PCL_DEPRECATED_HEADER(1, 12, "UniformSampling is not a Keypoint anymore, use <pcl/filters/uniform_sampling.h> instead.")
 #endif
 
 #include <pcl/filters/uniform_sampling.h>
index 82a00a970ec7b932a35e9267384b001df4d3f559..c2884d07e407a3ba77df560cc7e6d839ffcf42d6 100644 (file)
@@ -79,7 +79,7 @@ pcl::AgastKeypoint2D<pcl::PointXYZ, pcl::PointUV>::detectKeypoints (pcl::PointCl
 void
 pcl::keypoints::agast::AbstractAgastDetector::detectKeypoints (
     const std::vector<unsigned char> & intensity_data,
-    pcl::PointCloud<pcl::PointUV> &output)
+    pcl::PointCloud<pcl::PointUV> &output) const
 {
   detect (&(intensity_data[0]), output.points);
 
@@ -91,7 +91,7 @@ pcl::keypoints::agast::AbstractAgastDetector::detectKeypoints (
 void
 pcl::keypoints::agast::AbstractAgastDetector::detectKeypoints (
     const std::vector<float> & intensity_data,
-    pcl::PointCloud<pcl::PointUV> &output)
+    pcl::PointCloud<pcl::PointUV> &output) const
 {
   detect (&(intensity_data[0]), output.points);
 
@@ -297,7 +297,7 @@ void
 pcl::keypoints::agast::AbstractAgastDetector::computeCornerScores (
   const unsigned char* im,
   const std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all,
-  std::vector<ScoreIndex> &scores)
+  std::vector<ScoreIndex> &scores) const
 {
   unsigned int num_corners = static_cast<unsigned int> (corners_all.size ());
 
@@ -327,7 +327,7 @@ void
 pcl::keypoints::agast::AbstractAgastDetector::computeCornerScores (
   const float* im,
   const std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all,
-  std::vector<ScoreIndex> &scores)
+  std::vector<ScoreIndex> &scores) const
 {
   unsigned int num_corners = static_cast<unsigned int> (corners_all.size ());
 
index 26717e9dd8a756008333190def76cc7d033c9478..a23572cfad514ad5628baffc737b78fb0288a573 100644 (file)
@@ -279,8 +279,13 @@ NarfKeypoint::calculateCompleteInterestImage ()
     was_touched.resize (array_size, false);
     std::vector<int> neighbors_to_check;
     
-#   pragma omp parallel for num_threads (parameters_.max_no_of_threads) default (shared) \
-                            firstprivate (was_touched, neighbors_to_check, angle_histogram) schedule (dynamic, 10)
+#pragma omp parallel for \
+  default(none) \
+  shared(array_size, border_descriptions, interest_image, range_image, radius_reciprocal, radius_squared, scale_idx, \
+         surface_change_directions, surface_change_scores, start_usage_range) \
+  firstprivate(was_touched, neighbors_to_check, angle_histogram) \
+  schedule(dynamic, 10) \
+  num_threads(parameters_.max_no_of_threads)
     for (int index=0; index<array_size; ++index)
     {
       float& interest_value = interest_image[index];
@@ -473,9 +478,13 @@ NarfKeypoint::calculateSparseInterestImage ()
                    neighbors_within_radius_overhead;
   
   //double interest_value_calculation_start_time = getTime ();
-# pragma omp parallel for default (shared) num_threads (parameters_.max_no_of_threads) schedule (guided, 10) \
-                          firstprivate (was_touched, neighbors_to_check, angle_histogram, neighbors_within_radius_overhead, \
-                                        angle_elements, relevant_point_still_valid) 
+#pragma omp parallel for \
+  default(none) \
+  shared(array_size, border_descriptions, increased_radius_squared, radius_reciprocal, radius_overhead_squared, range_image, search_radius, \
+         surface_change_directions, surface_change_scores) \
+  num_threads(parameters_.max_no_of_threads) \
+  schedule(guided, 10) \
+  firstprivate(was_touched, neighbors_to_check, angle_histogram, neighbors_within_radius_overhead, angle_elements, relevant_point_still_valid) 
   for (int index=0; index<array_size; ++index)
   {
     if (interest_image_[index] <= 1.0f)
index 0b636f93e98553dad4c788b9bb50866981ba7cf4..8870a42e0693edcab4e3c7a3f72197f46feeb504 100644 (file)
@@ -86,4 +86,4 @@ PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/dt" ${dt_incs})
 PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/ferns" ${ferns_incs})
 PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl/dt" ${dt_impl_incs})
 PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl/ferns" ${ferns_impl_incs})
-PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl/svm" ${svm_impl_incs})
\ No newline at end of file
+PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl/svm" ${svm_impl_incs})
index 5f16522b7de6ff1d028d959f61f18016675d6ef3..cb63e853017afece3e0e6569e876ffcb96c1f100 100644 (file)
 
 #pragma once
 
+#include <pcl/ml/pairwise_potential.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
 
-#include <pcl/ml/pairwise_potential.h>
-
 namespace pcl {
 
 class PCL_EXPORTS DenseCrf {
@@ -107,7 +107,7 @@ public:
   expAndNormalize(std::vector<float>& out,
                   const std::vector<float>& in,
                   float scale,
-                  float relax = 1.0f);
+                  float relax = 1.0f) const;
 
   void
   expAndNormalizeORI(float* out,
index 83d8e799834e43395aeaea168289bd722fbcafa0..02cc485a8b774a2ba9c08e0980a769cc17ae9423 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_tree.h>
 
 #include <istream>
index e4595ada31516392dcf6343f1f3ceebfa6ea0435..59652eb468111233eb34e21460002f2193feaf8a 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_forest.h>
 #include <pcl/ml/dt/decision_tree_evaluator.h>
 #include <pcl/ml/feature_handler.h>
index 499a256fbe4ee69a0adbd6051a5abbcd580e096b..b177198622ee127d8870ea8a23c92c264292ae70 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_forest.h>
 #include <pcl/ml/dt/decision_tree.h>
 #include <pcl/ml/dt/decision_tree_trainer.h>
index fc13b283ec85f2f77f21845e71e48a2e212ce724..96b7b55aaa9094bf79cfc0905ac22ada9943c5dc 100644 (file)
@@ -37,9 +37,9 @@
 
 #pragma once
 
-#include <boost/shared_ptr.hpp>
-
 #include <pcl/common/common.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h> // for PCL_EXPORTS
 
 namespace pcl {
 template <class FeatureType,
index 0729a76290e66d4d7de5069909f1bda8aa20ab01..8ce72d0808284b15455f370722d769ff62ab7355 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_tree.h>
 #include <pcl/ml/feature_handler.h>
 #include <pcl/ml/stats_estimator.h>
index 7513b6698ecc809f3629f93106c6937f9d8d0d7c..3920182af96832496b43bad66d7fc8aff17d970f 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_tree.h>
 #include <pcl/ml/dt/decision_tree_data_provider.h>
 #include <pcl/ml/feature_handler.h>
index 6477dde0c42fef9c8173893a0ae2b8dcc8e94c9e..77fb46f5cbe113559cf6911ada06c3ab9364ca28 100644 (file)
@@ -142,7 +142,8 @@ public:
    *
    * \param node_index the index of the node to access
    */
-  inline NodeType& operator[](const std::size_t node_index)
+  inline NodeType&
+  operator[](const std::size_t node_index)
   {
     return nodes_[node_index];
   }
@@ -151,7 +152,8 @@ public:
    *
    * \param node_index the index of the node to access
    */
-  inline const NodeType& operator[](const std::size_t node_index) const
+  inline const NodeType&
+  operator[](const std::size_t node_index) const
   {
     return nodes_[node_index];
   }
index f869b44ae6d2d7dc1ba576f4cada21d8feddf4ec..d3f3c46150ed1b6d37e0634a2b12520822f21d19 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/feature_handler.h>
 #include <pcl/ml/ferns/fern.h>
 #include <pcl/ml/stats_estimator.h>
index f07f60ea0c57f8a083df21ebdd7bd2e08243259c..cda71bc3b25848ccb116331d1983d39e64000fb5 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/feature_handler.h>
 #include <pcl/ml/ferns/fern.h>
 #include <pcl/ml/stats_estimator.h>
index b9cfee01d85cc2bda5e96b02fe58d0dcf19499cb..61243ccc955cbc1beb936549789498fd1f8d54f2 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_forest.h>
 #include <pcl/ml/dt/decision_forest_evaluator.h>
 #include <pcl/ml/feature_handler.h>
index 019454e661c5710312d47d40687ed8691c5e96c0..23b3796164bd02a7106073c74d896dc689f12def 100644 (file)
 
 #pragma once
 
+namespace pcl {
+
 template <class FeatureType,
           class DataSet,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     DecisionForestTrainer()
 : num_of_trees_to_train_(1), decision_tree_trainer_()
 {}
@@ -52,7 +54,7 @@ template <class FeatureType,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     ~DecisionForestTrainer()
 {}
 
@@ -62,8 +64,8 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
-    train(pcl::DecisionForest<NodeType>& forest)
+DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train(
+    pcl::DecisionForest<NodeType>& forest)
 {
   for (std::size_t tree_index = 0; tree_index < num_of_trees_to_train_; ++tree_index) {
     pcl::DecisionTree<NodeType> tree;
@@ -72,3 +74,5 @@ pcl::DecisionForestTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeTy
     forest.push_back(tree);
   }
 }
+
+} // namespace pcl
index 3d55a850a3a14c85e029916e055c01b65f9c857d..db7f24e5124300b35c77bf24d05bd6dff50b7ca6 100644 (file)
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/dt/decision_tree.h>
 #include <pcl/ml/feature_handler.h>
 #include <pcl/ml/stats_estimator.h>
 
 #include <vector>
 
+namespace pcl {
+
 template <class FeatureType,
           class DataSet,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     DecisionTreeEvaluator()
 {}
 
@@ -59,7 +60,7 @@ template <class FeatureType,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     ~DecisionTreeEvaluator()
 {}
 
@@ -69,7 +70,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     evaluate(pcl::DecisionTree<NodeType>& tree,
              pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
              pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>&
@@ -106,7 +107,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     evaluateAndAdd(
         pcl::DecisionTree<NodeType>& tree,
         pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
@@ -143,7 +144,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     evaluate(pcl::DecisionTree<NodeType>& tree,
              pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
              pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>&
@@ -152,7 +153,6 @@ pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeTy
              ExampleIndex example,
              NodeType& leave)
 {
-
   NodeType* node = &(tree.getRoot());
 
   while (!node->sub_nodes.empty()) {
@@ -177,7 +177,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     getNodes(pcl::DecisionTree<NodeType>& tree,
              pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
              pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>&
@@ -206,3 +206,5 @@ pcl::DecisionTreeEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeTy
     nodes.push_back(node);
   }
 }
+
+} // namespace pcl
index 74db81ce780f9b794b20e74198d99571334e62d8..8a01488d0f3092cfd038d5de686e48fdb754b14b 100644 (file)
 
 #pragma once
 
+namespace pcl {
+
 template <class FeatureType,
           class DataSet,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     DecisionTreeTrainer()
 : max_tree_depth_(15)
 , num_of_features_(1000)
@@ -61,7 +63,7 @@ template <class FeatureType,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     ~DecisionTreeTrainer()
 {}
 
@@ -71,8 +73,8 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
-    train(pcl::DecisionTree<NodeType>& tree)
+DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train(
+    pcl::DecisionTree<NodeType>& tree)
 {
   // create random features
   std::vector<FeatureType> features;
@@ -107,7 +109,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     trainDecisionTreeNode(std::vector<FeatureType>& features,
                           std::vector<ExampleIndex>& examples,
                           std::vector<LabelType>& label_data,
@@ -272,7 +274,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     createThresholdsUniform(const std::size_t num_of_thresholds,
                             std::vector<float>& values,
                             std::vector<float>& thresholds)
@@ -303,3 +305,5 @@ pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType
         min_value + step * (static_cast<float>(threshold_index + 1));
   }
 }
+
+} // namespace pcl
index ade2cc83ab90f5d77c10812dc20aec756023f5dd..28bb49a15b50683c5c5aa64d01f437b59d6a545a 100644 (file)
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/feature_handler.h>
 #include <pcl/ml/ferns/fern.h>
 #include <pcl/ml/stats_estimator.h>
 
 #include <vector>
 
+namespace pcl {
+
 template <class FeatureType,
           class DataSet,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
-    FernEvaluator()
+FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::FernEvaluator()
 {}
 
 template <class FeatureType,
@@ -59,8 +59,7 @@ template <class FeatureType,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
-    ~FernEvaluator()
+FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::~FernEvaluator()
 {}
 
 template <class FeatureType,
@@ -69,7 +68,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::evaluate(
+FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::evaluate(
     pcl::Fern<FeatureType, NodeType>& fern,
     pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
     pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>& stats_estimator,
@@ -123,15 +122,13 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
-    evaluateAndAdd(
-        pcl::Fern<FeatureType, NodeType>& fern,
-        pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
-        pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>&
-            stats_estimator,
-        DataSet& data_set,
-        std::vector<ExampleIndex>& examples,
-        std::vector<LabelType>& label_data)
+FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::evaluateAndAdd(
+    pcl::Fern<FeatureType, NodeType>& fern,
+    pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
+    pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>& stats_estimator,
+    DataSet& data_set,
+    std::vector<ExampleIndex>& examples,
+    std::vector<LabelType>& label_data)
 {
   const std::size_t num_of_examples = examples.size();
   const std::size_t num_of_branches = stats_estimator.getNumOfBranches();
@@ -177,7 +174,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::getNodes(
+FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::getNodes(
     pcl::Fern<FeatureType, NodeType>& fern,
     pcl::FeatureHandler<FeatureType, DataSet, ExampleIndex>& feature_handler,
     pcl::StatsEstimator<LabelType, NodeType, DataSet, ExampleIndex>& stats_estimator,
@@ -224,3 +221,5 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::get
     nodes.push_back(&(fern[node_index]));
   }
 }
+
+} // namespace pcl
index 608c56ffc071f113666b0b250dca74d7a0f5a898..182869c241d6399bb446d5f26da992a5d0235f83 100644 (file)
 
 #pragma once
 
+namespace pcl {
+
 template <class FeatureType,
           class DataSet,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::FernTrainer()
+FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::FernTrainer()
 : fern_depth_(10)
 , num_of_features_(1000)
 , num_of_thresholds_(10)
@@ -58,8 +60,7 @@ template <class FeatureType,
           class LabelType,
           class ExampleIndex,
           class NodeType>
-pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
-    ~FernTrainer()
+FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::~FernTrainer()
 {}
 
 template <class FeatureType,
@@ -68,7 +69,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train(
+FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train(
     pcl::Fern<FeatureType, NodeType>& fern)
 {
   const std::size_t num_of_branches = stats_estimator_->getNumOfBranches();
@@ -295,7 +296,7 @@ template <class FeatureType,
           class ExampleIndex,
           class NodeType>
 void
-pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
+FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     createThresholdsUniform(const std::size_t num_of_thresholds,
                             std::vector<float>& values,
                             std::vector<float>& thresholds)
@@ -325,3 +326,5 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
     thresholds[threshold_index] = min_value + step * (threshold_index + 1);
   }
 }
+
+} // namespace pcl
index ee02c1ef4f7e2e949a2de14645d2c046c8b864ba..9933b50bf3ea2220371ad0bde2cf930630e39388 100644 (file)
 //#include <stdlib.h>
 //#include <time.h>
 
+namespace pcl {
 template <typename PointT>
-pcl::Kmeans<PointT>::Kmeans() : cluster_field_name_("")
+Kmeans<PointT>::Kmeans() : cluster_field_name_("")
 {}
 
 template <typename PointT>
-pcl::Kmeans<PointT>::~Kmeans()
+Kmeans<PointT>::~Kmeans()
 {}
 
 template <typename PointT>
 void
-pcl::Kmeans<PointT>::k_means()
-{}
-
-template <typename PointT>
-void
-pcl::Kmeans<PointT>::cluster(std::vector<PointIndices>& clusters)
+Kmeans<PointT>::cluster(std::vector<PointIndices>& clusters)
 {
   if (!initCompute() || (input_ != 0 && input_->points.empty()) ||
       (indices_ != 0 && indices_->empty())) {
@@ -162,5 +158,6 @@ pcl::Kmeans<PointT>::cluster(std::vector<PointIndices>& clusters)
 
   deinitCompute();
 }
+} // namespace pcl
 
 #define PCL_INSTANTIATE_Kmeans(T) template class PCL_EXPORTS pcl::Kmeans<T>;
index 1cac4e6d535a4601ee21448d9a56c3cb5456a5e9..af77608cbc0ebfbdf14b6de8fc09a9c42f5eaee7 100644 (file)
 
 #pragma once
 
-#include <set>
-
 #include <pcl/common/io.h>
 #include <pcl/console/parse.h>
 #include <pcl/console/print.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_base.h>
+#include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
 
-#include <pcl/pcl_base.h>
-#include <pcl/pcl_macros.h>
+#include <set>
 
 namespace pcl {
 
index 93d9372b2f832cee152f2a9fd749babb2861de47..0c0991c9544179e07684fbb9429090ff3930d4c1 100644 (file)
@@ -38,7 +38,6 @@
 #pragma once
 
 #include <pcl/common/common.h>
-
 #include <pcl/ml/feature_handler.h>
 #include <pcl/ml/multi_channel_2d_comparison_feature.h>
 #include <pcl/ml/multi_channel_2d_data_set.h>
index 9b16bdc56c3fc02ccf3f67ce5d7059e3369b6bd0..c37beba0f92d28ae3de5cc3e6e068fdd811dbd33 100644 (file)
 
 #pragma once
 
-#include <vector>
-
 #include <pcl/ml/permutohedral.h>
 
+#include <vector>
+
 namespace pcl {
 
 class PairwisePotential {
index bfee8267620d823808cef80ba027bf6c8fe75ce2..c2ca9e2e256658a55cfd5a6b89b2592dcb318dd0 100644 (file)
 #pragma GCC system_header
 #endif
 
-#include <boost/intrusive/hashtable.hpp>
-#include <map>
 #include <pcl/common/eigen.h>
-#include <vector>
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h>
+
+#include <boost/intrusive/hashtable.hpp>
 
-// TODO: SWAP with Boost intrusive hash table
 #include <cassert>
 #include <cmath>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
-
-#include <pcl/pcl_macros.h>
+#include <map>
+#include <vector>
 
 namespace pcl {
+
 /** Implementation of a high-dimensional gaussian filtering using the permutohedral
  *  lattice.
  *
index 0e7a63b6e0237fa23c0d8afe9e6d6eaad71c1da7..6604d96984a17cfad1cf2daa98f77b38f298af9d 100644 (file)
@@ -38,6 +38,9 @@
 
 #pragma once
 
+#include <pcl/common/eigen.h>
+#include <pcl/ml/svm.h>
+
 #include <cctype>
 #include <cerrno>
 #include <cstdio>
 #include <cstring>
 #include <fstream>
 #include <iostream>
-#include <pcl/common/eigen.h>
 #include <vector>
-
-#include <pcl/ml/svm.h>
 #define Malloc(type, n) static_cast<type*>(malloc((n) * sizeof(type)))
 
 namespace pcl {
@@ -163,7 +163,7 @@ protected:
 
   /** Convert the libSVM format (svm_problem) into a easier output format. */
   void
-  adaptLibSVMToInput(std::vector<SVMData>& training_set, svm_problem prob);
+  adaptLibSVMToInput(std::vector<SVMData>& training_set, svm_problem prob) const;
 
   /** Load a problem from an extern file. */
   bool
index a152e07854108f009685b6a5e93212c5ce60be8a..effdf09db28f27411cd2434a0528336708a01024 100644 (file)
@@ -235,7 +235,7 @@ void
 pcl::DenseCrf::expAndNormalize(std::vector<float>& out,
                                const std::vector<float>& in,
                                float scale,
-                               float relax)
+                               float relax) const
 {
   std::vector<float> V(N_ + 10);
   for (int i = 0; i < N_; i++) {
index 93d5df23480aad2e3979c3a01bdd8ec2111680c9..74cba05a4cf13c6d4fa8bd58c8978d735f3aa779 100644 (file)
@@ -39,6 +39,8 @@
 #ifndef _LIBSVM_HPP_
 #define _LIBSVM_HPP_
 
+#include <pcl/ml/svm.h>
+
 #include <cctype>
 #include <cfloat>
 #include <climits>
@@ -48,7 +50,6 @@
 #include <cstdlib>
 #include <cstring>
 #include <iostream>
-#include <pcl/ml/svm.h>
 int libsvm_version = LIBSVM_VERSION;
 using Qfloat = float;
 using schar = signed char;
@@ -3178,6 +3179,7 @@ svm_load_model(const char* model_file_name)
         free(model->rho);
         free(model->label);
         free(model->nSV);
+        free(model->scaling);
         free(model);
         return nullptr;
       }
@@ -3198,6 +3200,7 @@ svm_load_model(const char* model_file_name)
         free(model->rho);
         free(model->label);
         free(model->nSV);
+        free(model->scaling);
         free(model);
         return nullptr;
       }
@@ -3297,6 +3300,7 @@ svm_load_model(const char* model_file_name)
       free(model->rho);
       free(model->label);
       free(model->nSV);
+      free(model->scaling);
       free(model);
       return nullptr;
     }
@@ -3385,8 +3389,14 @@ svm_load_model(const char* model_file_name)
 
   // printf("%d e %f\n",model->scaling[j-2].index,model->scaling[j-2].value);
 
-  if (ferror(fp) != 0 || fclose(fp) != 0)
+  if (ferror(fp) != 0 || fclose(fp) != 0) {
+    free(model->rho);
+    free(model->label);
+    free(model->nSV);
+    free(model->scaling);
+    free(model);
     return nullptr;
+  }
 
   model->free_sv = 1; // XXX
 
index ae3d9aa5afa8f1b2e47ea62ba7ab55a554f2b9eb..29df338b10d5aba076fe95d1fd86839cd3a3fe11 100644 (file)
 #ifndef PCL_SVM_WRAPPER_HPP_
 #define PCL_SVM_WRAPPER_HPP_
 
+#include <pcl/ml/svm_wrapper.h>
+
 #include <cassert>
 #include <fstream>
-#include <pcl/ml/svm_wrapper.h>
 
 char*
 pcl::SVM::readline(FILE* input)
@@ -145,7 +146,7 @@ pcl::SVMTrain::scaleFactors(std::vector<SVMData> training_set, svm_scaling& scal
 };
 
 void
-pcl::SVM::adaptLibSVMToInput(std::vector<SVMData>& training_set, svm_problem prob)
+pcl::SVM::adaptLibSVMToInput(std::vector<SVMData>& training_set, svm_problem prob) const
 {
   training_set.clear(); // Reset input
 
index d7521bc619af92a5883cae55c056c8586b39e408..5cca01422ed2de857ec65b2c11cb5e117ce2121e 100644 (file)
 #ifndef PCL_OCTREE_BASE_HPP
 #define PCL_OCTREE_BASE_HPP
 
-#include <vector>
-
 #include <pcl/impl/instantiate.hpp>
 
+#include <vector>
+
 namespace pcl {
 namespace octree {
 //////////////////////////////////////////////////////////////////////////////////////////////
index d2ee37338535b4ef921c5dfd7f355c71832a818e..eb5a499186fa7ecb594085759c5f5b435b3c8b9e 100644 (file)
  * $Id$
  */
 
-#ifndef PCL_OCTREE_POINTCLOUD_HPP_
-#define PCL_OCTREE_POINTCLOUD_HPP_
-
-#include <cassert>
+#pragma once
 
 #include <pcl/common/common.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/octree/impl/octree_base.hpp>
 
+#include <cassert>
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT,
           typename LeafContainerT,
@@ -1052,5 +1052,3 @@ pcl::octree::OctreePointCloud<PointT, LeafContainerT, BranchContainerT, OctreeT>
       pcl::octree::OctreeContainerEmpty,                                               \
       pcl::octree::Octree2BufBase<pcl::octree::OctreeContainerEmpty,                   \
                                   pcl::octree::OctreeContainerEmpty>>;
-
-#endif /* OCTREE_POINTCLOUD_HPP_ */
index adf3ac5c33b5e080967ac1ddab919b2ae3e89c7d..ba7cc8f51cac117ed3f25e4d6f613f3dafe581d5 100644 (file)
  *
  */
 
-#ifndef PCL_OCTREE_POINTCLOUD_ADJACENCY_HPP_
-#define PCL_OCTREE_POINTCLOUD_ADJACENCY_HPP_
+#pragma once
 
 #include <pcl/common/geometry.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/console/print.h>
+
 /*
  * OctreePointCloudAdjacency is not precompiled, since it's used in other
  * parts of PCL with custom LeafContainers. So if PCL_NO_PRECOMPILE is NOT
@@ -330,5 +331,3 @@ pcl::octree::OctreePointCloudAdjacency<PointT, LeafContainerT, BranchContainerT>
 
 #define PCL_INSTANTIATE_OctreePointCloudAdjacency(T)                                   \
   template class PCL_EXPORTS pcl::octree::OctreePointCloudAdjacency<T>;
-
-#endif
index 9a72e3dcc535abc27357312bfa744440aad7454e..16b98ce0f98fb22d5e553ad1879c939a6e266734 100644 (file)
 
 #include <cassert>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+namespace pcl {
+
+namespace octree {
+
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 bool
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    voxelSearch(const PointT& point, std::vector<int>& point_idx_data)
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::voxelSearch(
+    const PointT& point, std::vector<int>& point_idx_data)
 {
   assert(isFinite(point) &&
          "Invalid (NaN, Inf) point coordinates given to nearestKSearch!");
@@ -65,24 +68,22 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (b_success);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 bool
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    voxelSearch(const int index, std::vector<int>& point_idx_data)
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::voxelSearch(
+    const int index, std::vector<int>& point_idx_data)
 {
   const PointT search_point = this->getPointByIndex(index);
   return (this->voxelSearch(search_point, point_idx_data));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    nearestKSearch(const PointT& p_q,
-                   int k,
-                   std::vector<int>& k_indices,
-                   std::vector<float>& k_sqr_distances)
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::nearestKSearch(
+    const PointT& p_q,
+    int k,
+    std::vector<int>& k_indices,
+    std::vector<float>& k_sqr_distances)
 {
   assert(this->leaf_count_ > 0);
   assert(isFinite(p_q) &&
@@ -119,24 +120,19 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return static_cast<int>(k_indices.size());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    nearestKSearch(int index,
-                   int k,
-                   std::vector<int>& k_indices,
-                   std::vector<float>& k_sqr_distances)
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::nearestKSearch(
+    int index, int k, std::vector<int>& k_indices, std::vector<float>& k_sqr_distances)
 {
   const PointT search_point = this->getPointByIndex(index);
   return (nearestKSearch(search_point, k, k_indices, k_sqr_distances));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 void
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    approxNearestSearch(const PointT& p_q, int& result_index, float& sqr_distance)
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::approxNearestSearch(
+    const PointT& p_q, int& result_index, float& sqr_distance)
 {
   assert(this->leaf_count_ > 0);
   assert(isFinite(p_q) &&
@@ -151,26 +147,24 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 void
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    approxNearestSearch(int query_index, int& result_index, float& sqr_distance)
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::approxNearestSearch(
+    int query_index, int& result_index, float& sqr_distance)
 {
   const PointT search_point = this->getPointByIndex(query_index);
 
   return (approxNearestSearch(search_point, result_index, sqr_distance));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    radiusSearch(const PointT& p_q,
-                 const double radius,
-                 std::vector<int>& k_indices,
-                 std::vector<float>& k_sqr_distances,
-                 unsigned int max_nn) const
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::radiusSearch(
+    const PointT& p_q,
+    const double radius,
+    std::vector<int>& k_indices,
+    std::vector<float>& k_sqr_distances,
+    unsigned int max_nn) const
 {
   assert(isFinite(p_q) &&
          "Invalid (NaN, Inf) point coordinates given to nearestKSearch!");
@@ -192,28 +186,26 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (static_cast<int>(k_indices.size()));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    radiusSearch(int index,
-                 const double radius,
-                 std::vector<int>& k_indices,
-                 std::vector<float>& k_sqr_distances,
-                 unsigned int max_nn) const
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::radiusSearch(
+    int index,
+    const double radius,
+    std::vector<int>& k_indices,
+    std::vector<float>& k_sqr_distances,
+    unsigned int max_nn) const
 {
   const PointT search_point = this->getPointByIndex(index);
 
   return (radiusSearch(search_point, radius, k_indices, k_sqr_distances, max_nn));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    boxSearch(const Eigen::Vector3f& min_pt,
-              const Eigen::Vector3f& max_pt,
-              std::vector<int>& k_indices) const
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::boxSearch(
+    const Eigen::Vector3f& min_pt,
+    const Eigen::Vector3f& max_pt,
+    std::vector<int>& k_indices) const
 {
 
   OctreeKey key;
@@ -226,10 +218,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (static_cast<int>(k_indices.size()));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 double
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     getKNearestNeighborRecursive(
         const PointT& point,
         unsigned int K,
@@ -339,10 +330,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (smallest_squared_dist);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 void
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     getNeighborsWithinRadiusRecursive(const PointT& point,
                                       const double radiusSquared,
                                       const BranchNode* node,
@@ -427,10 +417,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 void
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     approxNearestSearchRecursive(const PointT& point,
                                  const BranchNode* node,
                                  const OctreeKey& key,
@@ -517,25 +506,23 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 float
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    pointSquaredDist(const PointT& point_a, const PointT& point_b) const
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::pointSquaredDist(
+    const PointT& point_a, const PointT& point_b) const
 {
   return (point_a.getVector3fMap() - point_b.getVector3fMap()).squaredNorm();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 void
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
-    boxSearchRecursive(const Eigen::Vector3f& min_pt,
-                       const Eigen::Vector3f& max_pt,
-                       const BranchNode* node,
-                       const OctreeKey& key,
-                       unsigned int tree_depth,
-                       std::vector<int>& k_indices) const
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::boxSearchRecursive(
+    const Eigen::Vector3f& min_pt,
+    const Eigen::Vector3f& max_pt,
+    const BranchNode* node,
+    const OctreeKey& key,
+    unsigned int tree_depth,
+    std::vector<int>& k_indices) const
 {
   // iterate over all children
   for (unsigned char child_idx = 0; child_idx < 8; child_idx++) {
@@ -602,10 +589,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     getIntersectedVoxelCenters(Eigen::Vector3f origin,
                                Eigen::Vector3f direction,
                                AlignedPointTVector& voxel_center_list,
@@ -639,10 +625,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (0);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     getIntersectedVoxelIndices(Eigen::Vector3f origin,
                                Eigen::Vector3f direction,
                                std::vector<int>& k_indices,
@@ -674,10 +659,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (0);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     getIntersectedVoxelCentersRecursive(double min_x,
                                         double min_y,
                                         double min_z,
@@ -871,10 +855,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (voxel_count);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename LeafContainerT, typename BranchContainerT>
 int
-pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
+OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
     getIntersectedVoxelIndicesRecursive(double min_x,
                                         double min_y,
                                         double min_z,
@@ -1065,6 +1048,9 @@ pcl::octree::OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
   return (voxel_count);
 }
 
+} // namespace octree
+} // namespace pcl
+
 #define PCL_INSTANTIATE_OctreePointCloudSearch(T)                                      \
   template class PCL_EXPORTS pcl::octree::OctreePointCloudSearch<T>;
 
index 074ffbf979c1616323e5d717672105f22652b2a1..2767a30243724df5f1597d9978cfd90817ac9282 100644 (file)
@@ -42,7 +42,6 @@
 #include <pcl/octree/octree_base.h>
 #include <pcl/octree/octree_iterator.h>
 #include <pcl/octree/octree_pointcloud.h>
-
 #include <pcl/octree/octree_pointcloud_adjacency.h>
 #include <pcl/octree/octree_pointcloud_changedetector.h>
 #include <pcl/octree/octree_pointcloud_density.h>
@@ -50,5 +49,4 @@
 #include <pcl/octree/octree_pointcloud_pointvector.h>
 #include <pcl/octree/octree_pointcloud_singlepoint.h>
 #include <pcl/octree/octree_pointcloud_voxelcentroid.h>
-
 #include <pcl/octree/octree_search.h>
index 391572300390cd1902f3fa163bb67931ec40503b..6d9e70ee8c12c4245bb9b58ca82ccbf53fa08323 100644 (file)
 
 #pragma once
 
-#include <vector>
-
 #include <pcl/octree/octree_container.h>
 #include <pcl/octree/octree_iterator.h>
 #include <pcl/octree/octree_key.h>
 #include <pcl/octree/octree_nodes.h>
 #include <pcl/pcl_macros.h>
 
+#include <vector>
+
 namespace pcl {
 namespace octree {
 
@@ -139,16 +139,32 @@ public:
   }
 
   /** \brief Get const pointer to container */
-  const ContainerT* operator->() const { return &container_; }
+  const ContainerT*
+  operator->() const
+  {
+    return &container_;
+  }
 
   /** \brief Get pointer to container */
-  ContainerT* operator->() { return &container_; }
+  ContainerT*
+  operator->()
+  {
+    return &container_;
+  }
 
   /** \brief Get const reference to container */
-  const ContainerT& operator*() const { return container_; }
+  const ContainerT&
+  operator*() const
+  {
+    return container_;
+  }
 
   /** \brief Get reference to container */
-  ContainerT& operator*() { return container_; }
+  ContainerT&
+  operator*()
+  {
+    return container_;
+  }
 
   /** \brief Get const reference to container */
   const ContainerT&
@@ -237,14 +253,16 @@ public:
   using LeafNodeIterator = OctreeLeafNodeDepthFirstIterator<OctreeT>;
   using ConstLeafNodeIterator = const OctreeLeafNodeDepthFirstIterator<OctreeT>;
 
-  PCL_DEPRECATED("use leaf_depth_begin() instead")
+  PCL_DEPRECATED(1, 12, "use leaf_depth_begin() instead")
   LeafNodeIterator
   leaf_begin(unsigned int max_depth_arg = 0)
   {
     return LeafNodeIterator(this, max_depth_arg);
   };
 
-  PCL_DEPRECATED("use leaf_depth_end() instead") const LeafNodeIterator leaf_end()
+  PCL_DEPRECATED(1, 12, "use leaf_depth_end() instead")
+  const LeafNodeIterator
+  leaf_end()
   {
     return LeafNodeIterator();
   };
@@ -938,7 +956,7 @@ protected:
    * \param n_arg: some value
    * \return binary logarithm (log2) of argument n_arg
    */
-  PCL_DEPRECATED("use std::log2 instead") inline double Log2(double n_arg)
+  PCL_DEPRECATED(1, 12, "use std::log2 instead") inline double Log2(double n_arg)
   {
     return std::log2(n_arg);
   }
index 026d65d4a78e3ec86a595c4c1b5ebce0e7505b82..c487b92477e1406ff95b5246985129aa8966037e 100644 (file)
 
 #pragma once
 
-#include <vector>
-
 #include <pcl/octree/octree_container.h>
 #include <pcl/octree/octree_iterator.h>
 #include <pcl/octree/octree_key.h>
 #include <pcl/octree/octree_nodes.h>
 #include <pcl/pcl_macros.h>
 
+#include <vector>
+
 namespace pcl {
 namespace octree {
+
 /** \brief Octree class
  * \note The tree depth defines the maximum amount of octree voxels / leaf nodes (should
  * be initially defined).
@@ -126,14 +127,16 @@ public:
   using LeafNodeIterator = OctreeLeafNodeDepthFirstIterator<OctreeT>;
   using ConstLeafNodeIterator = const OctreeLeafNodeDepthFirstIterator<OctreeT>;
 
-  PCL_DEPRECATED("use leaf_depth_begin() instead")
+  PCL_DEPRECATED(1, 12, "use leaf_depth_begin() instead")
   LeafNodeIterator
   leaf_begin(unsigned int max_depth_arg = 0u)
   {
     return LeafNodeIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_);
   };
 
-  PCL_DEPRECATED("use leaf_depth_end() instead") const LeafNodeIterator leaf_end()
+  PCL_DEPRECATED(1, 12, "use leaf_depth_end() instead")
+  const LeafNodeIterator
+  leaf_end()
   {
     return LeafNodeIterator(this, 0, nullptr);
   };
@@ -247,6 +250,8 @@ public:
   {
     leaf_count_ = source.leaf_count_;
     branch_count_ = source.branch_count_;
+    delete root_node_;
+
     root_node_ = new (BranchNode)(*(source.root_node_));
     depth_mask_ = source.depth_mask_;
     max_key_ = source.max_key_;
@@ -396,7 +401,7 @@ protected:
   createLeaf(const OctreeKey& key_arg)
   {
 
-    LeafNode* leaf_node;
+    LeafNode* leaf_node = nullptr;
     BranchNode* leaf_node_parent;
 
     createLeafRecursive(key_arg, depth_mask_, root_node_, leaf_node, leaf_node_parent);
@@ -686,7 +691,7 @@ protected:
    * \param n_arg: some value
    * \return binary logarithm (log2) of argument n_arg
    */
-  PCL_DEPRECATED("use std::log2 instead") double Log2(double n_arg)
+  PCL_DEPRECATED(1, 12, "use std::log2 instead") double Log2(double n_arg)
   {
     return std::log2(n_arg);
   }
index 832380049b990833714ebf30e9bcb6c18af8c30d..c4655b7cfdf7ca1976f2b24754d08703debb2a82 100644 (file)
 
 #pragma once
 
+#include <cassert>
 #include <cstddef>
 #include <vector>
 
-#include <pcl/pcl_macros.h>
-
 namespace pcl {
 namespace octree {
+
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /** \brief @b Octree container class that can serve as a base to construct own leaf node
  * container classes.
index c8fa320b743f6aa83850fbc3a2a6a9532b2f3391..190c01116ee37c58142461645fecfd6e95e6b48b 100644 (file)
 
 #pragma once
 
-#include <pcl/octree/octree.h>
-
 #include <pcl/octree/impl/octree2buf_base.hpp>
 #include <pcl/octree/impl/octree_base.hpp>
 #include <pcl/octree/impl/octree_iterator.hpp>
 #include <pcl/octree/impl/octree_pointcloud.hpp>
 #include <pcl/octree/impl/octree_search.hpp>
+#include <pcl/octree/octree.h>
index 2d20cf2b24ecd8568f5cbfaba312e4ba66fb71ad..2156b3274ca2e4742f3d3a084db37ae03009883d 100644 (file)
 
 #pragma once
 
-#include <cstddef>
-#include <deque>
-#include <vector>
-
 #include <pcl/octree/octree_key.h>
 #include <pcl/octree/octree_nodes.h>
 
+#include <cstddef>
+#include <deque>
 #include <iterator>
+#include <vector>
 
 // Ignore warnings in the above headers
 #ifdef __GNUC__
@@ -218,7 +217,8 @@ public:
   /** \brief *operator.
    * \return pointer to the current octree node
    */
-  inline OctreeNode* operator*() const
+  inline OctreeNode*
+  operator*() const
   { // return designated object
     if (octree_ && current_state_) {
       return (current_state_->node_);
@@ -728,7 +728,8 @@ public:
   /** \brief *operator.
    * \return pointer to the current octree leaf node
    */
-  OctreeNode* operator*() const
+  OctreeNode*
+  operator*() const
   {
     // return designated object
     OctreeNode* ret = 0;
index 6ba5196a2fbd09a49aa2825816dc3cde46996947..a103d5a31db961b70b6bffda9261b50dadff9244 100644 (file)
@@ -38,6 +38,7 @@
 #pragma once
 
 #include <cstdint>
+#include <cstring> // for memcpy
 
 namespace pcl {
 namespace octree {
@@ -59,7 +60,7 @@ public:
   {}
 
   /** \brief Copy constructor. */
-  OctreeKey(const OctreeKey& source) { memcpy(key_, source.key_, sizeof(key_)); }
+  OctreeKey(const OctreeKey& source) { std::memcpy(key_, source.key_, sizeof(key_)); }
 
   OctreeKey&
   operator=(const OctreeKey&) = default;
index f261eb831ce522f4a60e53b978c14c759a9feb33..568e28bfeeb5c2e72efb1c5cdf1c9f40346cee24 100644 (file)
 
 #pragma once
 
-#include <vector>
-
 #include <pcl/pcl_macros.h>
 
+#include <vector>
+
 namespace pcl {
 namespace octree {
 
index 0277fc985a7b34efc367830caee6dc845a3bc3d8..e00182dfb1c34ea8f7a9e6cd391890ded7939dee 100644 (file)
 
 #pragma once
 
-#include <cstddef>
-
-#include <cassert>
+#include <pcl/octree/octree_container.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h>
 
 #include <Eigen/Core>
 
-#include <pcl/pcl_macros.h>
-
-#include "octree_container.h"
+#include <cassert>
+#include <cstddef>
 
 namespace pcl {
 namespace octree {
@@ -111,16 +110,32 @@ public:
   }
 
   /** \brief Get const pointer to container */
-  const ContainerT* operator->() const { return &container_; }
+  const ContainerT*
+  operator->() const
+  {
+    return &container_;
+  }
 
   /** \brief Get pointer to container */
-  ContainerT* operator->() { return &container_; }
+  ContainerT*
+  operator->()
+  {
+    return &container_;
+  }
 
   /** \brief Get const reference to container */
-  const ContainerT& operator*() const { return container_; }
+  const ContainerT&
+  operator*() const
+  {
+    return container_;
+  }
 
   /** \brief Get reference to container */
-  ContainerT& operator*() { return container_; }
+  ContainerT&
+  operator*()
+  {
+    return container_;
+  }
 
   /** \brief Get const reference to container */
   const ContainerT&
@@ -210,7 +225,8 @@ public:
    *  \param child_idx_arg: index to child node
    *  \return OctreeNode pointer
    * */
-  inline OctreeNode*& operator[](unsigned char child_idx_arg)
+  inline OctreeNode*&
+  operator[](unsigned char child_idx_arg)
   {
     assert(child_idx_arg < 8);
     return child_node_array_[child_idx_arg];
@@ -287,16 +303,32 @@ public:
   }
 
   /** \brief Get const pointer to container */
-  const ContainerT* operator->() const { return &container_; }
+  const ContainerT*
+  operator->() const
+  {
+    return &container_;
+  }
 
   /** \brief Get pointer to container */
-  ContainerT* operator->() { return &container_; }
+  ContainerT*
+  operator->()
+  {
+    return &container_;
+  }
 
   /** \brief Get const reference to container */
-  const ContainerT& operator*() const { return container_; }
+  const ContainerT&
+  operator*() const
+  {
+    return container_;
+  }
 
   /** \brief Get reference to container */
-  ContainerT& operator*() { return container_; }
+  ContainerT&
+  operator*()
+  {
+    return container_;
+  }
 
   /** \brief Get const reference to container */
   const ContainerT&
index 929c3c4c99a46560d2eb833d45565f137f7c7e3e..4f66675c5309498d97685c6d7507828b6def6416 100644 (file)
@@ -39,7 +39,6 @@
 #pragma once
 
 #include <pcl/octree/octree_base.h>
-
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
 
index 8d2a3b4ae0cb469e00f1d7d1015bb238f2037654..902dfd2c9d5bb145e1ce585f3d7bd6ebc36fc41f 100644 (file)
 
 #pragma once
 
-#include <boost/shared_ptr.hpp>
-
 #include <pcl/octree/octree2buf_base.h>
 #include <pcl/octree/octree_pointcloud.h>
+#include <pcl/memory.h>
 
 namespace pcl {
 namespace octree {
index 47b78182f72afe130908035b5aabaf6851044ac2..6d97a606b3f3d6cc048abb5e070f700c3e4e05a5 100644 (file)
 
 #pragma once
 
-#include <pcl/point_cloud.h>
-
 #include <pcl/octree/octree_pointcloud.h>
+#include <pcl/point_cloud.h>
 
 namespace pcl {
 namespace octree {
+
 /** \brief @b Octree pointcloud search class
  * \note This class provides several methods for spatial neighbor search based on octree
  * structure
@@ -339,8 +339,8 @@ protected:
     prioPointQueueEntry() : point_idx_(0), point_distance_(0) {}
 
     /** \brief Constructor for initializing priority queue entry.
-     * \param[in] point_idx an index representing a point in the dataset given by \a
-     * setInputCloud \param[in] point_distance distance of query point to voxel center
+     * \param[in] point_idx index for a dataset point given by \a setInputCloud
+     * \param[in] point_distance distance of query point to voxel center
      */
     prioPointQueueEntry(unsigned int& point_idx, float point_distance)
     : point_idx_(point_idx), point_distance_(point_distance)
index 4ed6c3daee0f9cb9739e6d1491efacb284c23078..acf0b5969c80f1c7247c5f9c435240e841846b7c 100644 (file)
@@ -475,8 +475,11 @@ namespace pcl
     ////////////////////////////////////////////////////////////////////////////////
 
     template<typename ContainerT, typename PointT> void
-   OutofcoreOctreeBase<ContainerT, PointT>::DeAllocEmptyNodeCache (OutofcoreOctreeBaseNode<ContainerT, PointT>* current)
+    OutofcoreOctreeBase<ContainerT, PointT>::DeAllocEmptyNodeCache (OutofcoreOctreeBaseNode<ContainerT, PointT>* current)
     {
+      if (current == nullptr)
+        current = root_node_;
+
       if (current->size () == 0)
       {
         current->flush_DeAlloc_this_only ();
@@ -486,7 +489,6 @@ namespace pcl
       {
         DeAllocEmptyNodeCache (current->children[i]);
       }
-
     }
 
     ////////////////////////////////////////////////////////////////////////////////
index ece9288cae2088c03cf46490342e36406c83c0d6..8492c41793a6c407f552abd455f9d0de43b71e1f 100644 (file)
@@ -337,11 +337,7 @@ namespace pcl
 
       for (std::size_t i = 0; i < 8; i++)
       {
-        if (children_[i])
-        {
-          OutofcoreOctreeBaseNode<ContainerT, PointT>* current = children_[i];
-          delete (current);
-        }
+        delete static_cast<OutofcoreOctreeBaseNode<ContainerT, PointT>*>(children_[i]);
       }
       children_.resize (8, static_cast<OutofcoreOctreeBaseNode<ContainerT, PointT>* > (nullptr));
       num_children_ = 0;
index 43cdbbc50f826ad4402f8c5c65eada136d4bc2c9..8152c9d3b38f1b5fe55dc3183a53bdcd3960f65c 100644 (file)
@@ -611,22 +611,15 @@ namespace pcl
         bool
         checkExtension (const boost::filesystem::path& path_name);
 
-
-        /** \brief DEPRECATED - Flush all nodes' cache 
-         *  \deprecated this was moved to the octree_node class
-         */
+        /** \brief Flush all nodes' cache */
         void
         flushToDisk ();
 
-        /** \brief DEPRECATED - Flush all non leaf nodes' cache 
-         *  \deprecated
-         */
+        /** \brief Flush all non leaf nodes' cache */
         void
         flushToDiskLazy ();
 
-        /** \brief DEPRECATED - Flush empty nodes only 
-         *  \deprecated
-         */
+        /** \brief Flush empty nodes only */
         void
         DeAllocEmptyNodeCache ();
 
index 5c33e542b174b536c9056618f23a096c9352c8d7..c65d8491d1978df3e1ea7c03d35eeabfd667ebec 100644 (file)
@@ -477,9 +477,7 @@ namespace pcl
         void
         loadFromFile (const boost::filesystem::path &path, OutofcoreOctreeBaseNode* super);
 
-        /** \brief Recursively converts data files to ascii XZY files
-         *  \note This will be deprecated soon
-         */
+        /** \brief Recursively converts data files to ascii XZY files */
         void
         convertToXYZRecursive ();
 
index 6b34b907fa556d4fb225c982fc488eb48fe71a2a..474c692ffbeb601ceb84e0a7851f2009c875654b 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/outofcore/boost.h>
 #include <pcl/outofcore/cJSON.h>
index 4a95544bbcd44f5f79d0c005b5f9b9d8b2db785e..54523791a240a82f4b879fbf5850d8bc2f51d878 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/outofcore/boost.h>
 #include <pcl/outofcore/cJSON.h>
index 608e55967e756bc8d71aecf5f288eb87fed1d2af..e2d57b13829d9ba31e7ea4e7ea7e9a524bfd4c96 100644 (file)
@@ -7,6 +7,7 @@
 // PCL
 #include <pcl/outofcore/visualization/object.h>
 #include <pcl/common/eigen.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 // VTK
index dc282b70c61bdabdd84fd808bf66f444843331e3..fde2b1773fc39eb22fdc5e913be3826eea7c6f3a 100644 (file)
@@ -7,6 +7,7 @@
 #include <thread>
 
 // PCL
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 
@@ -207,7 +208,7 @@ class OutofcoreCloud : public Object
     }
 
     int
-    getLodPixelThreshold ()
+    getLodPixelThreshold () const
     {
       return lod_pixel_threshold_;
     }
index bcced61c8175b88704d9610c6f4ada9fb3b1b6fa..5098aeb27adc35a796ba8cc184682ec2d7ec6b6b 100644 (file)
@@ -56,7 +56,9 @@
 // PCL - visualziation
 //#include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/common/common.h>
+#if VTK_RENDERING_BACKEND_OPENGL_VERSION < 2
 #include <pcl/visualization/vtk/vtkVertexBufferObjectMapper.h>
+#endif
 
 //#include "vtkVBOPolyDataMapper.h"
 
index 2c6d753646f314ec86e191582b50b557b6711b2b..5c55a57e7d2901181ffaa0d1a48b475c1358fe7a 100644 (file)
@@ -40,7 +40,7 @@
 
 #pragma once
 
-#include <pcl/pcl_macros.h>
+#include <pcl/pcl_macros.h> // export macro
 
 namespace pcl
 { 
index fae44bc404e8fc11847f0f854f4c9a5a7db8f922..bc5cf63d50703c77c48d3f3db2e630f78fc3a7e9 100644 (file)
 
 #include <pcl/people/hog.h>
 
-#include <cstring>
+#include <cstring> // for memcpy
+#include <algorithm> // for std::min
 
 #if defined(__SSE2__)
-#include <pcl/sse.h>
+  #include <pcl/sse.h> // sse methods
 #else
-#include <cstdlib>
+  #include <cstdlib>
 #endif
 
 /** \brief Constructor. */
@@ -170,30 +171,32 @@ pcl::people::HOG::gradHist( float *M, float *O, int h, int w, int bin_size, int
 {
   const int hb=h/bin_size, wb=w/bin_size, h0=hb*bin_size, w0=wb*bin_size, nb=wb*hb;
   const float s=(float)bin_size, sInv=1/s, sInv2=1/s/s;
-  float *H0, *H1, *M0, *M1; int x, y; int *O0, *O1;
+  float *H0, *H1, *M0, *M1; int *O0, *O1;
   O0=(int*)alMalloc(h*sizeof(int),16); M0=(float*) alMalloc(h*sizeof(float),16);
   O1=(int*)alMalloc(h*sizeof(int),16); M1=(float*) alMalloc(h*sizeof(float),16);
 
   // main loop
   float xb = 0;
   float init = 0;
-  for( x=0; x<w0; x++ ) {
+  for(int x=0; x<w0; x++ ) {
     // compute target orientation bins for entire column - very fast
     gradQuantize( O+x*h, M+x*h, O0, O1, M0, M1, n_orients, nb, h0, sInv2 );
 
     if( !soft_bin || bin_size==1 ) {
       // interpolate w.r.t. orientation only, not spatial bin_size
-      H1=H+(x/bin_size)*hb;
-      const auto GH = [&H1, &O0, &O1, &y, &M0, &M1]()
-      {
-          H1[O0[y]]+=M0[y]; H1[O1[y]]+=M1[y]; y++;
+      H1 = H + (x / bin_size) * hb;
+
+      const auto GH = [&H1, &O0, &O1, &M0, &M1](int y) {
+        H1[O0[y]] += M0[y];
+        H1[O1[y]] += M1[y];
       };
-      if( bin_size==1 )      for(y=0; y<h0;) { GH(); H1++; }
-      else if( bin_size==2 ) for(y=0; y<h0;) { GH(); GH(); H1++; }
-      else if( bin_size==3 ) for(y=0; y<h0;) { GH(); GH(); GH(); H1++; }
-      else if( bin_size==4 ) for(y=0; y<h0;) { GH(); GH(); GH(); GH(); H1++; }
-      else for( y=0; y<h0;) { for( int y1=0; y1<bin_size; y1++ ) { GH(); } H1++; }
 
+      for (int y = 0; y < h0;) {
+        for (int inner_loop = 0; inner_loop < bin_size; ++inner_loop, ++y) {
+          GH(y);
+        }
+        H1++;
+      }
     } else {
       // interpolate using trilinear interpolation
 #if defined(__SSE2__)
@@ -201,7 +204,8 @@ pcl::people::HOG::gradHist( float *M, float *O, int h, int w, int bin_size, int
       bool hasLf, hasRt; int xb0, yb0;
       if( x==0 ) { init=(0+.5f)*sInv-0.5f; xb=init; }
       hasLf = xb>=0; xb0 = hasLf?(int)xb:-1; hasRt = xb0 < wb-1;
-      xd=xb-xb0; xb+=sInv; yb=init; y=0;
+      xd=xb-xb0; xb+=sInv; yb=init;
+      int y=0;
       // lambda for code conciseness
       // @TODO: remove the very generic closure for specific variable one
       const auto GHinit = [&]()
@@ -247,7 +251,7 @@ pcl::people::HOG::gradHist( float *M, float *O, int h, int w, int bin_size, int
       bool hasLf, hasRt; int xb0, yb0;
       if( x==0 ) { init=(0+.5f)*sInv-0.5f; xb=init; }
       hasLf = xb>=0; xb0 = hasLf?(int)xb:-1; hasRt = xb0 < wb-1;
-      xd=xb-xb0; xb+=sInv; yb=init; y=0;
+      xd=xb-xb0; xb+=sInv; yb=init; int y=0;
       // lambda for code conciseness
       const auto GHinit = [&]()
       {
index 608eaea6af340c7f2cd7b75d6e85dfd20ea280c2..63bb6eec68b355899dc90e2e3ddd4696dd47e501 100644 (file)
@@ -163,9 +163,9 @@ namespace mets {
       termination_criteria_chain::reset();      
     }
 
-    int second_guess() { return second_guess_m; }
-    int iteration() { return total_iterations_m; }
-    int resets() { return resets_m; }
+    int second_guess() const { return second_guess_m; }
+    int iteration() const { return total_iterations_m; }
+    int resets() const { return resets_m; }
 
   protected:
     gol_type best_cost_m;
diff --git a/recognition/include/pcl/recognition/auxiliary.h b/recognition/include/pcl/recognition/auxiliary.h
deleted file mode 100644 (file)
index 8825cc7..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/auxiliary.h>
-#error "Using pcl/recognition/auxiliary.h is deprecated, please use pcl/recognition/ransac_based/auxiliary.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/bvh.h b/recognition/include/pcl/recognition/bvh.h
deleted file mode 100644 (file)
index a4a6952..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/bvh.h>
-#error "Using pcl/recognition/bvh.h is deprecated, please use pcl/recognition/ransac_based/bvh.h instead."
\ No newline at end of file
index 8d4d88d0c6f062087cf170921d76c3fcf5bebe7c..883f8dc870b275d369fd46c970ed5d6ff6eac4be 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <pcl/recognition/cg/correspondence_grouping.h>
 #include <pcl/recognition/boost.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 
index fda2962a1cfc2413abab7511ba8d80e60893de2b..f32ba9d5d46dd8381d772cf708d3e3d14b51e8a6 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <pcl/features/integral_image2D.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 #include <Eigen/Core>
index 669dbbcfab8ddd6f76b38826d270505656289db6..22363af3010460f512826be1f27aefb63720b4d9 100644 (file)
@@ -7,17 +7,18 @@
 
 #pragma once
 
+#include <pcl/memory.h>
+#include <pcl/common/common.h>
+#include <pcl/ml/dt/decision_tree_data_provider.h>
+#include <pcl/recognition/face_detection/face_common.h>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/filesystem/operations.hpp>
+
 #include <iostream>
 #include <fstream>
 #include <string>
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/algorithm/string.hpp>
-
-#include <pcl/common/common.h>
-#include <pcl/recognition/face_detection/face_common.h>
-#include <pcl/ml/dt/decision_tree_data_provider.h>
 
 namespace bf = boost::filesystem;
 
index 8df7502ef134d71eaf3462331c097ae851c3f8ab..7c6e92e2ff22585946020ba9ed99ebd820e51a98 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2012, Willow Garage, Inc.
- *  
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *
  */
 
+
 #ifndef PCL_RECOGNITION_CORRESPONDENCE_GROUPING_IMPL_H_
 #define PCL_RECOGNITION_CORRESPONDENCE_GROUPING_IMPL_H_
 
+
+namespace pcl
+{
+
 template <typename PointModelT, typename PointSceneT> void
-pcl::CorrespondenceGrouping<PointModelT, PointSceneT>::cluster (std::vector<Correspondences> &clustered_corrs)
+CorrespondenceGrouping<PointModelT, PointSceneT>::cluster (std::vector<Correspondences> &clustered_corrs)
 {
   clustered_corrs.clear ();
   corr_group_scale_.clear ();
@@ -57,4 +62,7 @@ pcl::CorrespondenceGrouping<PointModelT, PointSceneT>::cluster (std::vector<Corr
   deinitCompute ();
 }
 
+} // namespace pcl
+
 #endif // PCL_RECOGNITION_CORRESPONDENCE_GROUPING_IMPL_H_
+
index 143fe57ebb10e059b37183ce08db1017136bf8ba..92d7aa8bb0d72a2d78b57f40e56f127d1c7c3fde 100644 (file)
@@ -360,7 +360,10 @@ void pcl::GlobalHypothesesVerification<ModelT, SceneT>::initialize()
 
   {
     pcl::ScopeTime tcues ("Computing clutter cues");
-#pragma omp parallel for schedule(dynamic, 4) num_threads(omp_get_num_procs())
+#pragma omp parallel for \
+  default(none) \
+  schedule(dynamic, 4) \
+  num_threads(omp_get_num_procs())
     for (int j = 0; j < static_cast<int> (recognition_models_.size ()); j++)
       computeClutterCue (recognition_models_[j]);
   }
index 8a06e689741f27664bc21cd6feb26dec3b721f7b..9f74622ff61e3157a2c16eac5f61888165ff7772 100644 (file)
@@ -43,6 +43,8 @@
 
 #include "../implicit_shape_model.h"
 
+#include <pcl/memory.h>  // for dynamic_pointer_cast
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT>
 pcl::features::ISMVoteList<PointT>::ISMVoteList () :
@@ -1243,11 +1245,11 @@ pcl::ism::ImplicitShapeModelEstimation<FeatureSize, PointT, NormalT>::estimateFe
   feature_estimator_->setSearchMethod (tree);
 
 //  typename pcl::SpinImageEstimation<pcl::PointXYZ, pcl::Normal, pcl::Histogram<FeatureSize> >::Ptr feat_est_norm =
-//    boost::dynamic_pointer_cast<pcl::SpinImageEstimation<pcl::PointXYZ, pcl::Normal, pcl::Histogram<FeatureSize> > > (feature_estimator_);
+//    dynamic_pointer_cast<pcl::SpinImageEstimation<pcl::PointXYZ, pcl::Normal, pcl::Histogram<FeatureSize> > > (feature_estimator_);
 //  feat_est_norm->setInputNormals (normal_cloud);
 
   typename pcl::FeatureFromNormals<pcl::PointXYZ, pcl::Normal, pcl::Histogram<FeatureSize> >::Ptr feat_est_norm =
-    boost::dynamic_pointer_cast<pcl::FeatureFromNormals<pcl::PointXYZ, pcl::Normal, pcl::Histogram<FeatureSize> > > (feature_estimator_);
+    dynamic_pointer_cast<pcl::FeatureFromNormals<pcl::PointXYZ, pcl::Normal, pcl::Histogram<FeatureSize> > > (feature_estimator_);
   feat_est_norm->setInputNormals (normal_cloud);
 
   feature_estimator_->compute (*feature_cloud);
index b89f3a306a24d007339d0a0a2297af3add9ed102..77d08cb309b6c875b8471fa9dc7d861c168871b0 100644 (file)
@@ -4,7 +4,7 @@
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2010-2012, Willow Garage, Inc.
  *
- *  All rights reserved. 
+ *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
 #include <pcl/point_cloud.h>
 #include <limits>
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointXYZT, typename PointRGBT> bool
-pcl::LineRGBD<PointXYZT, PointRGBT>::readLTMHeader (int fd, pcl::io::TARHeader &header)
+LineRGBD<PointXYZT, PointRGBT>::readLTMHeader (int fd, pcl::io::TARHeader &header)
 {
   // Read in the header
-  int result = static_cast<int> (::read (fd, reinterpret_cast<char*> (&header.file_name[0]), 512));
+  int result = static_cast<int> (io::raw_read (fd, reinterpret_cast<char*> (&header.file_name[0]), 512));
   if (result == -1)
     return (false);
 
-  // We only support regular files for now. 
-  // Additional file types in TAR include: hard links, symbolic links, device/special files, block devices, 
+  // We only support regular files for now.
+  // Additional file types in TAR include: hard links, symbolic links, device/special files, block devices,
   // directories, and named pipes.
   if (header.file_type[0] != '0' && header.file_type[0] != '\0')
     return (false);
@@ -69,15 +72,15 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::readLTMHeader (int fd, pcl::io::TARHeader &
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointXYZT, typename PointRGBT> bool
-pcl::LineRGBD<PointXYZT, PointRGBT>::loadTemplates (const std::string &file_name, const std::size_t object_id)
+LineRGBD<PointXYZT, PointRGBT>::loadTemplates (const std::string &file_name, const std::size_t object_id)
 {
   // Open the file
   int ltm_fd = io::raw_open(file_name.c_str (), O_RDONLY);
   if (ltm_fd == -1)
     return (false);
-  
+
   int ltm_offset = 0;
 
   pcl::io::TARHeader ltm_header;
@@ -115,7 +118,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::loadTemplates (const std::string &file_name
 
       unsigned int fsize = ltm_header.getFileSize ();
       char *buffer = new char[fsize];
-      int result = static_cast<int> (::read (ltm_fd, reinterpret_cast<char*> (&buffer[0]), fsize));
+      int result = static_cast<int> (io::raw_read (ltm_fd, reinterpret_cast<char*> (&buffer[0]), fsize));
       if (result == -1)
       {
         delete [] buffer;
@@ -215,9 +218,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::loadTemplates (const std::string &file_name
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointXYZT, typename PointRGBT> int
-pcl::LineRGBD<PointXYZT, PointRGBT>::createAndAddTemplate (
+LineRGBD<PointXYZT, PointRGBT>::createAndAddTemplate (
   pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
   const std::size_t object_id,
   const MaskMap & mask_xyz,
@@ -311,9 +314,8 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::createAndAddTemplate (
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointXYZT, typename PointRGBT> bool
-pcl::LineRGBD<PointXYZT, PointRGBT>::addTemplate (const SparseQuantizedMultiModTemplate & sqmmt, pcl::PointCloud<pcl::PointXYZRGBA> & cloud, std::size_t object_id)
+LineRGBD<PointXYZT, PointRGBT>::addTemplate (const SparseQuantizedMultiModTemplate & sqmmt, pcl::PointCloud<pcl::PointXYZRGBA> & cloud, std::size_t object_id)
 {
   // add point cloud
   template_point_clouds_.resize (template_point_clouds_.size () + 1);
@@ -394,9 +396,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::addTemplate (const SparseQuantizedMultiModT
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> void 
-pcl::LineRGBD<PointXYZT, PointRGBT>::detect (
+
+template <typename PointXYZT, typename PointRGBT> void
+LineRGBD<PointXYZT, PointRGBT>::detect (
     std::vector<typename pcl::LineRGBD<PointXYZT, PointRGBT>::Detection> & detections)
 {
   std::vector<pcl::QuantizableModality*> modalities;
@@ -421,11 +423,11 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::detect (
     detection.response = linemod_detection.score;
 
     // compute bounding box:
-    // we assume that the bounding boxes of the templates are relative to the center of mass 
+    // we assume that the bounding boxes of the templates are relative to the center of mass
     // of the template points; so we also compute the center of mass of the points
-    // covered by the 
+    // covered by the
 
-    const pcl::SparseQuantizedMultiModTemplate & linemod_template = 
+    const pcl::SparseQuantizedMultiModTemplate & linemod_template =
       linemod_.getTemplate (linemod_detection.template_id);
 
     const std::size_t start_x = std::max (linemod_detection.x, 0);
@@ -492,9 +494,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::detect (
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> void 
-pcl::LineRGBD<PointXYZT, PointRGBT>::detectSemiScaleInvariant (
+
+template <typename PointXYZT, typename PointRGBT> void
+LineRGBD<PointXYZT, PointRGBT>::detectSemiScaleInvariant (
     std::vector<typename pcl::LineRGBD<PointXYZT, PointRGBT>::Detection> & detections,
     const float min_scale,
     const float max_scale,
@@ -522,11 +524,11 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::detectSemiScaleInvariant (
     detection.response = linemod_detection.score;
 
     // compute bounding box:
-    // we assume that the bounding boxes of the templates are relative to the center of mass 
+    // we assume that the bounding boxes of the templates are relative to the center of mass
     // of the template points; so we also compute the center of mass of the points
-    // covered by the 
+    // covered by the
 
-    const pcl::SparseQuantizedMultiModTemplate & linemod_template = 
+    const pcl::SparseQuantizedMultiModTemplate & linemod_template =
       linemod_.getTemplate (linemod_detection.template_id);
 
     const std::size_t start_x = std::max (linemod_detection.x, 0);
@@ -593,9 +595,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::detectSemiScaleInvariant (
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> void 
-pcl::LineRGBD<PointXYZT, PointRGBT>::computeTransformedTemplatePoints (
+
+template <typename PointXYZT, typename PointRGBT> void
+LineRGBD<PointXYZT, PointRGBT>::computeTransformedTemplatePoints (
     const std::size_t detection_id, pcl::PointCloud<pcl::PointXYZRGBA> &cloud)
 {
   if (detection_id >= detections_.size ())
@@ -607,11 +609,11 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::computeTransformedTemplatePoints (
   const pcl::BoundingBoxXYZ & template_bounding_box = bounding_boxes_[template_id];
   const pcl::BoundingBoxXYZ & detection_bounding_box = detections_[detection_id].bounding_box;
 
-  //std::cerr << "detection: " 
+  //std::cerr << "detection: "
   //  << detection_bounding_box.x << ", "
   //  << detection_bounding_box.y << ", "
   //  << detection_bounding_box.z << std::endl;
-  //std::cerr << "template: " 
+  //std::cerr << "template: "
   //  << template_bounding_box.x << ", "
   //  << template_bounding_box.y << ", "
   //  << template_bounding_box.z << std::endl;
@@ -619,7 +621,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::computeTransformedTemplatePoints (
   const float translation_y = detection_bounding_box.y - template_bounding_box.y;
   const float translation_z = detection_bounding_box.z - template_bounding_box.z;
 
-  //std::cerr << "translation: " 
+  //std::cerr << "translation: "
   //  << translation_x << ", "
   //  << translation_y << ", "
   //  << translation_z << std::endl;
@@ -640,9 +642,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::computeTransformedTemplatePoints (
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> void 
-pcl::LineRGBD<PointXYZT, PointRGBT>::refineDetectionsAlongDepth ()
+
+template <typename PointXYZT, typename PointRGBT> void
+LineRGBD<PointXYZT, PointRGBT>::refineDetectionsAlongDepth ()
 {
   const std::size_t nr_detections = detections_.size ();
   for (std::size_t detection_index = 0; detection_index < nr_detections; ++detection_index)
@@ -692,7 +694,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::refineDetectionsAlongDepth ()
     }
 
     std::vector<std::size_t> integral_depth_bins (nr_bins, 0);
-    
+
     integral_depth_bins[0] = depth_bins[0];
     for (std::size_t bin_index = 1; bin_index < nr_bins; ++bin_index)
     {
@@ -720,9 +722,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::refineDetectionsAlongDepth ()
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> void 
-pcl::LineRGBD<PointXYZT, PointRGBT>::applyProjectiveDepthICPOnDetections ()
+
+template <typename PointXYZT, typename PointRGBT> void
+LineRGBD<PointXYZT, PointRGBT>::applyProjectiveDepthICPOnDetections ()
 {
   const std::size_t nr_detections = detections_.size ();
   for (std::size_t detection_index = 0; detection_index < nr_detections; ++detection_index)
@@ -736,7 +738,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::applyProjectiveDepthICPOnDetections ()
     const std::size_t start_y = detection.region.y;
     const std::size_t pc_width = point_cloud.width;
     const std::size_t pc_height = point_cloud.height;
-    
+
     std::vector<std::pair<float, float> > depth_matches;
     for (std::size_t row_index = 0; row_index < pc_height; ++row_index)
     {
@@ -801,9 +803,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::applyProjectiveDepthICPOnDetections ()
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> void 
-pcl::LineRGBD<PointXYZT, PointRGBT>::removeOverlappingDetections ()
+
+template <typename PointXYZT, typename PointRGBT> void
+LineRGBD<PointXYZT, PointRGBT>::removeOverlappingDetections ()
 {
   // compute overlap between each detection
   const std::size_t nr_detections = detections_.size ();
@@ -820,7 +822,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::removeOverlappingDetections ()
         overlaps (detection_index_1, detection_index_2) = 0.0f;
       else
         overlaps (detection_index_1, detection_index_2) = computeBoundingBoxIntersectionVolume (
-          detections_[detection_index_1].bounding_box, 
+          detections_[detection_index_1].bounding_box,
           detections_[detection_index_2].bounding_box) / bounding_box_volume;
     }
   }
@@ -867,7 +869,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::removeOverlappingDetections ()
   for (std::size_t cluster_id = 0; cluster_id < nr_clusters; ++cluster_id)
   {
     std::vector<std::size_t> & cluster = clusters[cluster_id];
-    
+
     float average_center_x = 0.0f;
     float average_center_y = 0.0f;
     float average_center_z = 0.0f;
@@ -935,9 +937,9 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::removeOverlappingDetections ()
   detections_ = clustered_detections;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointXYZT, typename PointRGBT> float 
-pcl::LineRGBD<PointXYZT, PointRGBT>::computeBoundingBoxIntersectionVolume (
+
+template <typename PointXYZT, typename PointRGBT> float
+LineRGBD<PointXYZT, PointRGBT>::computeBoundingBoxIntersectionVolume (
   const BoundingBoxXYZ &box1, const BoundingBoxXYZ &box2)
 {
   const float x1_min = box1.x;
@@ -953,7 +955,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::computeBoundingBoxIntersectionVolume (
   const float x2_max = box2.x + box2.width;
   const float y2_max = box2.y + box2.height;
   const float z2_max = box2.z + box2.depth;
-  
+
   const float xi_min = std::max (x1_min, x2_min);
   const float yi_min = std::max (y1_min, y2_min);
   const float zi_min = std::max (z1_min, z2_min);
@@ -974,6 +976,7 @@ pcl::LineRGBD<PointXYZT, PointRGBT>::computeBoundingBoxIntersectionVolume (
   return (intersection_volume);
 }
 
+} // namespace pcl
 
-#endif        // PCL_RECOGNITION_LINEMOD_LINE_RGBD_IMPL_HPP_ 
+#endif        // PCL_RECOGNITION_LINEMOD_LINE_RGBD_IMPL_HPP_
 
index 89f8386752dfe8b6391e970ad9bdbcb14befe8a5..08fef7f84b26fecf71cb093ee47e30c40890fa70 100644 (file)
 #include <algorithm>
 #include <cmath>
 
-//===============================================================================================================================
+
+namespace pcl
+{
+
+namespace recognition
+{
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::Node ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::Node ()
 : data_ (nullptr),
   parent_ (nullptr),
   children_(nullptr)
 {}
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::~Node ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::~Node ()
 {
   this->deleteChildren ();
   this->deleteData ();
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::setCenter (const Scalar *c)
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::setCenter (const Scalar *c)
 {
   center_[0] = c[0];
   center_[1] = c[1];
   center_[2] = c[2];
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::setBounds (const Scalar *b)
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::setBounds (const Scalar *b)
 {
   bounds_[0] = b[0];
   bounds_[1] = b[1];
@@ -52,10 +54,9 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::setBoun
   bounds_[5] = b[5];
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::computeRadius ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::computeRadius ()
 {
   Scalar v[3] = {static_cast<Scalar> (0.5)*(bounds_[1]-bounds_[0]),
                  static_cast<Scalar> (0.5)*(bounds_[3]-bounds_[2]),
@@ -64,10 +65,9 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::compute
   radius_ = static_cast<Scalar> (std::sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]));
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline bool
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::createChildren ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::createChildren ()
 {
   if ( children_ )
     return (false);
@@ -152,34 +152,25 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::createC
   return (true);
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::deleteChildren ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::deleteChildren ()
 {
-  if ( children_ )
-  {
-    delete[] children_;
-    children_ = nullptr;
-  }
+  delete[] children_;
+  children_ = nullptr;
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::deleteData ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::deleteData ()
 {
-  if ( data_ )
-  {
-    delete data_;
-    data_ = nullptr;
-  }
+  delete data_;
+  data_ = nullptr;
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::makeNeighbors (Node* node)
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::makeNeighbors (Node* node)
 {
   if ( !this->hasData () || !node->hasData () )
     return;
@@ -188,41 +179,34 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node::makeNei
   node->full_leaf_neighbors_.insert (this);
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::SimpleOctree ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::SimpleOctree ()
 : tree_levels_ (0),
   root_ (nullptr)
 {
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::~SimpleOctree ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::~SimpleOctree ()
 {
   this->clear ();
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::clear ()
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::clear ()
 {
-  if ( root_ )
-  {
-    delete root_;
-    root_ = nullptr;
-  }
+  delete root_;
+  root_ = nullptr;
 
   full_leaves_.clear();
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::build (const Scalar* bounds, Scalar voxel_size,
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::build (const Scalar* bounds, Scalar voxel_size,
     NodeDataCreator* node_data_creator)
 {
   if ( voxel_size <= 0 )
@@ -265,11 +249,10 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::build (const
   root_->computeRadius ();
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-typename pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node*
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::createLeaf (Scalar x, Scalar y, Scalar z)
+typename SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node*
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::createLeaf (Scalar x, Scalar y, Scalar z)
 {
   // Make sure that the input point is within the octree bounds
   if ( x < bounds_[0] || x > bounds_[1] ||
@@ -305,11 +288,10 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::createLeaf (S
   return (node);
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-typename pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node*
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::getFullLeaf (int i, int j, int k)
+typename SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node*
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::getFullLeaf (int i, int j, int k)
 {
   Scalar offset = 0.5f*voxel_size_;
   Scalar p[3] = {bounds_[0] + offset + static_cast<Scalar> (i)*voxel_size_,
@@ -319,11 +301,10 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::getFullLeaf (
   return (this->getFullLeaf (p[0], p[1], p[2]));
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline
-typename pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node*
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::getFullLeaf (Scalar x, Scalar y, Scalar z)
+typename SimpleOctree<NodeData, NodeDataCreator, Scalar>::Node*
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::getFullLeaf (Scalar x, Scalar y, Scalar z)
 {
   // Make sure that the input point is within the octree bounds
   if ( x < bounds_[0] || x > bounds_[1] ||
@@ -357,10 +338,9 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::getFullLeaf (
   return (node);
 }
 
-//===============================================================================================================================
 
 template<typename NodeData, typename NodeDataCreator, typename Scalar> inline void
-pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::insertNeighbors (Node* node)
+SimpleOctree<NodeData, NodeDataCreator, Scalar>::insertNeighbors (Node* node)
 {
   const Scalar* c = node->getCenter ();
   Scalar s = static_cast<Scalar> (0.5)*voxel_size_;
@@ -397,6 +377,8 @@ pcl::recognition::SimpleOctree<NodeData, NodeDataCreator, Scalar>::insertNeighbo
   neigh = this->getFullLeaf (c[0]-s, c[1]-s, c[2]-s); if ( neigh ) node->makeNeighbors (neigh);
 }
 
-//===============================================================================================================================
+} // namespace recognition
+} // namespace pcl
 
 #endif /* SIMPLE_OCTREE_HPP_ */
+
index 93a00fcebe619e715f4ac3d8b69183ba0b207d86..35e3eabf4c8636ad1024b2c9b526eb3b01b5c18c 100644 (file)
  *
  */
 
+
 #ifndef PCL_RECOGNITION_VOXEL_STRUCTURE_HPP_
 #define PCL_RECOGNITION_VOXEL_STRUCTURE_HPP_
 
+
+namespace pcl
+{
+
+namespace recognition
+{
+
 template<class T, typename REAL> inline void
-pcl::recognition::VoxelStructure<T,REAL>::build (const REAL bounds[6], int num_of_voxels[3])
+VoxelStructure<T,REAL>::build (const REAL bounds[6], int num_of_voxels[3])
 {
   this->clear();
 
@@ -72,10 +80,9 @@ pcl::recognition::VoxelStructure<T,REAL>::build (const REAL bounds[6], int num_o
   min_center_[2] = bounds_[4] + static_cast<REAL> (0.5)*spacing_[2];
 }
 
-//================================================================================================================================
 
 template<class T, typename REAL> inline T*
-pcl::recognition::VoxelStructure<T,REAL>::getVoxel (const REAL p[3])
+VoxelStructure<T,REAL>::getVoxel (const REAL p[3])
 {
   if ( p[0] < bounds_[0] || p[0] >= bounds_[1] || p[1] < bounds_[2] || p[1] >= bounds_[3] || p[2] < bounds_[4] || p[2] >= bounds_[5] )
     return nullptr;
@@ -87,10 +94,9 @@ pcl::recognition::VoxelStructure<T,REAL>::getVoxel (const REAL p[3])
   return &voxels_[z*num_of_voxels_xy_plane_ + y*num_of_voxels_[0] + x];
 }
 
-//================================================================================================================================
 
 template<class T, typename REAL> inline T*
-pcl::recognition::VoxelStructure<T,REAL>::getVoxel (int x, int y, int z) const
+VoxelStructure<T,REAL>::getVoxel (int x, int y, int z) const
 {
   if ( x < 0 || x >= num_of_voxels_[0] ) return nullptr;
   if ( y < 0 || y >= num_of_voxels_[1] ) return nullptr;
@@ -99,10 +105,9 @@ pcl::recognition::VoxelStructure<T,REAL>::getVoxel (int x, int y, int z) const
   return &voxels_[z*num_of_voxels_xy_plane_ + y*num_of_voxels_[0] + x];
 }
 
-//================================================================================================================================
 
 template<class T, typename REAL> inline int
-pcl::recognition::VoxelStructure<T,REAL>::getNeighbors (const REAL* p, T **neighs) const
+VoxelStructure<T,REAL>::getNeighbors (const REAL* p, T **neighs) const
 {
   if ( p[0] < bounds_[0] || p[0] >= bounds_[1] || p[1] < bounds_[2] || p[1] >= bounds_[3] || p[2] < bounds_[4] || p[2] >= bounds_[5] )
     return 0;
@@ -151,6 +156,8 @@ pcl::recognition::VoxelStructure<T,REAL>::getNeighbors (const REAL* p, T **neigh
   return num_neighs;
 }
 
-//================================================================================================================================
+} // namespace recognition
+} // namespace pcl
 
 #endif // PCL_RECOGNITION_VOXEL_STRUCTURE_HPP_
+
index 55723ae57d927d6b3eb6cdf748906e0e6de30ac4..44e08583f3a57f51ca0cad43ba2c52bf290abfc7 100644 (file)
@@ -39,6 +39,7 @@
 #include <fstream>
 #include <limits>
 #include <Eigen/src/Core/Matrix.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
@@ -153,7 +154,7 @@ namespace pcl
         /** \brief Stores square distances to the corresponding neighbours. */
         std::vector<float> k_sqr_dist_;
     };
+
     /** \brief The assignment of this structure is to store the statistical/learned weights and other information
       * of the trained Implict Shape Model algorithm.
       */
@@ -553,7 +554,7 @@ namespace pcl
                                  int flags,
                                  Eigen::MatrixXf& cluster_centers);
 
-        /** \brief Generates centers for clusters as described in 
+        /** \brief Generates centers for clusters as described in
           * Arthur, David and Sergei Vassilvitski (2007) k-means++: The Advantages of Careful Seeding.
           * \param[in] data points to cluster
           * \param[out] out_centers it will contain generated centers
index 540746146f322c9bf89d5a7e7ab643e2cd74f86f..afef8eeb0f956e199a26d1bb3e2ffd136dc85ede 100644 (file)
@@ -78,7 +78,7 @@ public:
     return (data_.data());
   }
 
-  PCL_DEPRECATED("Use new version diff getDifferenceMask(mask0, mask1)")
+  PCL_DEPRECATED(1, 12, "Use new version diff getDifferenceMask(mask0, mask1)")
   static void
   getDifferenceMask(const MaskMap& mask0, const MaskMap& mask1, MaskMap& diff_mask);
 
diff --git a/recognition/include/pcl/recognition/model_library.h b/recognition/include/pcl/recognition/model_library.h
deleted file mode 100644 (file)
index 4e3fcc3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/model_library.h>
-#error "Using pcl/recognition/model_library.h is deprecated, please use pcl/recognition/ransac_based/model_library.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/obj_rec_ransac.h b/recognition/include/pcl/recognition/obj_rec_ransac.h
deleted file mode 100644 (file)
index 1cacff8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/obj_rec_ransac.h>
-#error "Using pcl/recognition/obj_rec_ransac.h is deprecated, please use pcl/recognition/ransac_based/obj_rec_ransac.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/orr_graph.h b/recognition/include/pcl/recognition/orr_graph.h
deleted file mode 100644 (file)
index 436b3e8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/orr_graph.h>
-#error "Using pcl/recognition/orr_graph.h is deprecated, please use pcl/recognition/ransac_based/orr_graph.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/orr_octree.h b/recognition/include/pcl/recognition/orr_octree.h
deleted file mode 100644 (file)
index 38b850c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/orr_octree.h>
-#error "Using pcl/recognition/orr_octree.h is deprecated, please use pcl/recognition/ransac_based/orr_octree.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/orr_octree_zprojection.h b/recognition/include/pcl/recognition/orr_octree_zprojection.h
deleted file mode 100644 (file)
index edb0580..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/orr_octree_zprojection.h>
-#error "Using pcl/recognition/orr_octree_zprojection.h is deprecated, please use pcl/recognition/ransac_based/orr_octree_zprojection.h instead."
\ No newline at end of file
index 7e37a17b2670f16e0270c31cb01f6103d5bb595c..af71d6fcb5368da9f4eb89ba741d194915d9bbeb 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
@@ -63,7 +64,7 @@ namespace pcl
     };
     PCL_MAKE_ALIGNED_OPERATOR_NEW
 
-    inline bool operator< (const GradientXY & rhs)
+    inline bool operator< (const GradientXY & rhs) const
     {
       return (magnitude > rhs.magnitude);
     }
index fd9e054ee103b18f19bd618cd35608716770238d..540e6b47007ca228f1d65422edc5b6c6fd78d2d3 100644 (file)
@@ -150,13 +150,10 @@ namespace pcl
             }
 
             virtual ~Node ()
-            {
-              if ( children_[0] )
               {
                 delete children_[0];
                 delete children_[1];
               }
-            }
 
             bool
             hasChildren () const
@@ -249,13 +246,10 @@ namespace pcl
         /** \brief Frees the memory allocated by this object. After that, you have to call build to use the tree again. */
         void
         clear()
-        {
-          if ( root_ )
           {
             delete root_;
             root_ = nullptr;
           }
-        }
 
         inline const std::vector<BoundedObject*>*
         getInputObjects () const
index 0655064159e923f364688c003a35be8f401590a4..d43aabd2bbe20b87451182abd11db798b70c07f4 100644 (file)
@@ -234,30 +234,24 @@ namespace pcl
 
             /** \brief Computes the "radius" of the node which is half the diagonal length. */
             inline float
-            getRadius (){ return radius_;}
+            getRadius () const{ return radius_;}
 
             bool
             createChildren ();
 
             inline void
             deleteChildren ()
-            {
-              if ( children_ )
               {
                 delete[] children_;
                 children_ = nullptr;
               }
-            }
 
             inline void
             deleteData ()
-            {
-              if ( data_ )
               {
                 delete data_;
                 data_ = nullptr;
               }
-            }
 
             /** \brief Make this and 'node' neighbors by inserting each node in the others node neighbor set. Nothing happens
               * of either of the nodes has no data. */
index 026a59b81271fc7a817734a42db8aeea8801ca29..78622a774936c150fb16830fbe12dbcb70068b80 100644 (file)
@@ -58,7 +58,7 @@ namespace pcl
 
       /** \brief Release the memory allocated for the voxels. */
       inline void
-      clear (){ if ( voxels_ ){ delete[] voxels_; voxels_ = nullptr;}}
+      clear (){ delete[] voxels_; voxels_ = nullptr;}
 
       /** \brief Returns a pointer to the voxel which contains p or NULL if p is not inside the structure. */
       inline T*
diff --git a/recognition/include/pcl/recognition/rigid_transform_space.h b/recognition/include/pcl/recognition/rigid_transform_space.h
deleted file mode 100644 (file)
index a62e3df..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/rigid_transform_space.h>
-#error "Using pcl/recognition/rigid_transform_space.h is deprecated, please use pcl/recognition/ransac_based/rigid_transform_space.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/simple_octree.h b/recognition/include/pcl/recognition/simple_octree.h
deleted file mode 100644 (file)
index 19f2a2b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/simple_octree.h>
-#error "Using pcl/recognition/simple_octree.h is deprecated, please use pcl/recognition/ransac_based/simple_octree.h instead."
\ No newline at end of file
index d8b298eede8bd609723e4b8d47f12c6b84281e95..9a38fff5e4978c57bd3d61bc351606eaee121075 100644 (file)
@@ -65,7 +65,7 @@ namespace pcl
       * \param[in] base the feature to compare to.
       */
     bool
-    compareForEquality (const QuantizedMultiModFeature & base)
+    compareForEquality (const QuantizedMultiModFeature & base) const
     {
       if (base.x != x)
         return false;
diff --git a/recognition/include/pcl/recognition/trimmed_icp.h b/recognition/include/pcl/recognition/trimmed_icp.h
deleted file mode 100644 (file)
index 23fd030..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/trimmed_icp.h>
-#error "Using pcl/recognition/trimmed_icp.h is deprecated, please use pcl/recognition/ransac_based/trimmed_icp.h instead."
\ No newline at end of file
diff --git a/recognition/include/pcl/recognition/voxel_structure.h b/recognition/include/pcl/recognition/voxel_structure.h
deleted file mode 100644 (file)
index 09ab880..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <pcl/recognition/ransac_based/voxel_structure.h>
-#error "Using pcl/recognition/voxel_structure.h is deprecated, please use pcl/recognition/ransac_based/voxel_structure.h instead."
\ No newline at end of file
index 23369dd06f5baa7787fabdf1167ba0daf9043147..e645de3446a1a3eea18ed47e1c98c0e82a366f2c 100644 (file)
@@ -1,5 +1,6 @@
 #include "pcl/recognition/face_detection/face_detector_data_provider.h"
 #include "pcl/recognition/face_detection/face_common.h"
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/common/time.h>
 #include <pcl/features/integral_image_normal.h>
 #include <pcl/io/pcd_io.h>
index be8f8346597a67d198780c8e53e07419cdc19987..35b5fda913a27c07f7901f44e89ade67a2f7be6c 100644 (file)
@@ -8,6 +8,7 @@
 #include "pcl/recognition/face_detection/rf_face_detector_trainer.h"
 #include "pcl/recognition/face_detection/face_common.h"
 #include "pcl/io/pcd_io.h"
+#include <pcl/memory.h>  // for dynamic_pointer_cast
 #include "pcl/ml/dt/decision_tree_trainer.h"
 #include "pcl/ml/dt/decision_tree_evaluator.h"
 #include "pcl/ml/dt/decision_forest_trainer.h"
@@ -22,6 +23,7 @@
 #include <pcl/recognition/hv/hv_papazov.h>
 #include <pcl/features/normal_3d.h>
 
+
 void pcl::RFFaceDetectorTrainer::trainWithDataProvider()
 {
 
@@ -58,7 +60,7 @@ void pcl::RFFaceDetectorTrainer::trainWithDataProvider()
 
   dtdp->initialize (directory_);
 
-  auto cast_dtdp = boost::dynamic_pointer_cast<pcl::DecisionTreeTrainerDataProvider<face_detection::FeatureType, std::vector<face_detection::TrainingExample>, float, int, NodeType>> (dtdp);
+  auto cast_dtdp = dynamic_pointer_cast<pcl::DecisionTreeTrainerDataProvider<face_detection::FeatureType, std::vector<face_detection::TrainingExample>, float, int, NodeType>> (dtdp);
   dft.setDecisionTreeDataProvider (cast_dtdp);
 
   pcl::DecisionForest<NodeType> forest;
index 120bbed70968ea7fb1aa0f2e69f55fa07e8fd2bd..bf492833f567ea4a2a81ee1570ef9351a4a2af8c 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <pcl/recognition/mask_map.h>
 
+#include <algorithm> // for std::transform
 #include <cassert>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
index b7b5a47e125887b7b6983cd185f9d9b95920ab82..e755a52034cbd3c5688f7a324f86011a1e7dc767 100644 (file)
@@ -60,11 +60,8 @@ pcl::recognition::ORROctree::ORROctree ()
 void
 pcl::recognition::ORROctree::clear ()
 {
-  if ( root_ )
-  {
-    delete root_;
-    root_ = nullptr;
-  }
+  delete root_;
+  root_ = nullptr;
 
   full_leaves_.clear();
 }
index a539f597990f91f1386177a414d9718197239021..2056dbae9211cd8338ff26976ed4715640eab228 100644 (file)
@@ -60,7 +60,6 @@ pcl::recognition::ORROctreeZProjection::clear ()
     {
       // Delete pixel by pixel
       for ( int j = 0 ; j < num_pixels_y_ ; ++j )
-        if ( pixels_[i][j] )
           delete pixels_[i][j];
 
       // Delete the whole row
@@ -76,7 +75,6 @@ pcl::recognition::ORROctreeZProjection::clear ()
     for ( int i = 0 ; i < num_pixels_x_ ; ++i )
     {
       for ( int j = 0 ; j < num_pixels_y_ ; ++j )
-        if ( sets_[i][j] )
           delete sets_[i][j];
 
       delete[] sets_[i];
index d6b307480d177b34e3464465b2abb5de133748e2..cf3020611de9a9e5a1a4cbab960f65e766227edc 100644 (file)
@@ -69,6 +69,16 @@ namespace Eigen
   };
 }
 
+namespace BFGSSpace {
+  enum Status {
+    NegativeGradientEpsilon = -3,
+    NotStarted = -2,
+    Running = -1,
+    Success = 0,
+    NoProgress = 1
+  };
+}
+
 template<typename _Scalar, int NX=Eigen::Dynamic>
 struct BFGSDummyFunctor
 {
@@ -87,18 +97,9 @@ struct BFGSDummyFunctor
   virtual double operator() (const VectorType &x) = 0;
   virtual void  df(const VectorType &x, VectorType &df) = 0;
   virtual void fdf(const VectorType &x, Scalar &f, VectorType &df) = 0;
+  virtual BFGSSpace::Status checkGradient(const VectorType& g) { return BFGSSpace::NotStarted; };
 };
 
-namespace BFGSSpace {
-  enum Status {
-    NegativeGradientEpsilon = -3,
-    NotStarted = -2,
-    Running = -1,
-    Success = 0,
-    NoProgress = 1
-  };
-}
-
 /**
  * BFGS stands for Broyden–Fletcher–Goldfarb–Shanno (BFGS) method for solving 
  * unconstrained nonlinear optimization problems. 
@@ -148,7 +149,9 @@ public:
   BFGSSpace::Status minimize(FVectorType &x);
   BFGSSpace::Status minimizeInit(FVectorType &x);
   BFGSSpace::Status minimizeOneStep(FVectorType &x);
-  BFGSSpace::Status testGradient(Scalar epsilon);
+  BFGSSpace::Status testGradient();
+  PCL_DEPRECATED(1, 13, "Use `testGradient()` instead")
+  BFGSSpace::Status testGradient(Scalar) { return testGradient(); }
   void resetParameters(void) { parameters = Parameters(); }
   
   Parameters parameters;
@@ -407,18 +410,11 @@ BFGS<FunctorType>::minimizeOneStep(FVectorType  &x)
   return BFGSSpace::Success;
 }
 
-template<typename FunctorType> typename BFGSSpace::Status 
-BFGS<FunctorType>::testGradient(Scalar epsilon)
+template <typename FunctorType>
+typename BFGSSpace::Status
+BFGS<FunctorType>::testGradient()
 {
-  if(epsilon < 0)
-    return BFGSSpace::NegativeGradientEpsilon;
-  else
-  {
-    if(gradient.norm () < epsilon)
-      return BFGSSpace::Success;
-    else
-      return BFGSSpace::Running;
-  }
+  return functor.checkGradient(gradient);
 }
 
 template<typename FunctorType> typename BFGS<FunctorType>::Scalar 
index 962e5888f4bc7b8f8e1c11c895553d656ac0e028..ae726dcce77191fbfc4bd0a93b126b72ee58df65 100644 (file)
@@ -49,4 +49,3 @@
 #include <boost/property_map/property_map.hpp>
 
 #include <boost/noncopyable.hpp>
-#include <boost/make_shared.hpp>
index efe0532382c52676f57a5905a0822e8e6d7b9889..ab64c5767c78d34b4216bd03c43272a6e09be95b 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
index 696804ca240ee91f0ba762876a7d1a7070995820..f016f2980c12901b97baf1baa7652538e957e69b 100644 (file)
@@ -45,6 +45,7 @@
 #include <pcl/pcl_base.h>
 #include <pcl/common/transforms.h>
 #include <pcl/search/kdtree.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 #include <pcl/registration/correspondence_types.h>
index 220ca647fec8739959a2b43e4851473366ca73dc..d8458183a48ef327b03787958ff595926f84227d 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/correspondence_estimation.h>
 
index ca9371fb9abb0582f7fdf3168fe20855dba1119a..88023d6a77a3415fe725ca09499c8d89268b1531 100644 (file)
@@ -69,7 +69,7 @@ namespace pcl
         virtual ~CorrespondenceRejector () {}
 
         /** \brief Provide a pointer to the vector of the input correspondences.
-          * \param[in] correspondences the const boost shared pointer to a correspondence vector
+          * \param[in] correspondences the const shared pointer to a correspondence vector
           */
         virtual inline void 
         setInputCorrespondences (const CorrespondencesConstPtr &correspondences) 
@@ -78,7 +78,7 @@ namespace pcl
         };
 
         /** \brief Get a pointer to the vector of the input correspondences.
-          * \return correspondences the const boost shared pointer to a correspondence vector
+          * \return correspondences the const shared pointer to a correspondence vector
           */
         inline CorrespondencesConstPtr 
         getInputCorrespondences () { return input_correspondences_; };
index 26552446dc2d94a9b4548c3a56f9a0eaf40924e4..f02721a79ec734b6ffe51bee57466a9bc44ec007 100644 (file)
@@ -41,6 +41,8 @@
 #pragma once
 
 #include <pcl/registration/correspondence_rejection.h>
+#include <pcl/memory.h>  // for static_pointer_cast
+
 
 namespace pcl
 {
@@ -95,19 +97,20 @@ namespace pcl
 
         /** \brief Get the maximum distance used for thresholding in correspondence rejection. */
         inline float 
-        getMaximumDistance () { return std::sqrt (max_distance_); };
+        getMaximumDistance () const { return std::sqrt (max_distance_); };
 
         /** \brief Provide a source point cloud dataset (must contain XYZ
           * data!), used to compute the correspondence distance.  
           * \param[in] cloud a cloud containing XYZ data
           */
-        template <typename PointT> inline void 
+        template <typename PointT>
+        PCL_DEPRECATED(1, 12, "pcl::registration::CorrespondenceRejectorDistance::setInputCloud is deprecated. Please use setInputSource instead")
+        inline void 
         setInputCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud)
         {
-          PCL_WARN ("[pcl::registration::%s::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.\n", getClassName ().c_str ());
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
         }
 
         /** \brief Provide a source point cloud dataset (must contain XYZ
@@ -119,7 +122,7 @@ namespace pcl
         {
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
         }
 
         /** \brief Provide a target point cloud dataset (must contain XYZ
@@ -131,7 +134,7 @@ namespace pcl
         {
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
         }
 
 
@@ -174,7 +177,7 @@ namespace pcl
         setSearchMethodTarget (const typename pcl::search::KdTree<PointT>::Ptr &tree,
                                bool force_no_recompute = false)
         { 
-          boost::static_pointer_cast< DataContainer<PointT> > 
+          static_pointer_cast< DataContainer<PointT> > 
             (data_container_)->setSearchMethodTarget (tree, force_no_recompute );
         }
 
index 08104c71c034859b5eef90d8487bc717a612abc2..8cece9d291d5d0533e1c5713356107f197bf00e5 100644 (file)
 #pragma once
 
 #include <pcl/registration/correspondence_rejection.h>
+#include <pcl/memory.h>  // for static_pointer_cast
 #include <pcl/point_cloud.h>
 
+
 namespace pcl
 {
   namespace registration
@@ -97,20 +99,21 @@ namespace pcl
         {
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
         }
 
         /** \brief Provide a source point cloud dataset (must contain XYZ
           * data!), used to compute the correspondence distance.  
           * \param[in] cloud a cloud containing XYZ data
           */
-        template <typename PointT> inline void 
+        template <typename PointT>
+        PCL_DEPRECATED(1, 12, "pcl::registration::CorrespondenceRejectorMedianDistance::setInputCloud is deprecated. Please use setInputSource instead")
+        inline void 
         setInputCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud)
         {
-          PCL_WARN ("[pcl::registration::%s::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.\n", getClassName ().c_str ());
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
         }
 
         /** \brief Provide a target point cloud dataset (must contain XYZ
@@ -122,7 +125,7 @@ namespace pcl
         {
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
         }
         
         /** \brief See if this rejector requires source points */
@@ -164,7 +167,7 @@ namespace pcl
         setSearchMethodTarget (const typename pcl::search::KdTree<PointT>::Ptr &tree,
                                bool force_no_recompute = false)
         { 
-          boost::static_pointer_cast< DataContainer<PointT> > 
+          static_pointer_cast< DataContainer<PointT> > 
             (data_container_)->setSearchMethodTarget (tree, force_no_recompute );
         }
 
index cfa20ec8ffc7e9c73f89629d720da240b9699ec5..49e6d26360d46b66bba1588d06aa5aeb0bdc859c 100644 (file)
@@ -39,7 +39,7 @@
 #pragma once
 
 #include <pcl/registration/correspondence_rejection.h>
-
+#include <pcl/memory.h>  // for static_pointer_cast
 
 namespace pcl
 {
@@ -79,7 +79,7 @@ namespace pcl
       {
         if (!data_container_)
           data_container_.reset (new pcl::registration::DataContainer<PointT>);
-        boost::static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+        static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputSource (cloud);
       }
 
       template <typename PointT> inline void
@@ -87,7 +87,7 @@ namespace pcl
       {
         if (!data_container_)
           data_container_.reset (new pcl::registration::DataContainer<PointT>);
-        boost::static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputTarget (cloud);
+        static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputTarget (cloud);
       }
 
       /** \brief See if this rejector requires source points */
index 593bd3041f8622ea8aa497913bebde1ff1dd41be..44fde05c7ec13da7fe471434e8135c9597bcd28a 100644 (file)
@@ -109,11 +109,10 @@ namespace pcl
         /** \brief Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence distance.
           * \param[in] cloud a cloud containing XYZ data
           */
+        PCL_DEPRECATED(1, 12, "pcl::registration::CorrespondenceRejectorPoly::setInputCloud is deprecated. Please use setInputSource instead")
         inline void 
         setInputCloud (const PointCloudSourceConstPtr &cloud)
         {
-          PCL_WARN ("[pcl::registration::%s::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.\n",
-                    getClassName ().c_str ());
           input_ = cloud;
         }
 
index 41dcf5085a1b492659f5a05833c20cded15eb0b0..3a2fa5851c8c59b831605ccbd57f9a16987222f9 100644 (file)
@@ -41,6 +41,7 @@
 #pragma once
 
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/correspondence_rejection.h>
 
index d415cd43a87bb1fca1c68d0f4d2058b8f880b0f6..9698b5ae7339c078a096357e114920f2592bd682 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/correspondence_rejection_sample_consensus.h>
 
index 0c9fba39940b3780de2a2c1b4703132c7f9ae608..510b8a644ed7b5e8366767fcea9ddd28fd0a0c49 100644 (file)
 #pragma once
 
 #include <pcl/registration/correspondence_rejection.h>
+#include <pcl/memory.h>  // for static_pointer_cast
 #include <pcl/point_cloud.h>
 
+
 namespace pcl
 {
   namespace registration
@@ -102,16 +104,17 @@ namespace pcl
         /** \brief Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence distance.  
           * \param[in] input a cloud containing XYZ data
           */
-        template <typename PointT> inline void 
+        template <typename PointT>
+        PCL_DEPRECATED(1, 12, "pcl::registration::CorrespondenceRejectorSurfaceNormal::setInputCloud is deprecated. Please use setInputSource instead")
+        inline void 
         setInputCloud (const typename pcl::PointCloud<PointT>::ConstPtr &input)
         {
-          PCL_WARN ("[pcl::registration::%s::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.\n", getClassName ().c_str ());
           if (!data_container_)
           {
             PCL_ERROR ("[pcl::registration::%s::setInputCloud] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (input);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (input);
         }
 
         /** \brief Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence distance.  
@@ -125,7 +128,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::setInputCloud] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (input);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (input);
         }
 
         /** \brief Get the target input point cloud */
@@ -137,7 +140,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::getInputSource] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          return (boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->getInputSource ());
+          return (static_pointer_cast<DataContainer<PointT> > (data_container_)->getInputSource ());
         }
 
         /** \brief Provide a target point cloud dataset (must contain XYZ data!), used to compute the correspondence distance.  
@@ -151,7 +154,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::setInputTarget] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
         }
 
         /** \brief Provide a pointer to the search object used to find correspondences in
@@ -165,7 +168,7 @@ namespace pcl
         setSearchMethodTarget (const typename pcl::search::KdTree<PointT>::Ptr &tree,
                                bool force_no_recompute = false)
         { 
-          boost::static_pointer_cast< DataContainer<PointT> > 
+          static_pointer_cast< DataContainer<PointT> > 
             (data_container_)->setSearchMethodTarget (tree, force_no_recompute );
         }
 
@@ -178,7 +181,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::getInputTarget] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          return (boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->getInputTarget ());
+          return (static_pointer_cast<DataContainer<PointT> > (data_container_)->getInputTarget ());
         }
 
         /** \brief Set the normals computed on the input point cloud
@@ -192,7 +195,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::setInputNormals] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          boost::static_pointer_cast<DataContainer<PointT, NormalT> > (data_container_)->setInputNormals (normals);
+          static_pointer_cast<DataContainer<PointT, NormalT> > (data_container_)->setInputNormals (normals);
         }
 
         /** \brief Get the normals computed on the input point cloud */
@@ -204,7 +207,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::getInputNormals] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          return (boost::static_pointer_cast<DataContainer<pcl::PointXYZ, NormalT> > (data_container_)->getInputNormals ());
+          return (static_pointer_cast<DataContainer<pcl::PointXYZ, NormalT> > (data_container_)->getInputNormals ());
         }
 
         /** \brief Set the normals computed on the target point cloud
@@ -218,7 +221,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::setTargetNormals] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          boost::static_pointer_cast<DataContainer<PointT, NormalT> > (data_container_)->setTargetNormals (normals);
+          static_pointer_cast<DataContainer<PointT, NormalT> > (data_container_)->setTargetNormals (normals);
         }
 
         /** \brief Get the normals computed on the target point cloud */
@@ -230,7 +233,7 @@ namespace pcl
             PCL_ERROR ("[pcl::registration::%s::getTargetNormals] Initialize the data container object by calling intializeDataContainer () before using this function.\n", getClassName ().c_str ());
             return;
           }
-          return (boost::static_pointer_cast<DataContainer<pcl::PointXYZ, NormalT> > (data_container_)->getTargetNormals ());
+          return (static_pointer_cast<DataContainer<pcl::PointXYZ, NormalT> > (data_container_)->getTargetNormals ());
         }
 
 
index a88e5227fb1a3a060568884283487ab58233fb21..e645161c7e572603d6d9449b200fe76ec1044ad7 100644 (file)
@@ -91,7 +91,7 @@ namespace pcl
 
         /** \brief Get the maximum distance used for thresholding in correspondence rejection. */
         inline float 
-        getOverlapRatio () { return overlap_ratio_; };
+        getOverlapRatio () const { return overlap_ratio_; };
 
         /** \brief Set a minimum number of correspondences. If the specified overlap ratio causes to have
           * less correspondences,  \a CorrespondenceRejectorTrimmed will try to return at least
@@ -104,7 +104,7 @@ namespace pcl
 
         /** \brief Get the minimum number of correspondences. */
         inline unsigned int 
-        getMinCorrespondences () { return nr_min_correspondences_; };
+        getMinCorrespondences () const { return nr_min_correspondences_; };
 
 
         /** \brief Get a list of valid correspondences after rejection from the original set of correspondences.
index c3750c2779fc1053a8cc696b10d9253018dc2464..93753a48c2cd9ff214edb2002fe42107feea128f 100644 (file)
@@ -40,6 +40,7 @@
 #pragma once
 
 #include <pcl/registration/correspondence_rejection.h>
+#include <pcl/memory.h>  // for static_pointer_cast
 #include <pcl/point_cloud.h>
 
 #include <vector>
@@ -103,20 +104,21 @@ namespace pcl
         {
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
         }
 
         /** \brief Provide a source point cloud dataset (must contain XYZ
           * data!), used to compute the correspondence distance.  
           * \param[in] cloud a cloud containing XYZ data
           */
-        template <typename PointT> inline void 
+        template <typename PointT>
+        PCL_DEPRECATED(1, 12, "pcl::registration::CorrespondenceRejectorVarTrimmed::setInputCloud is deprecated. Please use setInputSource instead")
+        inline void 
         setInputCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud)
         {
-          PCL_WARN ("[pcl::registration::%s::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.\n", getClassName ().c_str ());
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputSource (cloud);
         }
 
         /** \brief Provide a target point cloud dataset (must contain XYZ
@@ -128,7 +130,7 @@ namespace pcl
         {
           if (!data_container_)
             data_container_.reset (new DataContainer<PointT>);
-          boost::static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
+          static_pointer_cast<DataContainer<PointT> > (data_container_)->setInputTarget (target);
         }
 
 
@@ -172,7 +174,7 @@ namespace pcl
         setSearchMethodTarget (const typename pcl::search::KdTree<PointT>::Ptr &tree,
                                bool force_no_recompute = false)
         { 
-          boost::static_pointer_cast< DataContainer<PointT> > 
+          static_pointer_cast< DataContainer<PointT> > 
             (data_container_)->setSearchMethodTarget (tree, force_no_recompute );
         }
 
@@ -244,7 +246,7 @@ namespace pcl
 
         /** \brief finds the optimal inlier ratio. This is based on the paper 'Outlier Robust ICP for minimizing Fractional RMSD, J. M. Philips et al'
          */
-        inline float optimizeInlierRatio (std::vector <double> &dists);
+        inline float optimizeInlierRatio (std::vector <double> &dists) const;
     };
   }
 }
index 64c09325884e01de821f11e8e1eee60c088b7dc6..aa02d272d2a442c933b4d5cc8ba9415bf44a39a3 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/eigen.h>
 #include <pcl/correspondence.h>
index 73c47a3d8b0745d82f92c1a3ba9968941e6ec49b..d3667bc7395e1d4c77a217c4dd9b7ecfd5248e31 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
index 67f61ecb97bd24bc4404e392d6abdfd2c41fa91b..08d9ba2d84a7bd73ff0d5beac7eed02f7a26c75c 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/pcl_base.h>
 #include <pcl/point_types.h>
index 887b004f054135301770a509f60774ac9f2cd84b..e3b8ea6f0060e9bdd1013d785a1a408f775016e0 100644 (file)
 
 namespace pcl
 {
-  /** \brief GeneralizedIterativeClosestPoint is an ICP variant that implements the 
-    * generalized iterative closest point algorithm as described by Alex Segal et al. in 
+  /** \brief GeneralizedIterativeClosestPoint is an ICP variant that implements the
+    * generalized iterative closest point algorithm as described by Alex Segal et al. in
     * http://www.robots.ox.ac.uk/~avsegal/resources/papers/Generalized_ICP.pdf
-    * The approach is based on using anistropic cost functions to optimize the alignment 
+    * The approach is based on using anistropic cost functions to optimize the alignment
     * after closest point assignments have been made.
-    * The original code uses GSL and ANN while in ours we use an eigen mapped BFGS and 
+    * The original code uses GSL and ANN while in ours we use an eigen mapped BFGS and
     * FLANN.
     * \author Nizar Sallem
     * \ingroup registration
@@ -92,7 +92,7 @@ namespace pcl
       using MatricesVector = std::vector< Eigen::Matrix3d, Eigen::aligned_allocator<Eigen::Matrix3d> >;
       using MatricesVectorPtr = shared_ptr<MatricesVector>;
       using MatricesVectorConstPtr = shared_ptr<const MatricesVector>;
-      
+
       using InputKdTree = typename Registration<PointSource, PointTarget>::KdTree;
       using InputKdTreePtr = typename Registration<PointSource, PointTarget>::KdTreePtr;
 
@@ -103,12 +103,14 @@ namespace pcl
       using Vector6d = Eigen::Matrix<double, 6, 1>;
 
       /** \brief Empty constructor. */
-      GeneralizedIterativeClosestPoint () 
+      GeneralizedIterativeClosestPoint ()
         : k_correspondences_(20)
         , gicp_epsilon_(0.001)
         , rotation_epsilon_(2e-3)
         , mahalanobis_(0)
         , max_inner_iterations_(20)
+        ,translation_gradient_tolerance_(1e-2)
+        ,rotation_gradient_tolerance_(1e-2) 
       {
         min_number_correspondences_ = 4;
         reg_name_ = "GeneralizedIterativeClosestPoint";
@@ -141,43 +143,43 @@ namespace pcl
         // Set all the point.data[3] values to 1 to aid the rigid transformation
         for (std::size_t i = 0; i < input.size (); ++i)
           input[i].data[3] = 1.0;
-        
+
         pcl::IterativeClosestPoint<PointSource, PointTarget>::setInputSource (cloud);
         input_covariances_.reset ();
       }
 
-      /** \brief Provide a pointer to the covariances of the input source (if computed externally!). 
+      /** \brief Provide a pointer to the covariances of the input source (if computed externally!).
         * If not set, GeneralizedIterativeClosestPoint will compute the covariances itself.
         * Make sure to set the covariances AFTER setting the input source point cloud (setting the input source point cloud will reset the covariances).
-        * \param[in] target the input point cloud target
+        * \param[in] covariances the input source covariances
         */
-      inline void 
+      inline void
       setSourceCovariances (const MatricesVectorPtr& covariances)
       {
         input_covariances_ = covariances;
       }
-      
+
       /** \brief Provide a pointer to the input target (e.g., the point cloud that we want to align the input source to)
         * \param[in] target the input point cloud target
         */
-      inline void 
+      inline void
       setInputTarget (const PointCloudTargetConstPtr &target) override
       {
         pcl::IterativeClosestPoint<PointSource, PointTarget>::setInputTarget(target);
         target_covariances_.reset ();
       }
 
-      /** \brief Provide a pointer to the covariances of the input target (if computed externally!). 
+      /** \brief Provide a pointer to the covariances of the input target (if computed externally!).
         * If not set, GeneralizedIterativeClosestPoint will compute the covariances itself.
         * Make sure to set the covariances AFTER setting the input source point cloud (setting the input source point cloud will reset the covariances).
-        * \param[in] target the input point cloud target
+        * \param[in] covariances the input target covariances
         */
-           inline void 
+           inline void
       setTargetCovariances (const MatricesVectorPtr& covariances)
       {
         target_covariances_ = covariances;
       }
-      
+
       /** \brief Estimate a rigid rotation transformation between a source and a target point cloud using an iterative
         * non-linear Levenberg-Marquardt approach.
         * \param[in] cloud_src the source point cloud dataset
@@ -192,7 +194,7 @@ namespace pcl
                                        const PointCloudTarget &cloud_tgt,
                                        const std::vector<int> &indices_tgt,
                                        Eigen::Matrix4f &transformation_matrix);
-      
+
       /** \brief \return Mahalanobis distance matrix for the given point index */
       inline const Eigen::Matrix3d& mahalanobis(std::size_t index) const
       {
@@ -210,59 +212,82 @@ namespace pcl
       void
       computeRDerivative(const Vector6d &x, const Eigen::Matrix3d &R, Vector6d &g) const;
 
-      /** \brief Set the rotation epsilon (maximum allowable difference between two 
-        * consecutive rotations) in order for an optimization to be considered as having 
+      /** \brief Set the rotation epsilon (maximum allowable difference between two
+        * consecutive rotations) in order for an optimization to be considered as having
         * converged to the final solution.
         * \param epsilon the rotation epsilon
         */
-      inline void 
+      inline void
       setRotationEpsilon (double epsilon) { rotation_epsilon_ = epsilon; }
 
-      /** \brief Get the rotation epsilon (maximum allowable difference between two 
+      /** \brief Get the rotation epsilon (maximum allowable difference between two
         * consecutive rotations) as set by the user.
         */
-      inline double 
-      getRotationEpsilon () { return (rotation_epsilon_); }
+      inline double
+      getRotationEpsilon () const { return rotation_epsilon_; }
 
       /** \brief Set the number of neighbors used when selecting a point neighbourhood
-        * to compute covariances. 
-        * A higher value will bring more accurate covariance matrix but will make 
+        * to compute covariances.
+        * A higher value will bring more accurate covariance matrix but will make
         * covariances computation slower.
         * \param k the number of neighbors to use when computing covariances
         */
       void
       setCorrespondenceRandomness (int k) { k_correspondences_ = k; }
 
-      /** \brief Get the number of neighbors used when computing covariances as set by 
-        * the user 
+      /** \brief Get the number of neighbors used when computing covariances as set by
+        * the user
         */
       int
-      getCorrespondenceRandomness () { return (k_correspondences_); }
+      getCorrespondenceRandomness () const { return k_correspondences_; }
 
-      /** set maximum number of iterations at the optimization step
+      /** \brief Set maximum number of iterations at the optimization step
         * \param[in] max maximum number of iterations for the optimizer
         */
       void
       setMaximumOptimizerIterations (int max) { max_inner_iterations_ = max; }
 
-      ///\return maximum number of iterations at the optimization step
+      /** \brief Return maximum number of iterations at the optimization step
+         */
       int
-      getMaximumOptimizerIterations () { return (max_inner_iterations_); }
+      getMaximumOptimizerIterations () const { return max_inner_iterations_; }
+
+         /** \brief Set the minimal translation gradient threshold for early optimization stop
+        * \param[in] translation gradient threshold in meters
+        */
+      void
+      setTranslationGradientTolerance (double tolerance) { translation_gradient_tolerance_ = tolerance; }
+
+      /** \brief Return the minimal translation gradient threshold for early optimization stop
+         */
+      double
+      getTranslationGradientTolerance () const { return translation_gradient_tolerance_; }
+
+         /** \brief Set the minimal rotation gradient threshold for early optimization stop
+        * \param[in] rotation gradient threshold in radians
+        */
+      void
+      setRotationGradientTolerance (double tolerance) { rotation_gradient_tolerance_ = tolerance; }
+
+      /** \brief Return the minimal rotation gradient threshold for early optimization stop
+         */
+      double
+      getRotationGradientTolerance () const { return rotation_gradient_tolerance_; }
 
     protected:
 
-      /** \brief The number of neighbors used for covariances computation. 
+      /** \brief The number of neighbors used for covariances computation.
         * default: 20
         */
       int k_correspondences_;
 
-      /** \brief The epsilon constant for gicp paper; this is NOT the convergence 
-        * tolerance 
+      /** \brief The epsilon constant for gicp paper; this is NOT the convergence
+        * tolerance
         * default: 0.001
         */
       double gicp_epsilon_;
 
-      /** The epsilon constant for rotation error. (In GICP the transformation epsilon 
+      /** The epsilon constant for rotation error. (In GICP the transformation epsilon
         * is split in rotation part and translation part).
         * default: 2e-3
         */
@@ -283,7 +308,6 @@ namespace pcl
       /** \brief Temporary pointer to the target dataset indices. */
       const std::vector<int> *tmp_idx_tgt_;
 
-      
       /** \brief Input cloud points covariances. */
       MatricesVectorPtr input_covariances_;
 
@@ -292,26 +316,32 @@ namespace pcl
 
       /** \brief Mahalanobis matrices holder. */
       std::vector<Eigen::Matrix3d> mahalanobis_;
-      
+
       /** \brief maximum number of optimizations */
       int max_inner_iterations_;
 
-      /** \brief compute points covariances matrices according to the K nearest 
+         /** \brief minimal translation gradient for early optimization stop */
+         double translation_gradient_tolerance_;
+
+         /** \brief minimal rotation gradient for early optimization stop */
+         double rotation_gradient_tolerance_;
+
+      /** \brief compute points covariances matrices according to the K nearest
         * neighbors. K is set via setCorrespondenceRandomness() method.
         * \param cloud pointer to point cloud
         * \param tree KD tree performer for nearest neighbors search
         * \param[out] cloud_covariances covariances matrices for each point in the cloud
         */
       template<typename PointT>
-      void computeCovariances(typename pcl::PointCloud<PointT>::ConstPtr cloud, 
+      void computeCovariances(typename pcl::PointCloud<PointT>::ConstPtr cloud,
                               const typename pcl::search::KdTree<PointT>::Ptr tree,
                               MatricesVector& cloud_covariances);
 
-      /** \return trace of mat1^t . mat2 
+      /** \return trace of mat1^t . mat2
         * \param mat1 matrix of dimension nxm
         * \param mat2 matrix of dimension nxp
         */
-      inline double 
+      inline double
       matricesInnerProd(const Eigen::MatrixXd& mat1, const Eigen::MatrixXd& mat2) const
       {
         double r = 0.;
@@ -327,7 +357,7 @@ namespace pcl
         * \param output the transformed input point cloud dataset using the rigid transformation found
         * \param guess the initial guess of the transformation to compute
         */
-      void 
+      void
       computeTransformation (PointCloudSource &output, const Eigen::Matrix4f &guess) override;
 
       /** \brief Search for the closest nearest neighbor of a given point.
@@ -335,7 +365,7 @@ namespace pcl
         * \param index vector of size 1 to store the index of the nearest neighbour found
         * \param distance vector of size 1 to store the distance to nearest neighbour found
         */
-      inline bool 
+      inline bool
       searchForNeighbors (const PointSource &query, std::vector<int>& index, std::vector<float>& distance)
       {
         int k = tree_->nearestKSearch (query, 1, index, distance);
@@ -346,7 +376,7 @@ namespace pcl
 
       /// \brief compute transformation matrix from transformation matrix
       void applyState(Eigen::Matrix4f &t, const Vector6d& x) const;
-      
+
       /// \brief optimization functor structure
       struct OptimizationFunctorWithIndices : public BFGSDummyFunctor<double,6>
       {
@@ -355,10 +385,11 @@ namespace pcl
         double operator() (const Vector6d& x) override;
         void  df(const Vector6d &x, Vector6d &df) override;
         void fdf(const Vector6d &x, double &f, Vector6d &df) override;
+        BFGSSpace::Status checkGradient(const Vector6d& g) override;
 
         const GeneralizedIterativeClosestPoint *gicp_;
       };
-      
+
       std::function<void(const pcl::PointCloud<PointSource> &cloud_src,
                            const std::vector<int> &src_indices,
                            const pcl::PointCloud<PointTarget> &cloud_tgt,
index 590d8a64b5ccfd5224b728108eaaaa668c6a4c4c..c69f72f7864f8c5030af99f26b3b7b719f6b020b 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
index b920fdef72fc8343c0b3d0f3b62ff74fb8e67cf3..b9d644021a21346a30e7804d4a91a49b766ef322 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/registration.h>
 #include <pcl/registration/transformation_estimation_svd.h>
index 7114cc310d2cd4fa0827eecae2ca975b84be50c7..e3671c144d06e8e306b3c9a29a95d88a2b515122 100644 (file)
@@ -41,7 +41,7 @@
 #pragma once
 
 // PCL includes
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>  // for dynamic_pointer_cast, pcl::make_shared, shared_ptr
 #include <pcl/sample_consensus/ransac.h>
 #include <pcl/sample_consensus/sac_model_registration.h>
 #include <pcl/registration/registration.h>
@@ -51,6 +51,7 @@
 #include <pcl/registration/correspondence_estimation.h>
 #include <pcl/registration/default_convergence_criteria.h>
 
+
 namespace pcl
 {
   /** \brief @b IterativeClosestPoint provides a base implementation of the Iterative Closest Point algorithm. 
@@ -368,7 +369,7 @@ namespace pcl
       setEnforceSameDirectionNormals (bool enforce_same_direction_normals)
       {
         enforce_same_direction_normals_ = enforce_same_direction_normals;
-        auto symmetric_transformation_estimation = boost::dynamic_pointer_cast<pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar> >(transformation_estimation_);
+        auto symmetric_transformation_estimation = dynamic_pointer_cast<pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar> >(transformation_estimation_);
         if (symmetric_transformation_estimation)
             symmetric_transformation_estimation->setEnforceSameDirectionNormals (enforce_same_direction_normals_);
       }
index 3eae7d1fe730b95a5fc41135caaed3854e270f77..0b695a65a0a015bbe435c47d003d0dce1f2dd3da 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_H_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_H_
 
 #include <pcl/common/io.h>
 #include <pcl/common/copy_point.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::setInputTarget (
+CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::setInputTarget (
     const PointCloudTargetConstPtr &cloud)
 {
   if (cloud->points.empty ())
@@ -62,9 +69,9 @@ pcl::registration::CorrespondenceEstimationBase<PointSource, PointTarget, Scalar
   target_cloud_updated_ = true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> bool
-pcl::registration::CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute ()
+CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute ()
 {
   if (!target_)
   {
@@ -87,9 +94,9 @@ pcl::registration::CorrespondenceEstimationBase<PointSource, PointTarget, Scalar
   return (PCLBase<PointSource>::initCompute ());
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> bool
-pcl::registration::CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initComputeReciprocal ()
+CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initComputeReciprocal ()
 {
   // Only update source kd-tree if a new target cloud was set
   if (source_cloud_updated_ && !force_no_recompute_reciprocal_)
@@ -108,9 +115,9 @@ pcl::registration::CorrespondenceEstimationBase<PointSource, PointTarget, Scalar
   return (true);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::determineCorrespondences (
+CorrespondenceEstimation<PointSource, PointTarget, Scalar>::determineCorrespondences (
     pcl::Correspondences &correspondences, double max_distance)
 {
   if (!initCompute ())
@@ -124,7 +131,7 @@ pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::d
   std::vector<float> distance (1);
   pcl::Correspondence corr;
   unsigned int nr_valid_correspondences = 0;
-  
+
   // Check if the template types are the same. If true, avoid a copy.
   // Both point types MUST be registered using the POINT_CLOUD_REGISTER_POINT_STRUCT macro!
   if (isSamePointType<PointSource, PointTarget> ())
@@ -145,7 +152,7 @@ pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::d
   else
   {
     PointTarget pt;
-    
+
     // Iterate over the input set of source indices
     for (std::vector<int>::const_iterator idx = indices_->begin (); idx != indices_->end (); ++idx)
     {
@@ -166,9 +173,9 @@ pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::d
   deinitCompute ();
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::determineReciprocalCorrespondences (
+CorrespondenceEstimation<PointSource, PointTarget, Scalar>::determineReciprocalCorrespondences (
     pcl::Correspondences &correspondences, double max_distance)
 {
   if (!initCompute ())
@@ -216,7 +223,7 @@ pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::d
   {
     PointTarget pt_src;
     PointSource pt_tgt;
-   
+
     // Iterate over the input set of source indices
     for (std::vector<int>::const_iterator idx = indices_->begin (); idx != indices_->end (); ++idx)
     {
@@ -246,6 +253,10 @@ pcl::registration::CorrespondenceEstimation<PointSource, PointTarget, Scalar>::d
   deinitCompute ();
 }
 
+} // namespace registration
+} // namespace pcl
+
 //#define PCL_INSTANTIATE_CorrespondenceEstimation(T,U) template class PCL_EXPORTS pcl::registration::CorrespondenceEstimation<T,U>;
 
 #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_H_ */
+
index fa80ca369c9e6253ce0d1ade9083e97e07dc0f2c..1fa9ba1caa819ee4e034518f3e5c9b6c8bf28bb1 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_HPP_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_HPP_
 
 #include <pcl/common/copy_point.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> bool
-pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar>::initCompute ()
+CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar>::initCompute ()
 {
   if (!source_normals_ || !target_normals_)
   {
@@ -56,7 +63,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar>::determineCorrespondences (
+CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar>::determineCorrespondences (
     pcl::Correspondences &correspondences, double max_distance)
 {
   if (!initCompute ())
@@ -67,9 +74,8 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
   std::vector<int> nn_indices (k_);
   std::vector<float> nn_dists (k_);
 
-  float min_dist = std::numeric_limits<float>::max ();
   int min_index = 0;
-  
+
   pcl::Correspondence corr;
   unsigned int nr_valid_correspondences = 0;
 
@@ -84,8 +90,8 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
 
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<float>::max ();
-      
+      float min_dist = std::numeric_limits<float>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
@@ -93,7 +99,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
                           source_normals_->points[*idx_i].normal_y * target_normals_->points[nn_indices[j]].normal_y +
                           source_normals_->points[*idx_i].normal_z * target_normals_->points[nn_indices[j]].normal_z ;
         float dist = nn_dists[j] * (2.0f - cos_angle * cos_angle);
-        
+
         if (dist < min_dist)
         {
           min_dist = dist;
@@ -112,15 +118,15 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
   else
   {
     PointTarget pt;
-    
+
     // Iterate over the input set of source indices
     for (std::vector<int>::const_iterator idx_i = indices_->begin (); idx_i != indices_->end (); ++idx_i)
     {
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
+
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<float>::max ();
-      
+      float min_dist = std::numeric_limits<float>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
@@ -132,7 +138,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
                           source_normals_->points[*idx_i].normal_y * target_normals_->points[nn_indices[j]].normal_y +
                           source_normals_->points[*idx_i].normal_z * target_normals_->points[nn_indices[j]].normal_z ;
         float dist = nn_dists[j] * (2.0f - cos_angle * cos_angle);
-        
+
         if (dist < min_dist)
         {
           min_dist = dist;
@@ -141,7 +147,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
       }
       if (min_dist > max_distance)
         continue;
-      
+
       corr.index_query = *idx_i;
       corr.index_match = nn_indices[min_index];
       corr.distance = nn_dists[min_index];//min_dist;
@@ -152,9 +158,9 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
   deinitCompute ();
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar>::determineReciprocalCorrespondences (
+CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar>::determineReciprocalCorrespondences (
     pcl::Correspondences &correspondences, double max_distance)
 {
   if (!initCompute ())
@@ -171,9 +177,8 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
   std::vector<int> index_reciprocal (1);
   std::vector<float> distance_reciprocal (1);
 
-  float min_dist = std::numeric_limits<float>::max ();
   int min_index = 0;
-  
+
   pcl::Correspondence corr;
   unsigned int nr_valid_correspondences = 0;
   int target_idx = 0;
@@ -189,8 +194,8 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
 
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<float>::max ();
-      
+      float min_dist = std::numeric_limits<float>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
@@ -198,7 +203,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
                           source_normals_->points[*idx_i].normal_y * target_normals_->points[nn_indices[j]].normal_y +
                           source_normals_->points[*idx_i].normal_z * target_normals_->points[nn_indices[j]].normal_z ;
         float dist = nn_dists[j] * (2.0f - cos_angle * cos_angle);
-        
+
         if (dist < min_dist)
         {
           min_dist = dist;
@@ -224,15 +229,15 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
   else
   {
     PointTarget pt;
-    
+
     // Iterate over the input set of source indices
     for (std::vector<int>::const_iterator idx_i = indices_->begin (); idx_i != indices_->end (); ++idx_i)
     {
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
+
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<float>::max ();
-      
+      float min_dist = std::numeric_limits<float>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
@@ -244,7 +249,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
                           source_normals_->points[*idx_i].normal_y * target_normals_->points[nn_indices[j]].normal_y +
                           source_normals_->points[*idx_i].normal_z * target_normals_->points[nn_indices[j]].normal_z ;
         float dist = nn_dists[j] * (2.0f - cos_angle * cos_angle);
-        
+
         if (dist < min_dist)
         {
           min_dist = dist;
@@ -253,7 +258,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
       }
       if (min_dist > max_distance)
         continue;
-      
+
       // Check if the correspondence is reciprocal
       target_idx = nn_indices[min_index];
       tree_reciprocal_->nearestKSearch (target_->points[target_idx], 1, index_reciprocal, distance_reciprocal);
@@ -271,4 +276,7 @@ pcl::registration::CorrespondenceEstimationBackProjection<PointSource, PointTarg
   deinitCompute ();
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_HPP_
index 81e6e9e3bfdf7bfb0b5c88beed22806dbb0728e6..111fbbda809dd25a94169f0a40c68a97dd288d6d 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_NORMAL_SHOOTING_H_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_NORMAL_SHOOTING_H_
 
 #include <pcl/common/copy_point.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> bool
-pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar>::initCompute ()
+CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar>::initCompute ()
 {
   if (!source_normals_)
   {
@@ -55,9 +62,9 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   return (CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute ());
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar>::determineCorrespondences (
+CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar>::determineCorrespondences (
     pcl::Correspondences &correspondences, double max_distance)
 {
   if (!initCompute ())
@@ -68,9 +75,8 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   std::vector<int> nn_indices (k_);
   std::vector<float> nn_dists (k_);
 
-  double min_dist = std::numeric_limits<double>::max ();
   int min_index = 0;
-  
+
   pcl::Correspondence corr;
   unsigned int nr_valid_correspondences = 0;
 
@@ -85,12 +91,12 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
 
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<double>::max ();
-      
+      double min_dist = std::numeric_limits<double>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
-        // computing the distance between a point and a line in 3d. 
+        // computing the distance between a point and a line in 3d.
         // Reference - http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
         pt.x = target_->points[nn_indices[j]].x - input_->points[*idx_i].x;
         pt.y = target_->points[nn_indices[j]].y - input_->points[*idx_i].y;
@@ -100,7 +106,7 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
         Eigen::Vector3d N (normal.normal_x, normal.normal_y, normal.normal_z);
         Eigen::Vector3d V (pt.x, pt.y, pt.z);
         Eigen::Vector3d C = N.cross (V);
-        
+
         // Check if we have a better correspondence
         double dist = C.dot (C);
         if (dist < min_dist)
@@ -121,15 +127,15 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   else
   {
     PointTarget pt;
-    
+
     // Iterate over the input set of source indices
     for (std::vector<int>::const_iterator idx_i = indices_->begin (); idx_i != indices_->end (); ++idx_i)
     {
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
+
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<double>::max ();
-      
+      double min_dist = std::numeric_limits<double>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
@@ -142,12 +148,12 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
         pt.x = target_->points[nn_indices[j]].x - pt_src.x;
         pt.y = target_->points[nn_indices[j]].y - pt_src.y;
         pt.z = target_->points[nn_indices[j]].z - pt_src.z;
-        
+
         const NormalT &normal = source_normals_->points[*idx_i];
         Eigen::Vector3d N (normal.normal_x, normal.normal_y, normal.normal_z);
         Eigen::Vector3d V (pt.x, pt.y, pt.z);
         Eigen::Vector3d C = N.cross (V);
-        
+
         // Check if we have a better correspondence
         double dist = C.dot (C);
         if (dist < min_dist)
@@ -158,7 +164,7 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
       }
       if (min_dist > max_distance)
         continue;
-      
+
       corr.index_query = *idx_i;
       corr.index_match = nn_indices[min_index];
       corr.distance = nn_dists[min_index];//min_dist;
@@ -169,9 +175,9 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   deinitCompute ();
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar>::determineReciprocalCorrespondences (
+CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar>::determineReciprocalCorrespondences (
     pcl::Correspondences &correspondences, double max_distance)
 {
   if (!initCompute ())
@@ -189,9 +195,8 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   std::vector<int> index_reciprocal (1);
   std::vector<float> distance_reciprocal (1);
 
-  double min_dist = std::numeric_limits<double>::max ();
   int min_index = 0;
-  
+
   pcl::Correspondence corr;
   unsigned int nr_valid_correspondences = 0;
   int target_idx = 0;
@@ -207,12 +212,12 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
 
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<double>::max ();
-      
+      double min_dist = std::numeric_limits<double>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
-        // computing the distance between a point and a line in 3d. 
+        // computing the distance between a point and a line in 3d.
         // Reference - http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
         pt.x = target_->points[nn_indices[j]].x - input_->points[*idx_i].x;
         pt.y = target_->points[nn_indices[j]].y - input_->points[*idx_i].y;
@@ -222,7 +227,7 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
         Eigen::Vector3d N (normal.normal_x, normal.normal_y, normal.normal_z);
         Eigen::Vector3d V (pt.x, pt.y, pt.z);
         Eigen::Vector3d C = N.cross (V);
-        
+
         // Check if we have a better correspondence
         double dist = C.dot (C);
         if (dist < min_dist)
@@ -251,15 +256,15 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   else
   {
     PointTarget pt;
-    
+
     // Iterate over the input set of source indices
     for (std::vector<int>::const_iterator idx_i = indices_->begin (); idx_i != indices_->end (); ++idx_i)
     {
       tree_->nearestKSearch (input_->points[*idx_i], k_, nn_indices, nn_dists);
 
       // Among the K nearest neighbours find the one with minimum perpendicular distance to the normal
-      min_dist = std::numeric_limits<double>::max ();
-      
+      double min_dist = std::numeric_limits<double>::max ();
+
       // Find the best correspondence
       for (std::size_t j = 0; j < nn_indices.size (); j++)
       {
@@ -267,17 +272,17 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
         // Copy the source data to a target PointTarget format so we can search in the tree
         copyPoint (input_->points[*idx_i], pt_src);
 
-        // computing the distance between a point and a line in 3d. 
+        // computing the distance between a point and a line in 3d.
         // Reference - http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
         pt.x = target_->points[nn_indices[j]].x - pt_src.x;
         pt.y = target_->points[nn_indices[j]].y - pt_src.y;
         pt.z = target_->points[nn_indices[j]].z - pt_src.z;
-        
+
         const NormalT &normal = source_normals_->points[*idx_i];
         Eigen::Vector3d N (normal.normal_x, normal.normal_y, normal.normal_z);
         Eigen::Vector3d V (pt.x, pt.y, pt.z);
         Eigen::Vector3d C = N.cross (V);
-        
+
         // Check if we have a better correspondence
         double dist = C.dot (C);
         if (dist < min_dist)
@@ -307,4 +312,7 @@ pcl::registration::CorrespondenceEstimationNormalShooting<PointSource, PointTarg
   deinitCompute ();
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_NORMAL_SHOOTING_H_
index 557e5dd17981110a1ac2a14e1ab83ea8206e4eaf..a75a6e74595482bc5f71dfd35e147ba848c6945f 100644 (file)
  *
  */
 
+
 #ifndef PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_ORGANIZED_PROJECTION_IMPL_HPP_
 #define PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_ORGANIZED_PROJECTION_IMPL_HPP_
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> bool
-pcl::registration::CorrespondenceEstimationOrganizedProjection<PointSource, PointTarget, Scalar>::initCompute ()
+CorrespondenceEstimationOrganizedProjection<PointSource, PointTarget, Scalar>::initCompute ()
 {
   // Set the target_cloud_updated_ variable to true, so that the kd-tree is not built - it is not needed for this class
   target_cloud_updated_ = false;
@@ -66,9 +73,9 @@ pcl::registration::CorrespondenceEstimationOrganizedProjection<PointSource, Poin
   return (true);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::CorrespondenceEstimationOrganizedProjection<PointSource, PointTarget, Scalar>::determineCorrespondences (
+CorrespondenceEstimationOrganizedProjection<PointSource, PointTarget, Scalar>::determineCorrespondences (
     pcl::Correspondences &correspondences,
     double max_distance)
 {
@@ -113,9 +120,9 @@ pcl::registration::CorrespondenceEstimationOrganizedProjection<PointSource, Poin
   correspondences.resize (c_index);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::CorrespondenceEstimationOrganizedProjection<PointSource, PointTarget, Scalar>::determineReciprocalCorrespondences (
+CorrespondenceEstimationOrganizedProjection<PointSource, PointTarget, Scalar>::determineReciprocalCorrespondences (
     pcl::Correspondences &correspondences,
     double max_distance)
 {
@@ -123,5 +130,8 @@ pcl::registration::CorrespondenceEstimationOrganizedProjection<PointSource, Poin
   determineCorrespondences (correspondences, max_distance);
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_ORGANIZED_PROJECTION_IMPL_HPP_
 
index 96916baf3a5d34d868765390370ebefbf5d5ac0f..4545f073310c907a56021217a560485a33ea9595 100644 (file)
  * $Id$
  *
  */
+
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_FEATURES_HPP_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_FEATURES_HPP_
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename FeatureT> inline void 
-pcl::registration::CorrespondenceRejectorFeatures::setSourceFeature (
+
+namespace pcl
+{
+
+namespace registration
+{
+
+template <typename FeatureT> inline void
+CorrespondenceRejectorFeatures::setSourceFeature (
     const typename pcl::PointCloud<FeatureT>::ConstPtr &source_feature, const std::string &key)
 {
   if (features_map_.count (key) == 0)
@@ -50,18 +58,18 @@ pcl::registration::CorrespondenceRejectorFeatures::setSourceFeature (
   boost::static_pointer_cast<FeatureContainer<FeatureT> > (features_map_[key])->setSourceFeature (source_feature);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename FeatureT> inline typename pcl::PointCloud<FeatureT>::ConstPtr 
-pcl::registration::CorrespondenceRejectorFeatures::getSourceFeature (const std::string &key)
+
+template <typename FeatureT> inline typename pcl::PointCloud<FeatureT>::ConstPtr
+CorrespondenceRejectorFeatures::getSourceFeature (const std::string &key)
 {
   if (features_map_.count (key) == 0)
     return (nullptr);
   return (boost::static_pointer_cast<FeatureContainer<FeatureT> > (features_map_[key])->getSourceFeature ());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename FeatureT> inline void 
-pcl::registration::CorrespondenceRejectorFeatures::setTargetFeature (
+
+template <typename FeatureT> inline void
+CorrespondenceRejectorFeatures::setTargetFeature (
     const typename pcl::PointCloud<FeatureT>::ConstPtr &target_feature, const std::string &key)
 {
   if (features_map_.count (key) == 0)
@@ -69,18 +77,18 @@ pcl::registration::CorrespondenceRejectorFeatures::setTargetFeature (
   boost::static_pointer_cast<FeatureContainer<FeatureT> > (features_map_[key])->setTargetFeature (target_feature);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename FeatureT> inline typename pcl::PointCloud<FeatureT>::ConstPtr 
-pcl::registration::CorrespondenceRejectorFeatures::getTargetFeature (const std::string &key)
+
+template <typename FeatureT> inline typename pcl::PointCloud<FeatureT>::ConstPtr
+CorrespondenceRejectorFeatures::getTargetFeature (const std::string &key)
 {
   if (features_map_.count (key) == 0)
     return (nullptr);
   return (boost::static_pointer_cast<FeatureContainer<FeatureT> > (features_map_[key])->getTargetFeature ());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename FeatureT> inline void 
-pcl::registration::CorrespondenceRejectorFeatures::setDistanceThreshold (
+
+template <typename FeatureT> inline void
+CorrespondenceRejectorFeatures::setDistanceThreshold (
     double thresh, const std::string &key)
 {
   if (features_map_.count (key) == 0)
@@ -89,10 +97,8 @@ pcl::registration::CorrespondenceRejectorFeatures::setDistanceThreshold (
 }
 
 
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename FeatureT> inline void 
-pcl::registration::CorrespondenceRejectorFeatures::setFeatureRepresentation (
+template <typename FeatureT> inline void
+CorrespondenceRejectorFeatures::setFeatureRepresentation (
   const typename pcl::PointRepresentation<FeatureT>::ConstPtr &fr,
   const std::string &key)
 {
@@ -101,5 +107,8 @@ pcl::registration::CorrespondenceRejectorFeatures::setFeatureRepresentation (
   boost::static_pointer_cast<FeatureContainer<FeatureT> > (features_map_[key])->setFeatureRepresentation (fr);
 }
 
+} // namespace registration
+} // namespace pcl
 
 #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_FEATURES_HPP_ */
+
index dac077e06cf6a139cf1f5b24a8993e3d66035dba..906d8f057373ef1a1a709103fe549d6422f8a179 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  *
  */
+
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_POLY_HPP_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_POLY_HPP_
 
-///////////////////////////////////////////////////////////////////////////////////////////
-template <typename SourceT, typename TargetT> void 
-pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCorrespondences (
-    const pcl::Correspondences& original_correspondences, 
+
+namespace pcl
+{
+
+namespace registration
+{
+
+template <typename SourceT, typename TargetT> void
+CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCorrespondences (
+    const pcl::Correspondences& original_correspondences,
     pcl::Correspondences& remaining_correspondences)
 {
   // This is reset after all the checks below
   remaining_correspondences = original_correspondences;
-  
+
   // Check source/target
   if (!input_)
   {
@@ -61,7 +69,7 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCor
                getClassName ().c_str ());
     return;
   }
-  
+
   // Check cardinality
   if (cardinality_ < 2)
   {
@@ -69,7 +77,7 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCor
                getClassName ().c_str() );
     return;
   }
-  
+
   // Number of input correspondences
   const int nr_correspondences = static_cast<int> (original_correspondences.size ());
 
@@ -80,7 +88,7 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCor
                getClassName ().c_str() );
     return;
   }
-  
+
   // Check similarity
   if (similarity_threshold_ < 0.0f || similarity_threshold_ > 1.0f)
   {
@@ -88,24 +96,24 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCor
                getClassName ().c_str() );
     return;
   }
-  
+
   // Similarity, squared
   similarity_threshold_squared_ = similarity_threshold_ * similarity_threshold_;
 
   // Initialization of result
   remaining_correspondences.clear ();
   remaining_correspondences.reserve (nr_correspondences);
-  
+
   // Number of times a correspondence is sampled and number of times it was accepted
   std::vector<int> num_samples (nr_correspondences, 0);
   std::vector<int> num_accepted (nr_correspondences, 0);
-  
+
   // Main loop
   for (int i = 0; i < iterations_; ++i)
   {
     // Sample cardinality_ correspondences without replacement
     const std::vector<int> idx = getUniqueRandomIndices (nr_correspondences, cardinality_);
-    
+
     // Verify the polygon similarity
     if (thresholdPolygon (original_correspondences, idx))
     {
@@ -123,7 +131,7 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCor
         ++num_samples[ idx[j] ];
     }
   }
-  
+
   // Now calculate the acceptance rate of each correspondence
   std::vector<float> accept_rate (nr_correspondences, 0.0f);
   for (int i = 0; i < nr_correspondences; ++i)
@@ -134,50 +142,50 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::getRemainingCor
     else
       accept_rate[i] = static_cast<float> (num_accepted[i]) / static_cast<float> (numsi);
   }
-  
+
   // Compute a histogram in range [0,1] for acceptance rates
   const int hist_size = nr_correspondences / 2; // TODO: Optimize this
   const std::vector<int> histogram = computeHistogram (accept_rate, 0.0f, 1.0f, hist_size);
-  
+
   // Find the cut point between outliers and inliers using Otsu's thresholding method
   const int cut_idx = findThresholdOtsu (histogram);
   const float cut = static_cast<float> (cut_idx) / static_cast<float> (hist_size);
-  
+
   // Threshold
   for (int i = 0; i < nr_correspondences; ++i)
     if (accept_rate[i] > cut)
       remaining_correspondences.push_back (original_correspondences[i]);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename SourceT, typename TargetT> std::vector<int> 
-pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::computeHistogram (const std::vector<float>& data,
-                                                                         float lower, float upper, int bins)
+
+template <typename SourceT, typename TargetT> std::vector<int>
+CorrespondenceRejectorPoly<SourceT, TargetT>::computeHistogram (const std::vector<float>& data,
+                                                                float lower, float upper, int bins)
 {
   // Result
   std::vector<int> result (bins, 0);
-  
+
   // Last index into result and increment factor from data value --> index
   const int last_idx = bins - 1;
   const float idx_per_val = static_cast<float> (bins) / (upper - lower);
-  
+
   // Accumulate
   for (const float &value : data)
      ++result[ std::min (last_idx, int (value*idx_per_val)) ];
-  
+
   return (result);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename SourceT, typename TargetT> int 
-pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::findThresholdOtsu (const std::vector<int>& histogram)
+
+template <typename SourceT, typename TargetT> int
+CorrespondenceRejectorPoly<SourceT, TargetT>::findThresholdOtsu (const std::vector<int>& histogram)
 {
   // Precision
   const double eps = std::numeric_limits<double>::epsilon();
-  
+
   // Histogram dimension
   const int nbins = static_cast<int> (histogram.size ());
-  
+
   // Mean and inverse of the number of data points
   double mean = 0.0;
   double sum_inv = 0.0;
@@ -188,45 +196,45 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::findThresholdOt
   }
   sum_inv = 1.0/sum_inv;
   mean *= sum_inv;
-  
+
   // Probability and mean of class 1 (data to the left of threshold)
   double class_mean1 = 0.0;
   double class_prob1 = 0.0;
   double class_prob2 = 1.0;
-  
+
   // Maximized between class variance and associated bin value
   double between_class_variance_max = 0.0;
   int result = 0;
-  
+
   // Loop over all bin values
   for (int i = 0; i < nbins; ++i)
   {
     class_mean1 *= class_prob1;
-    
+
     // Probability of bin i
     const double prob_i = static_cast<double> (histogram[i]) * sum_inv;
-    
+
     // Class probability 1: sum of probabilities from 0 to i
     class_prob1 += prob_i;
-    
+
     // Class probability 2: sum of probabilities from i+1 to nbins-1
     class_prob2 -= prob_i;
-    
+
     // Avoid division by zero below
     if (std::min (class_prob1,class_prob2) < eps || std::max (class_prob1,class_prob2) > 1.0-eps)
       continue;
-    
+
     // Class mean 1: sum of probabilities from 0 to i, weighted by bin value
     class_mean1 = (class_mean1 + static_cast<double> (i) * prob_i) / class_prob1;
-    
+
     // Class mean 2: sum of probabilities from i+1 to nbins-1, weighted by bin value
     const double class_mean2 = (mean - class_prob1*class_mean1) / class_prob2;
-    
+
     // Between class variance
     const double between_class_variance = class_prob1 * class_prob2
                                           * (class_mean1 - class_mean2)
                                           * (class_mean1 - class_mean2);
-    
+
     // If between class variance is maximized, update result
     if (between_class_variance > between_class_variance_max)
     {
@@ -234,8 +242,12 @@ pcl::registration::CorrespondenceRejectorPoly<SourceT, TargetT>::findThresholdOt
       result = i;
     }
   }
-  
+
   return (result);
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_POLY_HPP_
+
index d8a4073b5bc1d96f14cad109c893970e9e9b1d03..7aa36b13003407cf4ec18af0637c50e04579a5b2 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SAMPLE_CONSENSUS_HPP_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SAMPLE_CONSENSUS_HPP_
 
 #include <unordered_map>
 
-///////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void 
-pcl::registration::CorrespondenceRejectorSampleConsensus<PointT>::getRemainingCorrespondences (
-    const pcl::Correspondences& original_correspondences, 
+
+namespace pcl
+{
+
+namespace registration
+{
+
+template <typename PointT> void
+CorrespondenceRejectorSampleConsensus<PointT>::getRemainingCorrespondences (
+    const pcl::Correspondences& original_correspondences,
     pcl::Correspondences& remaining_correspondences)
 {
   if (!input_)
@@ -133,4 +140,8 @@ pcl::registration::CorrespondenceRejectorSampleConsensus<PointT>::getRemainingCo
    }
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SAMPLE_CONSENSUS_HPP_
+
index 12357dfe54983c2feeb9d7cb65e625b6f8821dd7..173c524a08b8a53943c6ab38c66153cb778620e3 100644 (file)
@@ -35,6 +35,7 @@
  *
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SAMPLE_CONSENSUS_2D_HPP_
 #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SAMPLE_CONSENSUS_2D_HPP_
 
 
 #include <unordered_map>
 
-///////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void 
-pcl::registration::CorrespondenceRejectorSampleConsensus2D<PointT>::getRemainingCorrespondences (
-    const pcl::Correspondences& original_correspondences, 
+
+namespace pcl
+{
+
+namespace registration
+{
+
+template <typename PointT> void
+CorrespondenceRejectorSampleConsensus2D<PointT>::getRemainingCorrespondences (
+    const pcl::Correspondences& original_correspondences,
     pcl::Correspondences& remaining_correspondences)
 {
   if (!input_)
@@ -127,5 +134,8 @@ pcl::registration::CorrespondenceRejectorSampleConsensus2D<PointT>::getRemaining
   best_transformation_.row (3) = model_coefficients.segment<4>(12);
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SAMPLE_CONSENSUS_2D_HPP_
 
index bc89e93c75ae2df8737df4b75d52e50620e5181b..2a2eb88d43d399098c2a5af734320bf94c827f45 100644 (file)
 #include <cstddef>
 #include <vector>
 
+
+namespace pcl
+{
+
+namespace registration
+{
+
 inline void
-pcl::registration::getCorDistMeanStd (const pcl::Correspondences &correspondences, double &mean, double &stddev)
+getCorDistMeanStd (const pcl::Correspondences &correspondences, double &mean, double &stddev)
 {
   if (correspondences.empty ())
     return;
@@ -64,7 +71,7 @@ pcl::registration::getCorDistMeanStd (const pcl::Correspondences &correspondence
 }
 
 inline void
-pcl::registration::getQueryIndices (const pcl::Correspondences& correspondences, std::vector<int>& indices)
+getQueryIndices (const pcl::Correspondences& correspondences, std::vector<int>& indices)
 {
   indices.resize (correspondences.size ());
   for (std::size_t i = 0; i < correspondences.size (); ++i)
@@ -73,9 +80,13 @@ pcl::registration::getQueryIndices (const pcl::Correspondences& correspondences,
 
 
 inline void
-pcl::registration::getMatchIndices (const pcl::Correspondences& correspondences, std::vector<int>& indices)
+getMatchIndices (const pcl::Correspondences& correspondences, std::vector<int>& indices)
 {
   indices.resize (correspondences.size ());
   for (std::size_t i = 0; i < correspondences.size (); ++i)
     indices[i] = correspondences[i].index_match;
 }
+
+} // namespace registration
+} // namespace pcl
+
index 1dac2786e8e3df6cef82fcc00c4dc6048a242e7c..b67439973f2572688c58079ededba4f547cf6c6c 100644 (file)
 
 #include <pcl/console/print.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename Scalar> bool
-pcl::registration::DefaultConvergenceCriteria<Scalar>::hasConverged ()
+DefaultConvergenceCriteria<Scalar>::hasConverged ()
 {
   if (convergence_state_ != CONVERGENCE_CRITERIA_NOT_CONVERGED)
   {
@@ -52,7 +58,7 @@ pcl::registration::DefaultConvergenceCriteria<Scalar>::hasConverged ()
     iterations_similar_transforms_ = 0;
     convergence_state_ = CONVERGENCE_CRITERIA_NOT_CONVERGED;
   }
-  
+
   bool is_similar = false;
 
   PCL_DEBUG ("[pcl::DefaultConvergenceCriteria::hasConverged] Iteration %d out of %d.\n", iterations_, max_iterations_);
@@ -98,7 +104,7 @@ pcl::registration::DefaultConvergenceCriteria<Scalar>::hasConverged ()
     }
     is_similar = true;
   }
-  
+
   // Relative
   if (std::abs (correspondences_cur_mse_ - correspondences_prev_mse_) / correspondences_prev_mse_ < mse_threshold_relative_)
   {
@@ -126,4 +132,8 @@ pcl::registration::DefaultConvergenceCriteria<Scalar>::hasConverged ()
   return (false);
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_DEFAULT_CONVERGENCE_CRITERIA_HPP_
+
index 234b28ef4c14085e1615342a9ad184de41d2316c..651ab34f70a6ce5ea443a5a9781149e1f1355e01 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_GICP_HPP_
 #define PCL_REGISTRATION_IMPL_GICP_HPP_
 
 #include <pcl/registration/boost.h>
 #include <pcl/registration/exceptions.h>
 
-////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointSource, typename PointTarget>
 template<typename PointT> void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeCovariances(typename pcl::PointCloud<PointT>::ConstPtr cloud,
-                                                                                    const typename pcl::search::KdTree<PointT>::Ptr kdtree,
-                                                                                    MatricesVector& cloud_covariances)
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeCovariances(typename pcl::PointCloud<PointT>::ConstPtr cloud,
+                                                                               const typename pcl::search::KdTree<PointT>::Ptr kdtree,
+                                                                               MatricesVector& cloud_covariances)
 {
   if (k_correspondences_ > int (cloud->size ()))
   {
@@ -121,9 +125,9 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeCovarian
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget> void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeRDerivative(const Vector6d &x, const Eigen::Matrix3d &R, Vector6d& g) const
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeRDerivative(const Vector6d &x, const Eigen::Matrix3d &R, Vector6d& g) const
 {
   Eigen::Matrix3d dR_dPhi;
   Eigen::Matrix3d dR_dTheta;
@@ -176,13 +180,13 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeRDerivat
   g[5] = matricesInnerProd(dR_dPsi, R);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget> void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::estimateRigidTransformationBFGS (const PointCloudSource &cloud_src,
-                                                                                                  const std::vector<int> &indices_src,
-                                                                                                  const PointCloudTarget &cloud_tgt,
-                                                                                                  const std::vector<int> &indices_tgt,
-                                                                                                  Eigen::Matrix4f &transformation_matrix)
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::estimateRigidTransformationBFGS (const PointCloudSource &cloud_src,
+                                                                                             const std::vector<int> &indices_src,
+                                                                                             const PointCloudTarget &cloud_tgt,
+                                                                                             const std::vector<int> &indices_tgt,
+                                                                                             Eigen::Matrix4f &transformation_matrix)
 {
   if (indices_src.size () < 4)     // need at least 4 samples
   {
@@ -192,9 +196,12 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::estimateRigidTr
   }
   // Set the initial solution
   Vector6d x = Vector6d::Zero ();
+  // translation part
   x[0] = transformation_matrix (0,3);
   x[1] = transformation_matrix (1,3);
   x[2] = transformation_matrix (2,3);
+  // rotation part (Z Y X euler angles convention)
+  // see: https://en.wikipedia.org/wiki/Rotation_matrix#General_rotations
   x[3] = std::atan2 (transformation_matrix (2,1), transformation_matrix (2,2));
   x[4] = asin (-transformation_matrix (2,0));
   x[5] = std::atan2 (transformation_matrix (1,0), transformation_matrix (0,0));
@@ -206,7 +213,6 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::estimateRigidTr
   tmp_idx_tgt_ = &indices_tgt;
 
   // Optimize using forward-difference approximation LM
-  const double gradient_tol = 1e-2;
   OptimizationFunctorWithIndices functor(this);
   BFGS<OptimizationFunctorWithIndices> bfgs (functor);
   bfgs.parameters.sigma = 0.01;
@@ -227,7 +233,7 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::estimateRigidTr
     {
       break;
     }
-    result = bfgs.testGradient(gradient_tol);
+    result = bfgs.testGradient();
   } while(result == BFGSSpace::Running && inner_iterations_ < max_inner_iterations_);
   if(result == BFGSSpace::NoProgress || result == BFGSSpace::Success || inner_iterations_ == max_inner_iterations_)
   {
@@ -241,9 +247,9 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::estimateRigidTr
                         "[pcl::" << getClassName () << "::TransformationEstimationBFGS::estimateRigidTransformation] BFGS solver didn't converge!");
 }
 
-////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget> inline double
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::operator() (const Vector6d& x)
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::operator() (const Vector6d& x)
 {
   Eigen::Matrix4f transformation_matrix = gicp_->base_transformation_;
   gicp_->applyState(transformation_matrix, x);
@@ -266,9 +272,9 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFun
   return f/m;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget> inline void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::df (const Vector6d& x, Vector6d& g)
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::df (const Vector6d& x, Vector6d& g)
 {
   Eigen::Matrix4f transformation_matrix = gicp_->base_transformation_;
   gicp_->applyState(transformation_matrix, x);
@@ -302,9 +308,9 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFun
   gicp_->computeRDerivative(x, R, g);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget> inline void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::fdf (const Vector6d& x, double& f, Vector6d& g)
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::fdf (const Vector6d& x, double& f, Vector6d& g)
 {
   Eigen::Matrix4f transformation_matrix = gicp_->base_transformation_;
   gicp_->applyState(transformation_matrix, x);
@@ -339,9 +345,29 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFun
   gicp_->computeRDerivative(x, R, g);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////
+template <typename PointSource, typename PointTarget> inline BFGSSpace::Status
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::OptimizationFunctorWithIndices::checkGradient(const Vector6d& g)
+{
+  auto translation_epsilon = gicp_->translation_gradient_tolerance_;
+  auto rotation_epsilon = gicp_->rotation_gradient_tolerance_;
+
+  if ((translation_epsilon < 0.) || (rotation_epsilon < 0.))
+    return BFGSSpace::NegativeGradientEpsilon;
+
+  // express translation gradient as norm of translation parameters
+  auto translation_grad = g.head<3>().norm();
+
+  // express rotation gradient as a norm of rotation parameters
+  auto rotation_grad = g.tail<3>().norm();
+
+  if ((translation_grad < translation_epsilon) && (rotation_grad < rotation_epsilon))
+       return BFGSSpace::Success;
+
+  return BFGSSpace::Running;
+}
+
 template <typename PointSource, typename PointTarget> inline void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f& guess)
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f& guess)
 {
   pcl::IterativeClosestPoint<PointSource, PointTarget>::initComputeReciprocal ();
   using namespace std;
@@ -354,7 +380,7 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeTransfor
   // Compute target cloud covariance matrices
   if ((!target_covariances_) || (target_covariances_->empty ()))
   {
-    target_covariances_.reset (new MatricesVector);  
+    target_covariances_.reset (new MatricesVector);
     computeCovariances<PointTarget> (target_, tree_, *target_covariances_);
   }
   // Compute input cloud covariance matrices
@@ -463,10 +489,11 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::computeTransfor
   pcl::transformPointCloud (*input_, output, final_transformation_);
 }
 
+
 template <typename PointSource, typename PointTarget> void
-pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::applyState(Eigen::Matrix4f &t, const Vector6d& x) const
+GeneralizedIterativeClosestPoint<PointSource, PointTarget>::applyState(Eigen::Matrix4f &t, const Vector6d& x) const
 {
-  // !!! CAUTION Stanford GICP uses the Z Y X euler angles convention
+  // Z Y X euler angles convention
   Eigen::Matrix3f R;
   R = Eigen::AngleAxisf (static_cast<float> (x[5]), Eigen::Vector3f::UnitZ ())
     * Eigen::AngleAxisf (static_cast<float> (x[4]), Eigen::Vector3f::UnitY ())
@@ -476,4 +503,7 @@ pcl::GeneralizedIterativeClosestPoint<PointSource, PointTarget>::applyState(Eige
   t.col (3) += T;
 }
 
+} // namespace pcl
+
 #endif //PCL_REGISTRATION_IMPL_GICP_HPP_
+
index d758c14d063f5e516c2eabcf50f3cc4b83e2d228..101016953ffcfaf99d090d4240bd5dcd76718886 100644 (file)
@@ -41,6 +41,7 @@
 #include <pcl/registration/ia_fpcs.h>
 #include <pcl/common/time.h>
 #include <pcl/common/distances.h>
+#include <pcl/common/utils.h>
 #include <pcl/sample_consensus/sac_model_plane.h>
 #include <pcl/registration/transformation_estimation_3point.h>
 
@@ -59,13 +60,14 @@ pcl::getMeanPointDensity (const typename pcl::PointCloud<PointT>::ConstPtr &clou
   std::vector <int> ids (2);
   std::vector <float> dists_sqr (2);
 
-#ifdef _OPENMP
+  pcl::utils::ignore(nr_threads);
 #pragma omp parallel for \
-  reduction (+:mean_dist, num) \
-  private (ids, dists_sqr) shared (tree, cloud) firstprivate (s, max_dist_sqr) \
-  default (none)num_threads (nr_threads)
-#endif
-
+  default(none) \
+  shared(tree, cloud) \
+  private(ids, dists_sqr) \
+  reduction(+:mean_dist, num) \
+  firstprivate(s, max_dist_sqr) \
+  num_threads(nr_threads)
   for (int i = 0; i < 1000; i++)
   {
     tree.nearestKSearch (cloud->points[rand () % s], 2, ids, dists_sqr);
@@ -96,13 +98,14 @@ pcl::getMeanPointDensity (const typename pcl::PointCloud<PointT>::ConstPtr &clou
   std::vector <int> ids (2);
   std::vector <float> dists_sqr (2);
 
-#ifdef _OPENMP
+  pcl::utils::ignore(nr_threads);
 #pragma omp parallel for \
-  reduction (+:mean_dist, num) \
-  private (ids, dists_sqr) shared (tree, cloud, indices) firstprivate (s, max_dist_sqr) \
-  default (none)num_threads (nr_threads)
-#endif
-
+  default(none) \
+  shared(tree, cloud, indices) \
+  private(ids, dists_sqr) \
+  reduction(+:mean_dist, num) \
+  firstprivate(s, max_dist_sqr) \
+  num_threads(nr_threads)
   for (int i = 0; i < 1000; i++)
   {
     tree.nearestKSearch (cloud->points[indices[rand () % s]], 2, ids, dists_sqr);
@@ -162,20 +165,18 @@ pcl::registration::FPCSInitialAlignment <PointSource, PointTarget, NormalT, Scal
   std::vector <MatchingCandidates> all_candidates (max_iterations_);
   pcl::StopWatch timer;
 
-  #ifdef _OPENMP
-  #pragma omp parallel num_threads (nr_threads_)
-  #endif
+  #pragma omp parallel \
+    default(none) \
+    shared(abort, all_candidates, timer) \
+    num_threads(nr_threads_)
   {
     #ifdef _OPENMP
     std::srand (static_cast <unsigned int> (std::time (NULL)) ^ omp_get_thread_num ());    
-    #pragma omp for schedule (dynamic)
+    #pragma omp for schedule(dynamic)
     #endif
     for (int i = 0; i < max_iterations_; i++)
     {
-
-      #ifdef _OPENMP
       #pragma omp flush (abort)
-      #endif
 
       MatchingCandidates candidates (1);
       std::vector <int> base_indices (4);
@@ -209,9 +210,7 @@ pcl::registration::FPCSInitialAlignment <PointSource, PointTarget, NormalT, Scal
         abort = (abort ? abort : timer.getTimeSeconds () > max_runtime_);
 
 
-        #ifdef _OPENMP
         #pragma omp flush (abort)
-        #endif
       }
     }
   }
index 7f08fd543f2271ba341673ac532bf6817417d3ae..42c86e2549e916278cbb01b0794a95527f978a42 100644 (file)
 #ifndef PCL_REGISTRATION_IMPL_IA_KFPCS_H_
 #define PCL_REGISTRATION_IMPL_IA_KFPCS_H_
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar>
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::KFPCSInitialAlignment () :
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::KFPCSInitialAlignment () :
   lower_trl_boundary_ (-1.f),
-  upper_trl_boundary_ (-1.f),  
+  upper_trl_boundary_ (-1.f),
   lambda_ (0.5f),
   use_trl_score_ (false),
   indices_validation_ (new std::vector <int>)
@@ -50,9 +56,8 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
 }
 
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> bool
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::initCompute ()
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::initCompute ()
 {
   // due to sparse keypoint cloud, do not normalize delta with estimated point density
   if (normalize_delta_)
@@ -92,22 +97,20 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
 }
 
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::handleMatches (
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::handleMatches (
   const std::vector <int> &base_indices,
   std::vector <std::vector <int> > &matches,
   MatchingCandidates &candidates)
 {
   candidates.clear ();
-  float fitness_score = FLT_MAX;
 
   // loop over all Candidate matches
   for (auto &match : matches)
   {
     Eigen::Matrix4f transformation_temp;
     pcl::Correspondences correspondences_temp;
-    fitness_score = FLT_MAX; // reset to FLT_MAX to accept all candidates and not only best
+    float fitness_score = FLT_MAX; // reset to FLT_MAX to accept all candidates and not only best
 
     // determine corresondences between base and match according to their distance to centroid
     linkMatchWithBase (base_indices, match, correspondences_temp);
@@ -126,9 +129,8 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
 }
 
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> int
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::validateTransformation (
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::validateTransformation (
   Eigen::Matrix4f &transformation,
   float &fitness_score)
 {
@@ -138,7 +140,7 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
 
   const std::size_t nr_points = source_transformed.size ();
   float score_a = 0.f, score_b = 0.f;
-  
+
   // residual costs based on mse
   std::vector <int> ids;
   std::vector <float> dists_sqr;
@@ -173,9 +175,8 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
 }
 
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::finalCompute (
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::finalCompute (
   const std::vector <MatchingCandidates > &candidates)
 {
   // reorganize candidates into single vector
@@ -210,9 +211,9 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
   converged_ = fitness_score_ < score_threshold_;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::getNBestCandidates (
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::getNBestCandidates (
   int n,
   float min_angle3d,
   float min_translation3d,
@@ -249,9 +250,9 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> void
-pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::getTBestCandidates (
+KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::getTBestCandidates (
   float t,
   float min_angle3d,
   float min_translation3d,
@@ -284,6 +285,8 @@ pcl::registration::KFPCSInitialAlignment <PointSource, PointTarget, NormalT, Sca
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+} // namespace registration
+} // namespace pcl
 
 #endif // PCL_REGISTRATION_IMPL_IA_KFPCS_H_
+
index 2026ccb1feb3177b1cec6f3ca1d611178a5a4910..bc32641c70c66e089687aa6f712d885cec60bae5 100644 (file)
 
 #include <pcl/common/distances.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::setSourceFeatures (const FeatureCloudConstPtr &features)
+
+namespace pcl
+{
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::setSourceFeatures (const FeatureCloudConstPtr &features)
 {
   if (features == nullptr || features->empty ())
   {
@@ -55,9 +58,9 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::setSou
   input_features_ = features;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::setTargetFeatures (const FeatureCloudConstPtr &features)
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::setTargetFeatures (const FeatureCloudConstPtr &features)
 {
   if (features == nullptr || features->empty ())
   {
@@ -68,10 +71,10 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::setTar
   feature_tree_->setInputCloud (target_features_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::selectSamples (
-    const PointCloudSource &cloud, int nr_samples, float min_sample_distance, 
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::selectSamples (
+    const PointCloudSource &cloud, int nr_samples, float min_sample_distance,
     std::vector<int> &sample_indices)
 {
   if (nr_samples > static_cast<int> (cloud.points.size ()))
@@ -127,10 +130,10 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::select
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::findSimilarFeatures (
-    const FeatureCloud &input_features, const std::vector<int> &sample_indices, 
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::findSimilarFeatures (
+    const FeatureCloud &input_features, const std::vector<int> &sample_indices,
     std::vector<int> &corresponding_indices)
 {
   std::vector<int> nn_indices (k_correspondences_);
@@ -148,9 +151,9 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::findSi
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> float 
-pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::computeErrorMetric (
+
+template <typename PointSource, typename PointTarget, typename FeatureT> float
+SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::computeErrorMetric (
     const PointCloudSource &cloud, float)
 {
   std::vector<int> nn_index (1);
@@ -170,9 +173,9 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::comput
   return (error);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f& guess)
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f& guess)
 {
   // Some sanity checks first
   if (!input_features_)
@@ -216,7 +219,7 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::comput
   final_transformation_ = guess;
   int i_iter = 0;
   converged_ = false;
-  if (!guess.isApprox (Eigen::Matrix4f::Identity (), 0.01f)) 
+  if (!guess.isApprox (Eigen::Matrix4f::Identity (), 0.01f))
   {
     // If guess is not the Identity matrix we check it.
     transformPointCloud (*input_, input_transformed, final_transformation_);
@@ -252,5 +255,7 @@ pcl::SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT>::comput
   transformPointCloud (*input_, output, final_transformation_);
 }
 
+} // namespace pcl
+
 #endif  //#ifndef IA_RANSAC_HPP_
 
index fb7f62f5d2e625cd179437de7286140cd4029b11..f533abbdb2e7592dc94d4c84b51ab0cbbf86f652 100644 (file)
 #include <pcl/registration/boost.h>
 #include <pcl/correspondence.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::transformCloud (
-    const PointCloudSource &input, 
-    PointCloudSource &output, 
+IterativeClosestPoint<PointSource, PointTarget, Scalar>::transformCloud (
+    const PointCloudSource &input,
+    PointCloudSource &output,
     const Matrix4 &transform)
 {
   Eigen::Vector4f pt (0.0f, 0.0f, 0.0f, 1.0f), pt_t;
@@ -111,12 +114,11 @@ pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::transformCloud (
       memcpy (data_out + z_idx_offset_, &pt_t[2], sizeof (float));
     }
   }
-  
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformation (
+IterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformation (
     PointCloudSource &output, const Matrix4 &guess)
 {
   // Point cloud containing the correspondences of each point in <input, indices>
@@ -137,7 +139,7 @@ pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformat
   }
   else
     *input_transformed = *input_;
+
   transformation_ = Matrix4::Identity ();
 
   // Make blobs if necessary
@@ -224,7 +226,7 @@ pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformat
     // Transform the data
     transformCloud (*input_transformed, *input_transformed, transformation_);
 
-    // Obtain the final transformation    
+    // Obtain the final transformation
     final_transformation_ = transformation_ * final_transformation_;
 
     ++nr_iterations_;
@@ -250,8 +252,9 @@ pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformat
   transformCloud (*input_, output, final_transformation_);
 }
 
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::determineRequiredBlobData ()
+IterativeClosestPoint<PointSource, PointTarget, Scalar>::determineRequiredBlobData ()
 {
   need_source_blob_ = false;
   need_target_blob_ = false;
@@ -286,15 +289,17 @@ pcl::IterativeClosestPoint<PointSource, PointTarget, Scalar>::determineRequiredB
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::IterativeClosestPointWithNormals<PointSource, PointTarget, Scalar>::transformCloud (
-    const PointCloudSource &input, 
-    PointCloudSource &output, 
+IterativeClosestPointWithNormals<PointSource, PointTarget, Scalar>::transformCloud (
+    const PointCloudSource &input,
+    PointCloudSource &output,
     const Matrix4 &transform)
 {
   pcl::transformPointCloudWithNormals (input, output, transform);
 }
 
+} // namespace pcl
 
 #endif /* PCL_REGISTRATION_IMPL_ICP_HPP_ */
+
index 47b18431e9ed154d70deec48959b03af0c7b0046..d7bc41168c63230251f1495e2f7e58edf6ce10d7 100644 (file)
 #ifndef PCL_REGISTRATION_IMPL_INCREMENTAL_REGISTRATION_HPP_
 #define PCL_REGISTRATION_IMPL_INCREMENTAL_REGISTRATION_HPP_
 
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointT, typename Scalar>
-pcl::registration::IncrementalRegistration<PointT, Scalar>::IncrementalRegistration () :
+IncrementalRegistration<PointT, Scalar>::IncrementalRegistration () :
   delta_transform_ (Matrix4::Identity ()),
   abs_transform_ (Matrix4::Identity ())
 {}
 
 template <typename PointT, typename Scalar> bool
-pcl::registration::IncrementalRegistration<PointT, Scalar>::registerCloud (const PointCloudConstPtr& cloud, const Matrix4& delta_estimate)
+IncrementalRegistration<PointT, Scalar>::registerCloud (const PointCloudConstPtr& cloud, const Matrix4& delta_estimate)
 {
   assert (registration_);
 
@@ -76,28 +83,32 @@ pcl::registration::IncrementalRegistration<PointT, Scalar>::registerCloud (const
 }
 
 template <typename PointT, typename Scalar> inline typename pcl::registration::IncrementalRegistration<PointT, Scalar>::Matrix4
-pcl::registration::IncrementalRegistration<PointT, Scalar>::getDeltaTransform () const
+IncrementalRegistration<PointT, Scalar>::getDeltaTransform () const
 {
   return (delta_transform_);
 }
 
 template <typename PointT, typename Scalar> inline typename pcl::registration::IncrementalRegistration<PointT, Scalar>::Matrix4
-pcl::registration::IncrementalRegistration<PointT, Scalar>::getAbsoluteTransform () const
+IncrementalRegistration<PointT, Scalar>::getAbsoluteTransform () const
 {
   return (abs_transform_);
 }
 
 template <typename PointT, typename Scalar> inline void
-pcl::registration::IncrementalRegistration<PointT, Scalar>::reset ()
+IncrementalRegistration<PointT, Scalar>::reset ()
 {
   last_cloud_.reset ();
   delta_transform_ = abs_transform_ = Matrix4::Identity ();
 }
 
 template <typename PointT, typename Scalar> inline void
-pcl::registration::IncrementalRegistration<PointT, Scalar>::setRegistration (RegistrationPtr registration)
+IncrementalRegistration<PointT, Scalar>::setRegistration (RegistrationPtr registration)
 {
   registration_ = registration;
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif /*PCL_REGISTRATION_IMPL_INCREMENTAL_REGISTRATION_HPP_*/
+
index f8b16e73d2d3f5518013762a68091b52f7d7b38a..bde6c3178ec5b5f5a1c0af877546df15d4e2840c 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * Software License Agreement (BSD License)
- * 
+ *
  * Point Cloud Library (PCL) - www.pointclouds.org
  * Copyright (c) 2009-2012, Willow Garage, Inc.
  * Copyright (c) 2012-, Open Perception, Inc.
- * 
+ *
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  *  * Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above
@@ -20,7 +20,7 @@
  *  * Neither the name of the copyright holder(s) nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 #include <pcl/console/print.h>
 
 
-///////////////////////////////////////////////////////////////////////////////////////////
+namespace pcl
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformation (
+JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransformation (
     PointCloudSource &output, const Matrix4 &guess)
 {
   // Point clouds containing the correspondences of each point in <input, indices>
@@ -63,7 +65,7 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
     correspondence_estimations_.resize (sources_.size ());
     for (std::size_t i = 0; i < sources_.size (); i++)
     {
-      correspondence_estimations_[i] = correspondence_estimation_->clone ();      
+      correspondence_estimations_[i] = correspondence_estimation_->clone ();
       KdTreeReciprocalPtr src_tree (new KdTreeReciprocal);
       KdTreePtr tgt_tree (new KdTree);
       correspondence_estimations_[i]->setSearchMethodTarget (tgt_tree);
@@ -117,8 +119,6 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
     target_offset += targets_[i]->size ();
   }
 
-
   transformation_ = Matrix4::Identity ();
   // Make blobs if necessary
   determineRequiredBlobData ();
@@ -176,7 +176,7 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
         toPCLPointCloud2 (*inputs_transformed[i], *input_transformed_blob);
         correspondence_estimations_[i]->setSourceNormals (input_transformed_blob);
       }
-      
+
       // Estimate correspondences on each cloud pair separately
       if (use_reciprocal_correspondence_)
       {
@@ -186,8 +186,8 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
       {
         correspondence_estimations_[i]->determineCorrespondences (*partial_correspondences_[i], corr_dist_threshold_);
       }
-      PCL_DEBUG ("[pcl::%s::computeTransformation] Found %d partial correspondences for cloud [%d]\n", 
-          getClassName ().c_str (), 
+      PCL_DEBUG ("[pcl::%s::computeTransformation] Found %d partial correspondences for cloud [%d]\n",
+          getClassName ().c_str (),
           partial_correspondences_[i]->size (), i);
       for (std::size_t j = 0; j < partial_correspondences_[i]->size (); j++)
       {
@@ -199,7 +199,7 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
       }
     }
     PCL_DEBUG ("[pcl::%s::computeTransformation] Total correspondences: %d\n", getClassName ().c_str (), correspondences_->size ());
-    
+
     PCLPointCloud2::Ptr inputs_transformed_combined_blob;
     if (need_source_blob_)
     {
@@ -244,7 +244,7 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
       this->transformCloud (*inputs_transformed[i], *inputs_transformed[i], transformation_);
     }
 
-    // Obtain the final transformation    
+    // Obtain the final transformation
     final_transformation_ = transformation_ * final_transformation_;
 
     ++nr_iterations_;
@@ -257,7 +257,7 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
   }
   while (!converged_);
 
-  PCL_DEBUG ("Transformation is:\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n", 
+  PCL_DEBUG ("Transformation is:\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n",
       final_transformation_ (0, 0), final_transformation_ (0, 1), final_transformation_ (0, 2), final_transformation_ (0, 3),
       final_transformation_ (1, 0), final_transformation_ (1, 1), final_transformation_ (1, 2), final_transformation_ (1, 3),
       final_transformation_ (2, 0), final_transformation_ (2, 1), final_transformation_ (2, 2), final_transformation_ (2, 3),
@@ -274,13 +274,14 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeTransf
   }
 
 
-  // By definition, this method will return an empty cloud (for compliance with the ICP API). 
+  // By definition, this method will return an empty cloud (for compliance with the ICP API).
   // We can figure out a better solution, if necessary.
   output = PointCloudSource ();
 }
 
-  template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::determineRequiredBlobData ()
+
+template <typename PointSource, typename PointTarget, typename Scalar> void
+JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::determineRequiredBlobData ()
 {
   need_source_blob_ = false;
   need_target_blob_ = false;
@@ -320,7 +321,7 @@ pcl::JointIterativeClosestPoint<PointSource, PointTarget, Scalar>::determineRequ
   }
 }
 
+} // namespace pcl
 
 #endif /* PCL_REGISTRATION_IMPL_JOINT_ICP_HPP_ */
 
-
index 9a54279a219251a96b8243fda912655729d1d747..51747480cbd8e42c4188277ba269d31d7e6730e6 100644 (file)
 
 #include <tuple>
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template<typename PointT> inline void
-pcl::registration::LUM<PointT>::setLoopGraph (const SLAMGraphPtr &slam_graph)
+LUM<PointT>::setLoopGraph (const SLAMGraphPtr &slam_graph)
 {
   slam_graph_ = slam_graph;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> inline typename pcl::registration::LUM<PointT>::SLAMGraphPtr
-pcl::registration::LUM<PointT>::getLoopGraph () const
+
+template<typename PointT> inline typename LUM<PointT>::SLAMGraphPtr
+LUM<PointT>::getLoopGraph () const
 {
   return (slam_graph_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> typename pcl::registration::LUM<PointT>::SLAMGraph::vertices_size_type
-pcl::registration::LUM<PointT>::getNumVertices () const
+
+template<typename PointT> typename LUM<PointT>::SLAMGraph::vertices_size_type
+LUM<PointT>::getNumVertices () const
 {
   return (num_vertices (*slam_graph_));
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> void
-pcl::registration::LUM<PointT>::setMaxIterations (int max_iterations)
+LUM<PointT>::setMaxIterations (int max_iterations)
 {
   max_iterations_ = max_iterations;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline int
-pcl::registration::LUM<PointT>::getMaxIterations () const
+LUM<PointT>::getMaxIterations () const
 {
   return (max_iterations_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> void
-pcl::registration::LUM<PointT>::setConvergenceThreshold (float convergence_threshold)
+LUM<PointT>::setConvergenceThreshold (float convergence_threshold)
 {
   convergence_threshold_ = convergence_threshold;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline float
-pcl::registration::LUM<PointT>::getConvergenceThreshold () const
+LUM<PointT>::getConvergenceThreshold () const
 {
   return (convergence_threshold_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> typename pcl::registration::LUM<PointT>::Vertex
-pcl::registration::LUM<PointT>::addPointCloud (const PointCloudPtr &cloud, const Eigen::Vector6f &pose)
+
+template<typename PointT> typename LUM<PointT>::Vertex
+LUM<PointT>::addPointCloud (const PointCloudPtr &cloud, const Eigen::Vector6f &pose)
 {
   Vertex v = add_vertex (*slam_graph_);
   (*slam_graph_)[v].cloud_ = cloud;
@@ -108,9 +114,9 @@ pcl::registration::LUM<PointT>::addPointCloud (const PointCloudPtr &cloud, const
   return (v);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline void
-pcl::registration::LUM<PointT>::setPointCloud (const Vertex &vertex, const PointCloudPtr &cloud)
+LUM<PointT>::setPointCloud (const Vertex &vertex, const PointCloudPtr &cloud)
 {
   if (vertex >= getNumVertices ())
   {
@@ -120,9 +126,9 @@ pcl::registration::LUM<PointT>::setPointCloud (const Vertex &vertex, const Point
   (*slam_graph_)[vertex].cloud_ = cloud;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> inline typename pcl::registration::LUM<PointT>::PointCloudPtr
-pcl::registration::LUM<PointT>::getPointCloud (const Vertex &vertex) const
+
+template<typename PointT> inline typename LUM<PointT>::PointCloudPtr
+LUM<PointT>::getPointCloud (const Vertex &vertex) const
 {
   if (vertex >= getNumVertices ())
   {
@@ -132,9 +138,9 @@ pcl::registration::LUM<PointT>::getPointCloud (const Vertex &vertex) const
   return ((*slam_graph_)[vertex].cloud_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline void
-pcl::registration::LUM<PointT>::setPose (const Vertex &vertex, const Eigen::Vector6f &pose)
+LUM<PointT>::setPose (const Vertex &vertex, const Eigen::Vector6f &pose)
 {
   if (vertex >= getNumVertices ())
   {
@@ -149,9 +155,9 @@ pcl::registration::LUM<PointT>::setPose (const Vertex &vertex, const Eigen::Vect
   (*slam_graph_)[vertex].pose_ = pose;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline Eigen::Vector6f
-pcl::registration::LUM<PointT>::getPose (const Vertex &vertex) const
+LUM<PointT>::getPose (const Vertex &vertex) const
 {
   if (vertex >= getNumVertices ())
   {
@@ -161,17 +167,17 @@ pcl::registration::LUM<PointT>::getPose (const Vertex &vertex) const
   return ((*slam_graph_)[vertex].pose_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline Eigen::Affine3f
-pcl::registration::LUM<PointT>::getTransformation (const Vertex &vertex) const
+LUM<PointT>::getTransformation (const Vertex &vertex) const
 {
   Eigen::Vector6f pose = getPose (vertex);
   return (pcl::getTransformation (pose (0), pose (1), pose (2), pose (3), pose (4), pose (5)));
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> void
-pcl::registration::LUM<PointT>::setCorrespondences (const Vertex &source_vertex, const Vertex &target_vertex, const pcl::CorrespondencesPtr &corrs)
+LUM<PointT>::setCorrespondences (const Vertex &source_vertex, const Vertex &target_vertex, const pcl::CorrespondencesPtr &corrs)
 {
   if (source_vertex >= getNumVertices () || target_vertex >= getNumVertices () || source_vertex == target_vertex)
   {
@@ -186,9 +192,9 @@ pcl::registration::LUM<PointT>::setCorrespondences (const Vertex &source_vertex,
   (*slam_graph_)[e].corrs_ = corrs;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline pcl::CorrespondencesPtr
-pcl::registration::LUM<PointT>::getCorrespondences (const Vertex &source_vertex, const Vertex &target_vertex) const
+LUM<PointT>::getCorrespondences (const Vertex &source_vertex, const Vertex &target_vertex) const
 {
   if (source_vertex >= getNumVertices () || target_vertex >= getNumVertices ())
   {
@@ -206,9 +212,9 @@ pcl::registration::LUM<PointT>::getCorrespondences (const Vertex &source_vertex,
   return ((*slam_graph_)[e].corrs_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> void
-pcl::registration::LUM<PointT>::compute ()
+LUM<PointT>::compute ()
 {
   int n = static_cast<int> (getNumVertices ());
   if (n < 2)
@@ -271,18 +277,18 @@ pcl::registration::LUM<PointT>::compute ()
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> typename pcl::registration::LUM<PointT>::PointCloudPtr
-pcl::registration::LUM<PointT>::getTransformedCloud (const Vertex &vertex) const
+
+template<typename PointT> typename LUM<PointT>::PointCloudPtr
+LUM<PointT>::getTransformedCloud (const Vertex &vertex) const
 {
   PointCloudPtr out (new PointCloud);
   pcl::transformPointCloud (*getPointCloud (vertex), *out, getTransformation (vertex));
   return (out);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template<typename PointT> typename pcl::registration::LUM<PointT>::PointCloudPtr
-pcl::registration::LUM<PointT>::getConcatenatedCloud () const
+
+template<typename PointT> typename LUM<PointT>::PointCloudPtr
+LUM<PointT>::getConcatenatedCloud () const
 {
   PointCloudPtr out (new PointCloud);
   typename SLAMGraph::vertex_iterator v, v_end;
@@ -295,9 +301,9 @@ pcl::registration::LUM<PointT>::getConcatenatedCloud () const
   return (out);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> void
-pcl::registration::LUM<PointT>::computeEdge (const Edge &e)
+LUM<PointT>::computeEdge (const Edge &e)
 {
   // Get necessary local data from graph
   PointCloudPtr source_cloud = (*slam_graph_)[source (e, *slam_graph_)].cloud_;
@@ -399,9 +405,9 @@ pcl::registration::LUM<PointT>::computeEdge (const Edge &e)
   (*slam_graph_)[e].cinvd_ = MZ * (1.0f / ss);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointT> inline Eigen::Matrix6f
-pcl::registration::LUM<PointT>::incidenceCorrection (const Eigen::Vector6f &pose)
+LUM<PointT>::incidenceCorrection (const Eigen::Vector6f &pose)
 {
   Eigen::Matrix6f out = Eigen::Matrix6f::Identity ();
   float cx = std::cos (pose (3)), sx = sinf (pose (3)), cy = std::cos (pose (4)), sy = sinf (pose (4));
@@ -421,6 +427,9 @@ pcl::registration::LUM<PointT>::incidenceCorrection (const Eigen::Vector6f &pose
   return (out);
 }
 
+} // namespace registration
+} // namespace pcl
+
 #define PCL_INSTANTIATE_LUM(T) template class PCL_EXPORTS pcl::registration::LUM<T>;
 
 #endif  // PCL_REGISTRATION_IMPL_LUM_HPP_
index b1a9d16168cfd5dad3b9e6fff6b0c32ae3ca90ab..9a3479f7c93ce08970d653d32d95c99fbe346b17 100644 (file)
 #ifndef PCL_REGISTRATION_IMPL_META_REGISTRATION_HPP_
 #define PCL_REGISTRATION_IMPL_META_REGISTRATION_HPP_
 
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointT, typename Scalar>
-pcl::registration::MetaRegistration<PointT, Scalar>::MetaRegistration () :
+MetaRegistration<PointT, Scalar>::MetaRegistration () :
   abs_transform_ (Matrix4::Identity ())
 {}
 
 template <typename PointT, typename Scalar> bool
-pcl::registration::MetaRegistration<PointT, Scalar>::registerCloud (const PointCloudConstPtr& new_cloud, const Matrix4& delta_estimate)
+MetaRegistration<PointT, Scalar>::registerCloud (const PointCloudConstPtr& new_cloud, const Matrix4& delta_estimate)
 {
   assert (registration_);
 
@@ -74,28 +81,33 @@ pcl::registration::MetaRegistration<PointT, Scalar>::registerCloud (const PointC
   return (converged);
 }
 
-template <typename PointT, typename Scalar> inline typename pcl::registration::MetaRegistration<PointT, Scalar>::Matrix4
-pcl::registration::MetaRegistration<PointT, Scalar>::getAbsoluteTransform () const
+template <typename PointT, typename Scalar> inline typename MetaRegistration<PointT, Scalar>::Matrix4
+MetaRegistration<PointT, Scalar>::getAbsoluteTransform () const
 {
   return (abs_transform_);
 }
 
 template <typename PointT, typename Scalar> inline void
-pcl::registration::MetaRegistration<PointT, Scalar>::reset ()
+MetaRegistration<PointT, Scalar>::reset ()
 {
   full_cloud_.reset ();
   abs_transform_ = Matrix4::Identity ();
 }
 
 template <typename PointT, typename Scalar> inline void
-pcl::registration::MetaRegistration<PointT, Scalar>::setRegistration (RegistrationPtr reg)
+MetaRegistration<PointT, Scalar>::setRegistration (RegistrationPtr reg)
 {
   registration_ = reg;
 }
 
-template <typename PointT, typename Scalar> inline typename pcl::registration::MetaRegistration<PointT, Scalar>::PointCloudConstPtr
-pcl::registration::MetaRegistration<PointT, Scalar>::getMetaCloud () const
+template <typename PointT, typename Scalar> inline typename MetaRegistration<PointT, Scalar>::PointCloudConstPtr
+MetaRegistration<PointT, Scalar>::getMetaCloud () const
 {
   return full_cloud_;
 }
+
+} // namespace registration
+} // namespace pcl
+
 #endif /*PCL_REGISTRATION_IMPL_META_REGISTRATION_HPP_*/
+
index d5bfd77405b130ebe9528d3b68ba3f260660325c..da11a35ab02d324b4fcc043a02a512cff71b5bf3 100644 (file)
 #ifndef PCL_REGISTRATION_NDT_IMPL_H_
 #define PCL_REGISTRATION_NDT_IMPL_H_
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template<typename PointSource, typename PointTarget>
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::NormalDistributionsTransform () 
+NormalDistributionsTransform<PointSource, PointTarget>::NormalDistributionsTransform ()
   : target_cells_ ()
   , resolution_ (1.0f)
   , step_size_ (0.1)
@@ -67,9 +70,9 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::NormalDistributions
   max_iterations_ = 35;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f &guess)
+NormalDistributionsTransform<PointSource, PointTarget>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f &guess)
 {
   nr_iterations_ = 0;
   converged_ = false;
@@ -171,13 +174,13 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeTransformati
   trans_probability_ = score / static_cast<double> (input_->points.size ());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> double
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeDerivatives (Eigen::Matrix<double, 6, 1> &score_gradient,
-                                                                                 Eigen::Matrix<double, 6, 6> &hessian,
-                                                                                 PointCloudSource &trans_cloud,
-                                                                                 Eigen::Matrix<double, 6, 1> &p,
-                                                                                 bool compute_hessian)
+NormalDistributionsTransform<PointSource, PointTarget>::computeDerivatives (Eigen::Matrix<double, 6, 1> &score_gradient,
+                                                                            Eigen::Matrix<double, 6, 6> &hessian,
+                                                                            PointCloudSource &trans_cloud,
+                                                                            Eigen::Matrix<double, 6, 1> &p,
+                                                                            bool compute_hessian)
 {
   // Original Point and Transformed Point
   PointSource x_pt, x_trans_pt;
@@ -228,9 +231,9 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeDerivatives
   return (score);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeAngleDerivatives (Eigen::Matrix<double, 6, 1> &p, bool compute_hessian)
+NormalDistributionsTransform<PointSource, PointTarget>::computeAngleDerivatives (Eigen::Matrix<double, 6, 1> &p, bool compute_hessian)
 {
   // Simplified math for near 0 angles
   double cx, cy, cz, sx, sy, sz;
@@ -305,9 +308,9 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeAngleDerivat
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::computePointDerivatives (Eigen::Vector3d &x, bool compute_hessian)
+NormalDistributionsTransform<PointSource, PointTarget>::computePointDerivatives (Eigen::Vector3d &x, bool compute_hessian)
 {
   // Calculate first derivative of Transformation Equation 6.17 w.r.t. transform vector p.
   // Derivative w.r.t. ith element of transform vector corresponds to column i, Equation 6.18 and 6.19 [Magnusson 2009]
@@ -346,12 +349,12 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::computePointDerivat
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> double
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::updateDerivatives (Eigen::Matrix<double, 6, 1> &score_gradient,
-                                                                                Eigen::Matrix<double, 6, 6> &hessian,
-                                                                                Eigen::Vector3d &x_trans, Eigen::Matrix3d &c_inv,
-                                                                                bool compute_hessian)
+NormalDistributionsTransform<PointSource, PointTarget>::updateDerivatives (Eigen::Matrix<double, 6, 1> &score_gradient,
+                                                                           Eigen::Matrix<double, 6, 6> &hessian,
+                                                                           Eigen::Vector3d &x_trans, Eigen::Matrix3d &c_inv,
+                                                                           bool compute_hessian)
 {
   Eigen::Vector3d cov_dxd_pi;
   // e^(-d_2/2 * (x_k - mu_k)^T Sigma_k^-1 (x_k - mu_k)) Equation 6.9 [Magnusson 2009]
@@ -392,10 +395,10 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::updateDerivatives (
   return (score_inc);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeHessian (Eigen::Matrix<double, 6, 6> &hessian,
-                                                                             PointCloudSource &trans_cloud, Eigen::Matrix<double, 6, 1> &)
+NormalDistributionsTransform<PointSource, PointTarget>::computeHessian (Eigen::Matrix<double, 6, 6> &hessian,
+                                                                        PointCloudSource &trans_cloud, Eigen::Matrix<double, 6, 1> &)
 {
   // Original Point and Transformed Point
   PointSource x_pt, x_trans_pt;
@@ -444,9 +447,9 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeHessian (Eig
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::updateHessian (Eigen::Matrix<double, 6, 6> &hessian, Eigen::Vector3d &x_trans, Eigen::Matrix3d &c_inv)
+NormalDistributionsTransform<PointSource, PointTarget>::updateHessian (Eigen::Matrix<double, 6, 6> &hessian, Eigen::Vector3d &x_trans, Eigen::Matrix3d &c_inv)
 {
   Eigen::Vector3d cov_dxd_pi;
   // e^(-d_2/2 * (x_k - mu_k)^T Sigma_k^-1 (x_k - mu_k)) Equation 6.9 [Magnusson 2009]
@@ -475,11 +478,11 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::updateHessian (Eige
 
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> bool
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::updateIntervalMT (double &a_l, double &f_l, double &g_l,
-                                                                               double &a_u, double &f_u, double &g_u,
-                                                                               double a_t, double f_t, double g_t)
+NormalDistributionsTransform<PointSource, PointTarget>::updateIntervalMT (double &a_l, double &f_l, double &g_l,
+                                                                          double &a_u, double &f_u, double &g_u,
+                                                                          double a_t, double f_t, double g_t)
 {
   // Case U1 in Update Algorithm and Case a in Modified Update Algorithm [More, Thuente 1994]
   if (f_t > f_l)
@@ -513,11 +516,11 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::updateIntervalMT (d
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> double
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::trialValueSelectionMT (double a_l, double f_l, double g_l,
-                                                                                    double a_u, double f_u, double g_u,
-                                                                                    double a_t, double f_t, double g_t)
+NormalDistributionsTransform<PointSource, PointTarget>::trialValueSelectionMT (double a_l, double f_l, double g_l,
+                                                                               double a_u, double f_u, double g_u,
+                                                                               double a_t, double f_t, double g_t)
 {
   // Case 1 in Trial Value Selection [More, Thuente 1994]
   if (f_t > f_l)
@@ -588,11 +591,11 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::trialValueSelection
   return (a_u + (a_t - a_u) * (w - g_u - z) / (g_t - g_u + 2 * w));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> double
-pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeStepLengthMT (const Eigen::Matrix<double, 6, 1> &x, Eigen::Matrix<double, 6, 1> &step_dir, double step_init, double step_max,
-                                                                                  double step_min, double &score, Eigen::Matrix<double, 6, 1> &score_gradient, Eigen::Matrix<double, 6, 6> &hessian,
-                                                                                  PointCloudSource &trans_cloud)
+NormalDistributionsTransform<PointSource, PointTarget>::computeStepLengthMT (const Eigen::Matrix<double, 6, 1> &x, Eigen::Matrix<double, 6, 1> &step_dir, double step_init, double step_max,
+                                                                             double step_min, double &score, Eigen::Matrix<double, 6, 1> &score_gradient, Eigen::Matrix<double, 6, 6> &hessian,
+                                                                             PointCloudSource &trans_cloud)
 {
   // Set the value of phi(0), Equation 1.3 [More, Thuente 1994]
   double phi_0 = -score;
@@ -748,4 +751,7 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::computeStepLengthMT
   return (a_t);
 }
 
+} // namespace pcl
+
 #endif // PCL_REGISTRATION_NDT_IMPL_H_
+
index c34bdf35c40b0407eddf493a50af926338aaf0a7..d725e1e87f321bdf9b3f28c819f4bd5a0bdbdd43 100644 (file)
@@ -1,42 +1,43 @@
 /*
- * Software License Agreement (BSD License)
- *
- *  Point Cloud Library (PCL) - www.pointclouds.org
- *  Copyright (c) 2011-2012, Willow Garage, Inc.
- *  Copyright (c) 2012-, Open Perception, Inc.
- *
- *  All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions
- *  are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the following
- *     disclaimer in the documentation and/or other materials provided
- *     with the distribution.
- *   * Neither the name of the copyright holder(s) nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *  POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id$
- *
- */
+* Software License Agreement (BSD License)
+*
+*  Point Cloud Library (PCL) - www.pointclouds.org
+*  Copyright (c) 2011-2012, Willow Garage, Inc.
+*  Copyright (c) 2012-, Open Perception, Inc.
+*
+*  All rights reserved.
+*
+*  Redistribution and use in source and binary forms, with or without
+*  modification, are permitted provided that the following conditions
+*  are met:
+*
+*   * Redistributions of source code must retain the above copyright
+*     notice, this list of conditions and the following disclaimer.
+*   * Redistributions in binary form must reproduce the above
+*     copyright notice, this list of conditions and the following
+*     disclaimer in the documentation and/or other materials provided
+*     with the distribution.
+*   * Neither the name of the copyright holder(s) nor the names of its
+*     contributors may be used to endorse or promote products derived
+*     from this software without specific prior written permission.
+*
+*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+*  POSSIBILITY OF SUCH DAMAGE.
+*
+* $Id$
+*
+*/
+
 #ifndef PCL_NDT_2D_IMPL_H_
 #define PCL_NDT_2D_IMPL_H_
 
 
 namespace pcl
 {
-  namespace ndt2d
+
+namespace ndt2d
+{
+/** \brief Class to store vector value and first and second derivatives
+  * (grad vector and hessian matrix), so they can be returned easily from
+  * functions
+  */
+template<unsigned N=3, typename T=double>
+struct ValueAndDerivatives
+{
+  ValueAndDerivatives () : hessian (), grad (), value () {}
+
+  Eigen::Matrix<T, N, N> hessian;
+  Eigen::Matrix<T, N, 1>    grad;
+  T value;
+
+  static ValueAndDerivatives<N,T>
+  Zero ()
+  {
+    ValueAndDerivatives<N,T> r;
+    r.hessian = Eigen::Matrix<T, N, N>::Zero ();
+    r.grad    = Eigen::Matrix<T, N, 1>::Zero ();
+    r.value   = 0;
+    return r;
+  }
+
+  ValueAndDerivatives<N,T>&
+  operator+= (ValueAndDerivatives<N,T> const& r)
+  {
+    hessian += r.hessian;
+    grad    += r.grad;
+    value   += r.value;
+    return *this;
+  }
+};
+
+/** \brief A normal distribution estimation class.
+  *
+  * First the indices of of the points from a point cloud that should be
+  * modelled by the distribution are added with addIdx (...).
+  *
+  * Then estimateParams (...) uses the stored point indices to estimate the
+  * parameters of a normal distribution, and discards the stored indices.
+  *
+  * Finally the distriubution, and its derivatives, may be evaluated at any
+  * point using test (...).
+  */
+template <typename PointT>
+class NormalDist
+{
+  using PointCloud = pcl::PointCloud<PointT>;
+
+public:
+  NormalDist ()
+    : min_n_ (3), n_ (0)
+  {
+  }
+
+  /** \brief Store a point index to use later for estimating distribution parameters.
+    * \param[in] i Point index to store
+    */
+  void
+  addIdx (std::size_t i)
   {
-    /** \brief Class to store vector value and first and second derivatives
-      * (grad vector and hessian matrix), so they can be returned easily from
-      * functions
-      */
-    template<unsigned N=3, typename T=double>
-    struct ValueAndDerivatives
+    pt_indices_.push_back (i);
+  }
+
+  /** \brief Estimate the normal distribution parameters given the point indices provided. Memory of point indices is cleared.
+    * \param[in] cloud                    Point cloud corresponding to indices passed to addIdx.
+    * \param[in] min_covar_eigvalue_mult  Set the smallest eigenvalue to this times the largest.
+    */
+  void
+  estimateParams (const PointCloud& cloud, double min_covar_eigvalue_mult = 0.001)
+  {
+    Eigen::Vector2d sx  = Eigen::Vector2d::Zero ();
+    Eigen::Matrix2d sxx = Eigen::Matrix2d::Zero ();
+
+    for (auto i = pt_indices_.cbegin (); i != pt_indices_.cend (); i++)
     {
-      ValueAndDerivatives () : hessian (), grad (), value () {}
-
-      Eigen::Matrix<T, N, N> hessian;
-      Eigen::Matrix<T, N, 1>    grad;
-      T value;
-      
-      static ValueAndDerivatives<N,T>
-      Zero ()
-      {
-        ValueAndDerivatives<N,T> r;
-        r.hessian = Eigen::Matrix<T, N, N>::Zero ();
-        r.grad    = Eigen::Matrix<T, N, 1>::Zero ();
-        r.value   = 0;
-        return r;
-      }
+      Eigen::Vector2d p (cloud[*i]. x, cloud[*i]. y);
+      sx  += p;
+      sxx += p * p.transpose ();
+    }
+
+    n_ = pt_indices_.size ();
+
+    if (n_ >= min_n_)
+    {
+      mean_ = sx / static_cast<double> (n_);
+      // Using maximum likelihood estimation as in the original paper
+      Eigen::Matrix2d covar = (sxx - 2 * (sx * mean_.transpose ())) / static_cast<double> (n_) + mean_ * mean_.transpose ();
 
-      ValueAndDerivatives<N,T>&
-      operator+= (ValueAndDerivatives<N,T> const& r)
+      Eigen::SelfAdjointEigenSolver<Eigen::Matrix2d> solver (covar);
+      if (solver.eigenvalues ()[0] < min_covar_eigvalue_mult * solver.eigenvalues ()[1])
       {
-        hessian += r.hessian;
-        grad    += r.grad;
-        value   += r.value;
-        return *this;
+        PCL_DEBUG ("[pcl::NormalDist::estimateParams] NDT normal fit: adjusting eigenvalue %f\n", solver.eigenvalues ()[0]);
+        Eigen::Matrix2d l = solver.eigenvalues ().asDiagonal ();
+        Eigen::Matrix2d q = solver.eigenvectors ();
+        // set minimum smallest eigenvalue:
+        l (0,0) = l (1,1) * min_covar_eigvalue_mult;
+        covar = q * l * q.transpose ();
       }
-    };
-
-    /** \brief A normal distribution estimation class.
-      *
-      * First the indices of of the points from a point cloud that should be
-      * modelled by the distribution are added with addIdx (...).
-      *
-      * Then estimateParams (...) uses the stored point indices to estimate the
-      * parameters of a normal distribution, and discards the stored indices.
-      *
-      * Finally the distriubution, and its derivatives, may be evaluated at any
-      * point using test (...).
-      */
-    template <typename PointT>
-    class NormalDist
-    {
-      using PointCloud = pcl::PointCloud<PointT>;
-
-      public:
-        NormalDist ()
-          : min_n_ (3), n_ (0)
-        {
-        }
-        
-        /** \brief Store a point index to use later for estimating distribution parameters.
-          * \param[in] i Point index to store
-          */
-        void
-        addIdx (std::size_t i)
-        {
-          pt_indices_.push_back (i);
-        }
-        
-        /** \brief Estimate the normal distribution parameters given the point indices provided. Memory of point indices is cleared.
-          * \param[in] cloud                    Point cloud corresponding to indices passed to addIdx.
-          * \param[in] min_covar_eigvalue_mult  Set the smallest eigenvalue to this times the largest.
-          */
-        void
-        estimateParams (const PointCloud& cloud, double min_covar_eigvalue_mult = 0.001)
-        {
-          Eigen::Vector2d sx  = Eigen::Vector2d::Zero ();
-          Eigen::Matrix2d sxx = Eigen::Matrix2d::Zero ();
-          
-          for (auto i = pt_indices_.cbegin (); i != pt_indices_.cend (); i++)
-          {
-            Eigen::Vector2d p (cloud[*i]. x, cloud[*i]. y);
-            sx  += p;
-            sxx += p * p.transpose ();
-          }
-          
-          n_ = pt_indices_.size ();
-
-          if (n_ >= min_n_)
-          {
-            mean_ = sx / static_cast<double> (n_);
-            // Using maximum likelihood estimation as in the original paper
-            Eigen::Matrix2d covar = (sxx - 2 * (sx * mean_.transpose ())) / static_cast<double> (n_) + mean_ * mean_.transpose ();
-
-            Eigen::SelfAdjointEigenSolver<Eigen::Matrix2d> solver (covar);
-            if (solver.eigenvalues ()[0] < min_covar_eigvalue_mult * solver.eigenvalues ()[1])
-            {
-              PCL_DEBUG ("[pcl::NormalDist::estimateParams] NDT normal fit: adjusting eigenvalue %f\n", solver.eigenvalues ()[0]);
-              Eigen::Matrix2d l = solver.eigenvalues ().asDiagonal ();
-              Eigen::Matrix2d q = solver.eigenvectors ();
-              // set minimum smallest eigenvalue:
-              l (0,0) = l (1,1) * min_covar_eigvalue_mult;
-              covar = q * l * q.transpose ();
-            }
-            covar_inv_ = covar.inverse ();
-          }
-
-          pt_indices_.clear ();
-        }
-
-        /** \brief Return the 'score' (denormalised likelihood) and derivatives of score of the point p given this distribution.
-          * \param[in] transformed_pt   Location to evaluate at.
-          * \param[in] cos_theta        sin(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
-          * \param[in] sin_theta        cos(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
-          * estimateParams must have been called after at least three points were provided, or this will return zero.
-          *
-          */
-        ValueAndDerivatives<3,double>
-        test (const PointT& transformed_pt, const double& cos_theta, const double& sin_theta) const
-        {
-          if (n_ < min_n_)
-            return ValueAndDerivatives<3,double>::Zero ();
-          
-          ValueAndDerivatives<3,double> r;
-          const double x = transformed_pt.x;
-          const double y = transformed_pt.y;
-          const Eigen::Vector2d p_xy (transformed_pt.x, transformed_pt.y);
-          const Eigen::Vector2d q = p_xy - mean_;
-          const Eigen::RowVector2d qt_cvi (q.transpose () * covar_inv_);
-          const double exp_qt_cvi_q = std::exp (-0.5 * double (qt_cvi * q));
-          r.value = -exp_qt_cvi_q;
-
-          Eigen::Matrix<double, 2, 3> jacobian;
-          jacobian <<
-            1, 0, -(x * sin_theta + y*cos_theta),
-            0, 1,   x * cos_theta - y*sin_theta;
-          
-          for (std::size_t i = 0; i < 3; i++)
-            r.grad[i] = double (qt_cvi * jacobian.col (i)) * exp_qt_cvi_q;
-          
-          // second derivative only for i == j == 2:
-          const Eigen::Vector2d d2q_didj (
-              y * sin_theta - x*cos_theta,
-            -(x * sin_theta + y*cos_theta)
-          );
-
-          for (std::size_t i = 0; i < 3; i++)
-            for (std::size_t j = 0; j < 3; j++)
-              r.hessian (i,j) = -exp_qt_cvi_q * (
-                double (-qt_cvi*jacobian.col (i)) * double (-qt_cvi*jacobian.col (j)) +
-                (-qt_cvi * ((i==2 && j==2)? d2q_didj : Eigen::Vector2d::Zero ())) +
-                (-jacobian.col (j).transpose () * covar_inv_ * jacobian.col (i))
-              );
-          
-          return r;
-        }
-
-    protected:
-        const std::size_t min_n_;
-
-        std::size_t n_;
-        std::vector<std::size_t> pt_indices_;
-        Eigen::Vector2d mean_;
-        Eigen::Matrix2d covar_inv_;
-    };
-    
-    /** \brief Build a set of normal distributions modelling a 2D point cloud,
-      * and provide the value and derivatives of the model at any point via the
-      * test (...) function.
-      */
-    template <typename PointT> 
-    class NDTSingleGrid: public boost::noncopyable
-    {
-      using PointCloud = pcl::PointCloud<PointT>;
-      using PointCloudConstPtr = typename PointCloud::ConstPtr;
-      using NormalDist = pcl::ndt2d::NormalDist<PointT>;
-
-      public:
-        NDTSingleGrid (PointCloudConstPtr cloud,
-                       const Eigen::Vector2f& about,
-                       const Eigen::Vector2f& extent,
-                       const Eigen::Vector2f& step)
-            : min_ (about - extent), max_ (min_ + 2*extent), step_ (step),
-              cells_ ((max_[0]-min_[0]) / step_[0],
-                      (max_[1]-min_[1]) / step_[1]),
-              normal_distributions_ (cells_[0], cells_[1])
-        {
-          // sort through all points, assigning them to distributions:
-          std::size_t used_points = 0;
-          for (std::size_t i = 0; i < cloud->size (); i++)
-          if (NormalDist* n = normalDistForPoint (cloud->at (i)))
-          {
-            n->addIdx (i);
-            used_points++;
-          }
-
-          PCL_DEBUG ("[pcl::NDTSingleGrid] NDT single grid %dx%d using %d/%d points\n", cells_[0], cells_[1], used_points, cloud->size ());
-
-          // then bake the distributions such that they approximate the
-          // points (and throw away memory of the points)
-          for (int x = 0; x < cells_[0]; x++)
-            for (int y = 0; y < cells_[1]; y++)
-              normal_distributions_.coeffRef (x,y).estimateParams (*cloud);
-        }
-        
-        /** \brief Return the 'score' (denormalised likelihood) and derivatives of score of the point p given this distribution.
-          * \param[in] transformed_pt   Location to evaluate at.
-          * \param[in] cos_theta        sin(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
-          * \param[in] sin_theta        cos(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
-          */
-        ValueAndDerivatives<3,double>
-        test (const PointT& transformed_pt, const double& cos_theta, const double& sin_theta) const
-        {
-          const NormalDist* n = normalDistForPoint (transformed_pt);
-          // index is in grid, return score from the normal distribution from
-          // the correct part of the grid:
-          if (n)
-            return n->test (transformed_pt, cos_theta, sin_theta);
-          return ValueAndDerivatives<3,double>::Zero ();
-        }
-
-      protected:
-        /** \brief Return the normal distribution covering the location of point p
-          * \param[in] p a point
-          */
-        NormalDist* 
-        normalDistForPoint (PointT const& p) const
-        {
-          // this would be neater in 3d...
-          Eigen::Vector2f idxf;
-          for (std::size_t i = 0; i < 2; i++)
-            idxf[i] = (p.getVector3fMap ()[i] - min_[i]) / step_[i];
-          Eigen::Vector2i idxi = idxf.cast<int> ();
-          for (std::size_t i = 0; i < 2; i++)
-            if (idxi[i] >= cells_[i] || idxi[i] < 0)
-              return nullptr;
-          // const cast to avoid duplicating this function in const and
-          // non-const variants...
-          return const_cast<NormalDist*> (&normal_distributions_.coeffRef (idxi[0], idxi[1]));
-        }
-
-        Eigen::Vector2f min_;
-        Eigen::Vector2f max_;
-        Eigen::Vector2f step_;
-        Eigen::Vector2i cells_;
-
-        Eigen::Matrix<NormalDist, Eigen::Dynamic, Eigen::Dynamic> normal_distributions_;
-    };
-
-    /** \brief Build a Normal Distributions Transform of a 2D point cloud. This
-      * consists of the sum of four overlapping models of the original points
-      * with normal distributions.
-      * The value and derivatives of the model at any point can be evaluated
-      * with the test (...) function.
-      */
-    template <typename PointT> 
-    class NDT2D: public boost::noncopyable
+      covar_inv_ = covar.inverse ();
+    }
+
+    pt_indices_.clear ();
+  }
+
+  /** \brief Return the 'score' (denormalised likelihood) and derivatives of score of the point p given this distribution.
+    * \param[in] transformed_pt   Location to evaluate at.
+    * \param[in] cos_theta        sin(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
+    * \param[in] sin_theta        cos(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
+    * estimateParams must have been called after at least three points were provided, or this will return zero.
+    *
+    */
+  ValueAndDerivatives<3,double>
+  test (const PointT& transformed_pt, const double& cos_theta, const double& sin_theta) const
+  {
+    if (n_ < min_n_)
+      return ValueAndDerivatives<3,double>::Zero ();
+
+    ValueAndDerivatives<3,double> r;
+    const double x = transformed_pt.x;
+    const double y = transformed_pt.y;
+    const Eigen::Vector2d p_xy (transformed_pt.x, transformed_pt.y);
+    const Eigen::Vector2d q = p_xy - mean_;
+    const Eigen::RowVector2d qt_cvi (q.transpose () * covar_inv_);
+    const double exp_qt_cvi_q = std::exp (-0.5 * double (qt_cvi * q));
+    r.value = -exp_qt_cvi_q;
+
+    Eigen::Matrix<double, 2, 3> jacobian;
+    jacobian <<
+      1, 0, -(x * sin_theta + y*cos_theta),
+      0, 1,   x * cos_theta - y*sin_theta;
+
+    for (std::size_t i = 0; i < 3; i++)
+      r.grad[i] = double (qt_cvi * jacobian.col (i)) * exp_qt_cvi_q;
+
+    // second derivative only for i == j == 2:
+    const Eigen::Vector2d d2q_didj (
+        y * sin_theta - x*cos_theta,
+      -(x * sin_theta + y*cos_theta)
+    );
+
+    for (std::size_t i = 0; i < 3; i++)
+      for (std::size_t j = 0; j < 3; j++)
+        r.hessian (i,j) = -exp_qt_cvi_q * (
+          double (-qt_cvi*jacobian.col (i)) * double (-qt_cvi*jacobian.col (j)) +
+          (-qt_cvi * ((i==2 && j==2)? d2q_didj : Eigen::Vector2d::Zero ())) +
+          (-jacobian.col (j).transpose () * covar_inv_ * jacobian.col (i))
+        );
+
+    return r;
+  }
+
+protected:
+  const std::size_t min_n_;
+
+  std::size_t n_;
+  std::vector<std::size_t> pt_indices_;
+  Eigen::Vector2d mean_;
+  Eigen::Matrix2d covar_inv_;
+};
+
+/** \brief Build a set of normal distributions modelling a 2D point cloud,
+  * and provide the value and derivatives of the model at any point via the
+  * test (...) function.
+  */
+template <typename PointT>
+class NDTSingleGrid: public boost::noncopyable
+{
+  using PointCloud = pcl::PointCloud<PointT>;
+  using PointCloudConstPtr = typename PointCloud::ConstPtr;
+  using NormalDist = pcl::ndt2d::NormalDist<PointT>;
+
+public:
+  NDTSingleGrid (PointCloudConstPtr cloud,
+                 const Eigen::Vector2f& about,
+                 const Eigen::Vector2f& extent,
+                 const Eigen::Vector2f& step)
+      : min_ (about - extent), max_ (min_ + 2*extent), step_ (step),
+        cells_ ((max_[0]-min_[0]) / step_[0],
+                (max_[1]-min_[1]) / step_[1]),
+        normal_distributions_ (cells_[0], cells_[1])
+  {
+    // sort through all points, assigning them to distributions:
+    std::size_t used_points = 0;
+    for (std::size_t i = 0; i < cloud->size (); i++)
+    if (NormalDist* n = normalDistForPoint (cloud->at (i)))
     {
-      using PointCloud = pcl::PointCloud<PointT>;
-      using PointCloudConstPtr = typename PointCloud::ConstPtr;
-      using SingleGrid = NDTSingleGrid<PointT>;
-
-      public:
-        /** \brief
-          * \param[in] cloud the input point cloud
-          * \param[in] about Centre of the grid for normal distributions model
-          * \param[in] extent Extent of grid for normal distributions model
-          * \param[in] step Size of region that each normal distribution will model
-          */
-        NDT2D (PointCloudConstPtr cloud,
-             const Eigen::Vector2f& about,
-             const Eigen::Vector2f& extent,
-             const Eigen::Vector2f& step)
-        {
-          Eigen::Vector2f dx (step[0]/2, 0);
-          Eigen::Vector2f dy (0, step[1]/2);
-          single_grids_[0].reset(new SingleGrid (cloud, about,        extent, step));
-          single_grids_[1].reset(new SingleGrid (cloud, about +dx,    extent, step));
-          single_grids_[2].reset(new SingleGrid (cloud, about +dy,    extent, step));
-          single_grids_[3].reset(new SingleGrid (cloud, about +dx+dy, extent, step));
-        }
-        
-        /** \brief Return the 'score' (denormalised likelihood) and derivatives of score of the point p given this distribution.
-          * \param[in] transformed_pt   Location to evaluate at.
-          * \param[in] cos_theta        sin(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
-          * \param[in] sin_theta        cos(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
-          */
-        ValueAndDerivatives<3,double>
-        test (const PointT& transformed_pt, const double& cos_theta, const double& sin_theta) const
-        {
-          ValueAndDerivatives<3,double> r = ValueAndDerivatives<3,double>::Zero ();
-          for (const auto &single_grid : single_grids_)
-              r += single_grid->test (transformed_pt, cos_theta, sin_theta);
-          return r;
-        }
-
-      protected:
-        std::shared_ptr<SingleGrid> single_grids_[4];
-    };
-
-  } // namespace ndt2d
+      n->addIdx (i);
+      used_points++;
+    }
+
+    PCL_DEBUG ("[pcl::NDTSingleGrid] NDT single grid %dx%d using %d/%d points\n", cells_[0], cells_[1], used_points, cloud->size ());
+
+    // then bake the distributions such that they approximate the
+    // points (and throw away memory of the points)
+    for (int x = 0; x < cells_[0]; x++)
+      for (int y = 0; y < cells_[1]; y++)
+        normal_distributions_.coeffRef (x,y).estimateParams (*cloud);
+  }
+
+  /** \brief Return the 'score' (denormalised likelihood) and derivatives of score of the point p given this distribution.
+    * \param[in] transformed_pt   Location to evaluate at.
+    * \param[in] cos_theta        sin(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
+    * \param[in] sin_theta        cos(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
+    */
+  ValueAndDerivatives<3,double>
+  test (const PointT& transformed_pt, const double& cos_theta, const double& sin_theta) const
+  {
+    const NormalDist* n = normalDistForPoint (transformed_pt);
+    // index is in grid, return score from the normal distribution from
+    // the correct part of the grid:
+    if (n)
+      return n->test (transformed_pt, cos_theta, sin_theta);
+    return ValueAndDerivatives<3,double>::Zero ();
+  }
+
+protected:
+  /** \brief Return the normal distribution covering the location of point p
+    * \param[in] p a point
+    */
+  NormalDist*
+  normalDistForPoint (PointT const& p) const
+  {
+    // this would be neater in 3d...
+    Eigen::Vector2f idxf;
+    for (std::size_t i = 0; i < 2; i++)
+      idxf[i] = (p.getVector3fMap ()[i] - min_[i]) / step_[i];
+    Eigen::Vector2i idxi = idxf.cast<int> ();
+    for (std::size_t i = 0; i < 2; i++)
+      if (idxi[i] >= cells_[i] || idxi[i] < 0)
+        return nullptr;
+    // const cast to avoid duplicating this function in const and
+    // non-const variants...
+    return const_cast<NormalDist*> (&normal_distributions_.coeffRef (idxi[0], idxi[1]));
+  }
+
+  Eigen::Vector2f min_;
+  Eigen::Vector2f max_;
+  Eigen::Vector2f step_;
+  Eigen::Vector2i cells_;
+
+  Eigen::Matrix<NormalDist, Eigen::Dynamic, Eigen::Dynamic> normal_distributions_;
+};
+
+/** \brief Build a Normal Distributions Transform of a 2D point cloud. This
+  * consists of the sum of four overlapping models of the original points
+  * with normal distributions.
+  * The value and derivatives of the model at any point can be evaluated
+  * with the test (...) function.
+  */
+template <typename PointT>
+class NDT2D: public boost::noncopyable
+{
+  using PointCloud = pcl::PointCloud<PointT>;
+  using PointCloudConstPtr = typename PointCloud::ConstPtr;
+  using SingleGrid = NDTSingleGrid<PointT>;
+
+public:
+  /** \brief
+    * \param[in] cloud the input point cloud
+    * \param[in] about Centre of the grid for normal distributions model
+    * \param[in] extent Extent of grid for normal distributions model
+    * \param[in] step Size of region that each normal distribution will model
+    */
+  NDT2D (PointCloudConstPtr cloud,
+       const Eigen::Vector2f& about,
+       const Eigen::Vector2f& extent,
+       const Eigen::Vector2f& step)
+  {
+    Eigen::Vector2f dx (step[0]/2, 0);
+    Eigen::Vector2f dy (0, step[1]/2);
+    single_grids_[0].reset(new SingleGrid (cloud, about,        extent, step));
+    single_grids_[1].reset(new SingleGrid (cloud, about +dx,    extent, step));
+    single_grids_[2].reset(new SingleGrid (cloud, about +dy,    extent, step));
+    single_grids_[3].reset(new SingleGrid (cloud, about +dx+dy, extent, step));
+  }
+
+  /** \brief Return the 'score' (denormalised likelihood) and derivatives of score of the point p given this distribution.
+    * \param[in] transformed_pt   Location to evaluate at.
+    * \param[in] cos_theta        sin(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
+    * \param[in] sin_theta        cos(theta) of the current rotation angle of rigid transformation: to avoid repeated evaluation
+    */
+  ValueAndDerivatives<3,double>
+  test (const PointT& transformed_pt, const double& cos_theta, const double& sin_theta) const
+  {
+    ValueAndDerivatives<3,double> r = ValueAndDerivatives<3,double>::Zero ();
+    for (const auto &single_grid : single_grids_)
+        r += single_grid->test (transformed_pt, cos_theta, sin_theta);
+    return r;
+  }
+
+protected:
+  std::shared_ptr<SingleGrid> single_grids_[4];
+};
+
+} // namespace ndt2d
 } // namespace pcl
 
 
 namespace Eigen
 {
-  /* This NumTraits specialisation is necessary because NormalDist is used as
-   * the element type of an Eigen Matrix.
-   */
-  template<typename PointT> struct NumTraits<pcl::ndt2d::NormalDist<PointT> >
+
+/* This NumTraits specialisation is necessary because NormalDist is used as
+* the element type of an Eigen Matrix.
+*/
+template<typename PointT>
+struct NumTraits<pcl::ndt2d::NormalDist<PointT> >
+{
+  using Real = double;
+  using Literal = double;
+  static Real dummy_precision () { return 1.0; }
+  enum
   {
-    using Real = double;
-    using Literal = double;
-    static Real dummy_precision () { return 1.0; }
-    enum {
-      IsComplex = 0,
-      IsInteger = 0,
-      IsSigned = 0,
-      RequireInitialization = 1,
-      ReadCost = 1,
-      AddCost = 1,
-      MulCost = 1
-    };
+    IsComplex = 0,
+    IsInteger = 0,
+    IsSigned = 0,
+    RequireInitialization = 1,
+    ReadCost = 1,
+    AddCost = 1,
+    MulCost = 1
   };
-}
+};
+
+} // namespace Eigen
+
+
+namespace pcl
+{
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget> void
-pcl::NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f &guess)
+NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f &guess)
 {
   PointCloudSource intm_cloud = output;
 
@@ -384,13 +393,13 @@ pcl::NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransforma
   {
     transformation_ = guess;
     transformPointCloud (output, intm_cloud, transformation_);
-  } 
+  }
 
   // build Normal Distribution Transform of target cloud:
   ndt2d::NDT2D<PointTarget> target_ndt (target_, grid_centre_, grid_extent_, grid_step_);
-  
+
   // can't seem to use .block<> () member function on transformation_
-  // directly... gcc bug? 
+  // directly... gcc bug?
   Eigen::Matrix4f& transformation = transformation_;
 
 
@@ -410,12 +419,12 @@ pcl::NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransforma
   {
     const double cos_theta = std::cos (xytheta_transformation[2]);
     const double sin_theta = std::sin (xytheta_transformation[2]);
-    previous_transformation_ = transformation;    
+    previous_transformation_ = transformation;
 
     ndt2d::ValueAndDerivatives<3, double> score = ndt2d::ValueAndDerivatives<3, double>::Zero ();
     for (std::size_t i = 0; i < intm_cloud.size (); i++)
       score += target_ndt.test (intm_cloud[i], cos_theta, sin_theta);
-    
+
     PCL_DEBUG ("[pcl::NormalDistributionsTransform2D::computeTransformation] NDT score %f (x=%f,y=%f,r=%f)\n",
       float (score.value), xytheta_transformation[0], xytheta_transformation[1], xytheta_transformation[2]
     );
@@ -447,12 +456,12 @@ pcl::NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransforma
       assert (solver.eigenvalues ()[0].real () >= 0 &&
               solver.eigenvalues ()[1].real () >= 0 &&
               solver.eigenvalues ()[2].real () >= 0);
-      
+
       Eigen::Vector3d delta_transformation (-score.hessian.inverse () * score.grad);
       Eigen::Vector3d new_transformation = xytheta_transformation + newton_lambda_.cwiseProduct (delta_transformation);
 
       xytheta_transformation = new_transformation;
-      
+
       // update transformation matrix from x, y, theta:
       transformation.block<3,3> (0,0).matrix () = Eigen::Matrix3f (Eigen::AngleAxisf (static_cast<float> (xytheta_transformation[2]), Eigen::Vector3f::UnitZ ()));
       transformation.block<3,1> (0,3).matrix () = Eigen::Vector3f (static_cast<float> (xytheta_transformation[0]), static_cast<float> (xytheta_transformation[1]), 0.0f);
@@ -464,11 +473,11 @@ pcl::NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransforma
       PCL_ERROR ("[pcl::NormalDistributionsTransform2D::computeTransformation] no overlap: try increasing the size or reducing the step of the grid\n");
       break;
     }
-    
+
     transformPointCloud (output, intm_cloud, transformation);
 
     nr_iterations_++;
-    
+
     if (update_visualizer_)
       update_visualizer_ (output, *indices_, *target_, *indices_);
 
@@ -492,5 +501,7 @@ pcl::NormalDistributionsTransform2D<PointSource, PointTarget>::computeTransforma
   output = intm_cloud;
 }
 
+} // namespace pcl
+
 #endif    // PCL_NDT_2D_IMPL_H_
+
index 2a57773408f5c93a7039f8b1e3789a96c48e5724..1f2de87af0e28e4aeea124489d2eea7a84fe8533 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_IMPL_PAIRWISE_GRAPH_REGISTRATION_HPP_
 #define PCL_REGISTRATION_IMPL_PAIRWISE_GRAPH_REGISTRATION_HPP_
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+namespace pcl
+{
+
 template <typename GraphT, typename PointT> void
-pcl::PairwiseGraphRegistration<GraphT, PointT>::computeRegistration ()
+PairwiseGraphRegistration<GraphT, PointT>::computeRegistration ()
 {
   if (!registration_method_)
   {
@@ -76,4 +81,8 @@ pcl::PairwiseGraphRegistration<GraphT, PointT>::computeRegistration ()
     registration_method_->setInputTarget (boost::get_cloud<PointT> (last_aligned_vertex_, *(graph_handler_->getGraph ())));
   }
 }
+
+} // namespace pcl
+
 #endif //PCL_REGISTRATION_IMPL_PAIRWISE_GRAPH_REGISTRATION_HPP_
+
index 5dfd6c49cfc2fa36c0bb56d00bfaa66dc03795c5..f986e8b852566f5572fdcbd7b00abd0b50d78a60 100644 (file)
 #include <pcl/pcl_macros.h>
 #include <pcl/console/print.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointFeature> float
-pcl::PyramidFeatureHistogram<PointFeature>::comparePyramidFeatureHistograms (const PyramidFeatureHistogramPtr &pyramid_a,
-                                                                             const PyramidFeatureHistogramPtr &pyramid_b)
+PyramidFeatureHistogram<PointFeature>::comparePyramidFeatureHistograms (const PyramidFeatureHistogramPtr &pyramid_a,
+                                                                        const PyramidFeatureHistogramPtr &pyramid_b)
 {
   // do a few consistency checks before and during the computation
   if (pyramid_a->nr_dimensions != pyramid_b->nr_dimensions)
@@ -113,9 +116,8 @@ pcl::PyramidFeatureHistogram<PointFeature>::comparePyramidFeatureHistograms (con
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature>
-pcl::PyramidFeatureHistogram<PointFeature>::PyramidFeatureHistogram () :
+PyramidFeatureHistogram<PointFeature>::PyramidFeatureHistogram () :
   nr_dimensions (0), nr_levels (0), nr_features (0),
   feature_representation_ (new DefaultPointRepresentation<PointFeature>),
   is_computed_ (false),
@@ -123,9 +125,9 @@ pcl::PyramidFeatureHistogram<PointFeature>::PyramidFeatureHistogram () :
 {
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointFeature> void
-pcl::PyramidFeatureHistogram<PointFeature>::PyramidFeatureHistogramLevel::initializeHistogramLevel ()
+PyramidFeatureHistogram<PointFeature>::PyramidFeatureHistogramLevel::initializeHistogramLevel ()
 {
   std::size_t total_vector_size = 1;
   for (std::vector<std::size_t>::iterator dim_it = bins_per_dimension.begin (); dim_it != bins_per_dimension.end (); ++dim_it)
@@ -135,9 +137,8 @@ pcl::PyramidFeatureHistogram<PointFeature>::PyramidFeatureHistogramLevel::initia
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature> bool
-pcl::PyramidFeatureHistogram<PointFeature>::initializeHistogram ()
+PyramidFeatureHistogram<PointFeature>::initializeHistogram ()
 {
   // a few consistency checks before starting the computations
   if (!PCLBase<PointFeature>::initCompute ())
@@ -202,10 +203,9 @@ pcl::PyramidFeatureHistogram<PointFeature>::initializeHistogram ()
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature> unsigned int&
-pcl::PyramidFeatureHistogram<PointFeature>::at (std::vector<std::size_t> &access,
-                                                std::size_t &level)
+PyramidFeatureHistogram<PointFeature>::at (std::vector<std::size_t> &access,
+                                           std::size_t &level)
 {
   if (access.size () != nr_dimensions)
   {
@@ -231,10 +231,9 @@ pcl::PyramidFeatureHistogram<PointFeature>::at (std::vector<std::size_t> &access
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature> unsigned int&
-pcl::PyramidFeatureHistogram<PointFeature>::at (std::vector<float> &feature,
-                                                std::size_t &level)
+PyramidFeatureHistogram<PointFeature>::at (std::vector<float> &feature,
+                                           std::size_t &level)
 {
   if (feature.size () != nr_dimensions)
   {
@@ -255,10 +254,9 @@ pcl::PyramidFeatureHistogram<PointFeature>::at (std::vector<float> &feature,
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature> void
-pcl::PyramidFeatureHistogram<PointFeature>::convertFeatureToVector (const PointFeature &feature,
-                                                                    std::vector<float> &feature_vector)
+PyramidFeatureHistogram<PointFeature>::convertFeatureToVector (const PointFeature &feature,
+                                                               std::vector<float> &feature_vector)
 {
   // convert feature to vector representation
   feature_vector.resize (feature_representation_->getNumberOfDimensions ());
@@ -271,9 +269,8 @@ pcl::PyramidFeatureHistogram<PointFeature>::convertFeatureToVector (const PointF
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature> void
-pcl::PyramidFeatureHistogram<PointFeature>::compute ()
+PyramidFeatureHistogram<PointFeature>::compute ()
 {
   if (!initializeHistogram ())
     return;
@@ -289,14 +286,16 @@ pcl::PyramidFeatureHistogram<PointFeature>::compute ()
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointFeature> void
-pcl::PyramidFeatureHistogram<PointFeature>::addFeature (std::vector<float> &feature)
+PyramidFeatureHistogram<PointFeature>::addFeature (std::vector<float> &feature)
 {
   for (std::size_t level_i = 0; level_i < nr_levels; ++level_i)
     at (feature, level_i) ++;
 }
 
+} // namespace pcl
+
 #define PCL_INSTANTIATE_PyramidFeatureHistogram(PointFeature) template class PCL_EXPORTS pcl::PyramidFeatureHistogram<PointFeature>;
 
 #endif /* PCL_REGISTRATION_IMPL_PYRAMID_FEATURE_MATCHING_H_ */
+
index 88dfab75c38f0c54d8a17dd5546c08a7684605dc..bd40767a7e2c8c91d881a6b222e0cff197dba6ef 100644 (file)
  *
  */
 
-///////////////////////////////////////////////////////////////////////////////////////////
+#pragma once
+
+namespace pcl
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::Registration<PointSource, PointTarget, Scalar>::setInputTarget (const PointCloudTargetConstPtr &cloud)
+Registration<PointSource, PointTarget, Scalar>::setInputTarget (const PointCloudTargetConstPtr &cloud)
 {
   if (cloud->points.empty ())
   {
@@ -51,9 +55,9 @@ pcl::Registration<PointSource, PointTarget, Scalar>::setInputTarget (const Point
   target_cloud_updated_ = true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> bool
-pcl::Registration<PointSource, PointTarget, Scalar>::initCompute ()
+Registration<PointSource, PointTarget, Scalar>::initCompute ()
 {
   if (!target_)
   {
@@ -68,23 +72,22 @@ pcl::Registration<PointSource, PointTarget, Scalar>::initCompute ()
     target_cloud_updated_ = false;
   }
 
-  
   // Update the correspondence estimation
   if (correspondence_estimation_)
   {
     correspondence_estimation_->setSearchMethodTarget (tree_, force_no_recompute_);
     correspondence_estimation_->setSearchMethodSource (tree_reciprocal_, force_no_recompute_reciprocal_);
   }
-  
+
   // Note: we /cannot/ update the search method on all correspondence rejectors, because we know 
   // nothing about them. If they should be cached, they must be cached individually.
 
   return (PCLBase<PointSource>::initCompute ());
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> bool
-pcl::Registration<PointSource, PointTarget, Scalar>::initComputeReciprocal ()
+Registration<PointSource, PointTarget, Scalar>::initComputeReciprocal ()
 {
   if (!input_)
   {
@@ -100,9 +103,9 @@ pcl::Registration<PointSource, PointTarget, Scalar>::initComputeReciprocal ()
   return (true);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline double
-pcl::Registration<PointSource, PointTarget, Scalar>::getFitnessScore (
+Registration<PointSource, PointTarget, Scalar>::getFitnessScore (
     const std::vector<float> &distances_a,
     const std::vector<float> &distances_b)
 {
@@ -112,11 +115,10 @@ pcl::Registration<PointSource, PointTarget, Scalar>::getFitnessScore (
   return (static_cast<double> ((map_a - map_b).sum ()) / static_cast<double> (nr_elem));
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline double
-pcl::Registration<PointSource, PointTarget, Scalar>::getFitnessScore (double max_range)
+Registration<PointSource, PointTarget, Scalar>::getFitnessScore (double max_range)
 {
-
   double fitness_score = 0.0;
 
   // Transform the input dataset using the final transformation
@@ -132,7 +134,7 @@ pcl::Registration<PointSource, PointTarget, Scalar>::getFitnessScore (double max
   {
     // Find its nearest neighbor in the target
     tree_->nearestKSearch (input_transformed.points[i], 1, nn_indices, nn_dists);
-    
+
     // Deal with occlusions (incomplete targets)
     if (nn_dists[0] <= max_range)
     {
@@ -148,18 +150,18 @@ pcl::Registration<PointSource, PointTarget, Scalar>::getFitnessScore (double max
 
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::Registration<PointSource, PointTarget, Scalar>::align (PointCloudSource &output)
+Registration<PointSource, PointTarget, Scalar>::align (PointCloudSource &output)
 {
   align (output, Matrix4::Identity ());
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::Registration<PointSource, PointTarget, Scalar>::align (PointCloudSource &output, const Matrix4& guess)
+Registration<PointSource, PointTarget, Scalar>::align (PointCloudSource &output, const Matrix4& guess)
 {
-  if (!initCompute ()) 
+  if (!initCompute ())
     return;
 
   // Resize the output dataset
@@ -202,3 +204,5 @@ pcl::Registration<PointSource, PointTarget, Scalar>::align (PointCloudSource &ou
   deinitCompute ();
 }
 
+} // namespace pcl
+
index 2fa4dd60c10c824427ce00c719bb0fda0365a55a..aec01f8bee411091baa80fc0b95fe35d756ab10c 100644 (file)
 #ifndef PCL_REGISTRATION_SAMPLE_CONSENSUS_PREREJECTIVE_HPP_
 #define PCL_REGISTRATION_SAMPLE_CONSENSUS_PREREJECTIVE_HPP_
 
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::setSourceFeatures (const FeatureCloudConstPtr &features)
+
+namespace pcl
+{
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::setSourceFeatures (const FeatureCloudConstPtr &features)
 {
   if (features == nullptr || features->empty ())
   {
@@ -53,9 +56,9 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::setSourceF
   input_features_ = features;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::setTargetFeatures (const FeatureCloudConstPtr &features)
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::setTargetFeatures (const FeatureCloudConstPtr &features)
 {
   if (features == nullptr || features->empty ())
   {
@@ -66,9 +69,9 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::setTargetF
   feature_tree_->setInputCloud (target_features_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::selectSamples (
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::selectSamples (
     const PointCloudSource &cloud, int nr_samples, std::vector<int> &sample_indices)
 {
   if (nr_samples > static_cast<int> (cloud.points.size ()))
@@ -78,7 +81,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::selectSamp
                nr_samples, cloud.points.size ());
     return;
   }
-  
+
   sample_indices.resize (nr_samples);
   int temp_sample;
 
@@ -87,7 +90,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::selectSamp
   {
     // Select a random number
     sample_indices[i] = getRandomIndex (static_cast<int> (cloud.points.size ()) - i);
-      
+
     // Run trough list of numbers, starting at the lowest, to avoid duplicates
     for (int j = 0; j < i; j++)
     {
@@ -102,7 +105,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::selectSamp
         temp_sample = sample_indices[i];
         for (int k = i; k > j; k--)
           sample_indices[k] = sample_indices[k - 1];
-        
+
         sample_indices[j] = temp_sample;
         break;
       }
@@ -110,9 +113,9 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::selectSamp
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::findSimilarFeatures (
+SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::findSimilarFeatures (
         const std::vector<int> &sample_indices,
         std::vector<std::vector<int> >& similar_features,
         std::vector<int> &corresponding_indices)
@@ -120,13 +123,13 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::findSimila
   // Allocate results
   corresponding_indices.resize (sample_indices.size ());
   std::vector<float> nn_distances (k_correspondences_);
-  
+
   // Loop over the sampled features
   for (std::size_t i = 0; i < sample_indices.size (); ++i)
   {
     // Current feature index
     const int idx = sample_indices[i];
-    
+
     // Find the k nearest feature neighbors to the sampled input feature if they are not in the cache already
     if (similar_features[idx].empty ())
       feature_tree_->nearestKSearch (*input_features_, idx, k_correspondences_, similar_features[idx], nn_distances);
@@ -139,9 +142,9 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::findSimila
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f& guess)
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTransformation (PointCloudSource &output, const Eigen::Matrix4f& guess)
 {
   // Some sanity checks first
   if (!input_features_)
@@ -180,7 +183,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTra
                inlier_fraction_);
     return;
   }
-  
+
   const float similarity_threshold = correspondence_rejector_poly_->getSimilarityThreshold ();
   if (similarity_threshold < 0.0f || similarity_threshold >= 1.0f)
   {
@@ -189,7 +192,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTra
                similarity_threshold);
     return;
   }
-  
+
   if (k_correspondences_ <= 0)
   {
     PCL_ERROR ("[pcl::%s::computeTransformation] ", getClassName ().c_str ());
@@ -197,30 +200,30 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTra
             k_correspondences_);
     return;
   }
-  
+
   // Initialize prerejector (similarity threshold already set to default value in constructor)
   correspondence_rejector_poly_->setInputSource (input_);
   correspondence_rejector_poly_->setInputTarget (target_);
   correspondence_rejector_poly_->setCardinality (nr_samples_);
   int num_rejections = 0; // For debugging
-  
+
   // Initialize results
   final_transformation_ = guess;
   inliers_.clear ();
   float lowest_error = std::numeric_limits<float>::max ();
   converged_ = false;
-  
+
   // Temporaries
   std::vector<int> inliers;
   float inlier_fraction;
   float error;
-  
+
   // If guess is not the Identity matrix we check it
   if (!guess.isApprox (Eigen::Matrix4f::Identity (), 0.01f))
   {
     getFitness (inliers, error);
     inlier_fraction = static_cast<float> (inliers.size ()) / static_cast<float> (input_->size ());
-    
+
     if (inlier_fraction >= inlier_fraction_ && error < lowest_error)
     {
       inliers_ = inliers;
@@ -228,23 +231,23 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTra
       converged_ = true;
     }
   }
-  
+
   // Feature correspondence cache
   std::vector<std::vector<int> > similar_features (input_->size ());
-  
+
   // Start
   for (int i = 0; i < max_iterations_; ++i)
   {
     // Temporary containers
     std::vector<int> sample_indices;
     std::vector<int> corresponding_indices;
-    
+
     // Draw nr_samples_ random samples
     selectSamples (*input_, nr_samples_, sample_indices);
-    
+
     // Find corresponding features in the target cloud
     findSimilarFeatures (sample_indices, similar_features, corresponding_indices);
-    
+
     // Apply prerejection
     if (!correspondence_rejector_poly_->thresholdPolygon (sample_indices, corresponding_indices))
     {
@@ -254,16 +257,16 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTra
 
     // Estimate the transform from the correspondences, write to transformation_
     transformation_estimation_->estimateRigidTransformation (*input_, sample_indices, *target_, corresponding_indices, transformation_);
-    
+
     // Take a backup of previous result
     const Matrix4 final_transformation_prev = final_transformation_;
-    
+
     // Set final result to current transformation
     final_transformation_ = transformation_;
-    
+
     // Transform the input and compute the error (uses input_ and final_transformation_)
     getFitness (inliers, error);
-    
+
     // Restore previous result
     final_transformation_ = final_transformation_prev;
 
@@ -283,21 +286,21 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::computeTra
   // Apply the final transformation
   if (converged_)
     transformPointCloud (*input_, output, final_transformation_);
-  
+
   // Debug output
   PCL_DEBUG("[pcl::%s::computeTransformation] Rejected %i out of %i generated pose hypotheses.\n",
             getClassName ().c_str (), num_rejections, max_iterations_);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename FeatureT> void 
-pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::getFitness (std::vector<int>& inliers, float& fitness_score)
+
+template <typename PointSource, typename PointTarget, typename FeatureT> void
+SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::getFitness (std::vector<int>& inliers, float& fitness_score)
 {
   // Initialize variables
   inliers.clear ();
   inliers.reserve (input_->size ());
   fitness_score = 0.0f;
-  
+
   // Use squared distance for comparison with NN search results
   const float max_range = corr_dist_threshold_ * corr_dist_threshold_;
 
@@ -305,7 +308,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::getFitness
   PointCloudSource input_transformed;
   input_transformed.resize (input_->size ());
   transformPointCloud (*input_, input_transformed, final_transformation_);
-  
+
   // For each point in the source dataset
   for (std::size_t i = 0; i < input_transformed.points.size (); ++i)
   {
@@ -313,13 +316,13 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::getFitness
     std::vector<int> nn_indices (1);
     std::vector<float> nn_dists (1);
     tree_->nearestKSearch (input_transformed.points[i], 1, nn_indices, nn_dists);
-    
+
     // Check if point is an inlier
     if (nn_dists[0] < max_range)
     {
       // Update inliers
       inliers.push_back (static_cast<int> (i));
-      
+
       // Update fitness score
       fitness_score += nn_dists[0];
     }
@@ -332,5 +335,7 @@ pcl::SampleConsensusPrerejective<PointSource, PointTarget, FeatureT>::getFitness
     fitness_score = std::numeric_limits<float>::max ();
 }
 
+} // namespace pcl
+
 #endif
 
index 36b9d6785007a553e31b6b19c99b6d1e3f7da0a4..162aad6361332d0a9166b813387a8c3a89c29560 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_2D_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_2D_HPP_
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     Matrix4 &transformation_matrix) const
@@ -56,9 +63,9 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -76,9 +83,8 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
 }
 
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -96,9 +102,9 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     const pcl::Correspondences &correspondences,
@@ -109,9 +115,9 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimation2D<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     ConstCloudIterator<PointSource>& source_it,
     ConstCloudIterator<PointTarget>& target_it,
     Matrix4 &transformation_matrix) const
@@ -135,9 +141,9 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
   getTransformationFromCorrelation (cloud_src_demean, centroid_src, cloud_tgt_demean, centroid_tgt, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>::getTransformationFromCorrelation (
+TransformationEstimation2D<PointSource, PointTarget, Scalar>::getTransformationFromCorrelation (
     const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_src_demean,
     const Eigen::Matrix<Scalar, 4, 1> &centroid_src,
     const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_tgt_demean,
@@ -148,9 +154,9 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
 
   // Assemble the correlation matrix H = source * target'
   Eigen::Matrix<Scalar, 3, 3> H = (cloud_src_demean * cloud_tgt_demean.transpose ()).topLeftCorner (3, 3);
-  
+
   float angle = std::atan2 ((H (0, 1) - H (1, 0)), (H(0, 0) + H (1, 1)));
-  
+
   Eigen::Matrix<Scalar, 3, 3> R (Eigen::Matrix<Scalar, 3, 3>::Identity ());
   R (0, 0) = R (1, 1) = std::cos (angle);
   R (0, 1) = -std::sin (angle);
@@ -162,4 +168,8 @@ pcl::registration::TransformationEstimation2D<PointSource, PointTarget, Scalar>:
   transformation_matrix.block (0, 3, 3, 1).matrix () = centroid_tgt.head (3) - Rc;
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_2D_HPP_
+
index 102ca7e5b00a143d36add8f2ac1d8bcd85ca0be2..b5a486119193af645a2769a6b7d0ca4648ca7c97 100644 (file)
  *
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_DQ_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_DQ_HPP_
 
 #include <pcl/common/eigen.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     Matrix4 &transformation_matrix) const
@@ -60,9 +67,9 @@ pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -79,9 +86,9 @@ pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -99,9 +106,9 @@ pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     const pcl::Correspondences &correspondences,
@@ -112,9 +119,9 @@ pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>:
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDQ<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     ConstCloudIterator<PointSource>& source_it,
     ConstCloudIterator<PointTarget>& target_it,
     Matrix4 &transformation_matrix) const
@@ -203,4 +210,8 @@ pcl::registration::TransformationEstimationDQ<PointSource, PointTarget, Scalar>:
   transformation_matrix(2,3) = -t.z();
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_DQ_HPP_ */
+
index 27f1347d91f4b3a5bbc3bf0eae386af383e1374c..9bee6a2533ce5402a6820a7de2855548f6e8529b 100644 (file)
  *
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_DQ_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_DQ_HPP_
 
 #include <pcl/common/eigen.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     Matrix4 &transformation_matrix) const
@@ -60,9 +67,9 @@ pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarg
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -79,9 +86,9 @@ pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarg
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -99,9 +106,9 @@ pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarg
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     const pcl::Correspondences &correspondences,
@@ -112,9 +119,9 @@ pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarg
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     ConstCloudIterator<PointSource>& source_it,
     ConstCloudIterator<PointTarget>& target_it,
     Matrix4 &transformation_matrix) const
@@ -204,4 +211,8 @@ pcl::registration::TransformationEstimationDualQuaternion<PointSource, PointTarg
   transformation_matrix (2, 3) = - t.z ();
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_DQ_HPP_ */
+
index 03316e3c18b2d1dc726659905e3a279929a9030d..97ffe4bf82a7d4022172b80e27a8825e59d9f16f 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_LLS_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_LLS_HPP_
+
 #include <pcl/cloud_iterator.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
                              Matrix4 &transformation_matrix) const
@@ -57,12 +65,12 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 
   ConstCloudIterator<PointSource> source_it (cloud_src);
   ConstCloudIterator<PointTarget> target_it (cloud_tgt);
-  estimateRigidTransformation (source_it, target_it, transformation_matrix);  
+  estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const std::vector<int> &indices_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -77,13 +85,12 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 
   ConstCloudIterator<PointSource> source_it (cloud_src, indices_src);
   ConstCloudIterator<PointTarget> target_it (cloud_tgt);
-  estimateRigidTransformation (source_it, target_it, transformation_matrix);  
+  estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const std::vector<int> &indices_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -99,12 +106,12 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 
   ConstCloudIterator<PointSource> source_it (cloud_src, indices_src);
   ConstCloudIterator<PointTarget> target_it (cloud_tgt, indices_tgt);
-  estimateRigidTransformation (source_it, target_it, transformation_matrix);  
+  estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
                              const pcl::Correspondences &correspondences,
@@ -115,14 +122,14 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 constructTransformationMatrix (const double & alpha, const double & beta, const double & gamma,
                                const double & tx,    const double & ty,   const double & tz,
                                Matrix4 &transformation_matrix) const
 {
-  // Construct the transformation matrix from rotation and translation 
+  // Construct the transformation matrix from rotation and translation
   transformation_matrix = Eigen::Matrix<Scalar, 4, 4>::Zero ();
   transformation_matrix (0, 0) = static_cast<Scalar> ( std::cos (gamma) * std::cos (beta));
   transformation_matrix (0, 1) = static_cast<Scalar> (-sin (gamma) * std::cos (alpha) + std::cos (gamma) * sin (beta) * sin (alpha));
@@ -140,9 +147,9 @@ constructTransformationMatrix (const double & alpha, const double & beta, const
   transformation_matrix (3, 3) = static_cast<Scalar> (1);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCloudIterator<PointTarget>& target_it, Matrix4 &transformation_matrix) const
 {
   using Vector6d = Eigen::Matrix<double, 6, 1>;
@@ -167,7 +174,7 @@ estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCl
         !std::isfinite (target_it->normal_z))
     {
       ++target_it;
-      ++source_it;    
+      ++source_it;
       continue;
     }
 
@@ -182,16 +189,16 @@ estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCl
     const float & nz = target_it->normal[2];
 
     double a = nz*sy - ny*sz;
-    double b = nx*sz - nz*sx; 
+    double b = nx*sz - nz*sx;
     double c = ny*sx - nx*sy;
-   
+
     //    0  1  2  3  4  5
     //    6  7  8  9 10 11
     //   12 13 14 15 16 17
     //   18 19 20 21 22 23
     //   24 25 26 27 28 29
     //   30 31 32 33 34 35
-   
+
     ATA.coeffRef (0) += a * a;
     ATA.coeffRef (1) += a * b;
     ATA.coeffRef (2) += a * c;
@@ -223,8 +230,9 @@ estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCl
     ATb.coeffRef (5) += nz * d;
 
     ++target_it;
-    ++source_it;    
+    ++source_it;
   }
+
   ATA.coeffRef (6) = ATA.coeff (1);
   ATA.coeffRef (12) = ATA.coeff (2);
   ATA.coeffRef (13) = ATA.coeff (8);
@@ -243,8 +251,13 @@ estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCl
 
   // Solve A*x = b
   Vector6d x = static_cast<Vector6d> (ATA.inverse () * ATb);
-  
+
   // Construct the transformation matrix from x
   constructTransformationMatrix (x (0), x (1), x (2), x (3), x (4), x (5), transformation_matrix);
 }
+
+} // namespace registration
+} // namespace pcl
+
 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_LLS_HPP_ */
+
index dfbd16108db8b2fcc0ed5abb701473651c603e04..c377fad4d3bc3239e0ca77c6447a2de6809f32f5 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_LLS_WEIGHTED_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_LLS_WEIGHTED_HPP_
+
 #include <pcl/cloud_iterator.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
                              Matrix4 &transformation_matrix) const
@@ -66,9 +74,9 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
   estimateRigidTransformation (source_it, target_it, weights_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const std::vector<int> &indices_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -95,9 +103,8 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const std::vector<int> &indices_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -123,9 +130,9 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
   estimateRigidTransformation (source_it, target_it, weights_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
                              const pcl::Correspondences &correspondences,
@@ -140,14 +147,14 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
   estimateRigidTransformation (source_it, target_it, weights_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
 constructTransformationMatrix (const double & alpha, const double & beta, const double & gamma,
                                const double & tx,    const double & ty,   const double & tz,
                                Matrix4 &transformation_matrix) const
 {
-  // Construct the transformation matrix from rotation and translation 
+  // Construct the transformation matrix from rotation and translation
   transformation_matrix = Eigen::Matrix<Scalar, 4, 4>::Zero ();
   transformation_matrix (0, 0) = static_cast<Scalar> ( std::cos (gamma) * std::cos (beta));
   transformation_matrix (0, 1) = static_cast<Scalar> (-sin (gamma) * std::cos (alpha) + std::cos (gamma) * sin (beta) * sin (alpha));
@@ -165,9 +172,9 @@ constructTransformationMatrix (const double & alpha, const double & beta, const
   transformation_matrix (3, 3) = static_cast<Scalar> (1);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
+TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it,
                              ConstCloudIterator<PointTarget>& target_it,
                              typename std::vector<Scalar>::const_iterator& weights_it,
@@ -277,4 +284,9 @@ estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it,
   // Construct the transformation matrix from x
   constructTransformationMatrix (x (0), x (1), x (2), x (3), x (4), x (5), transformation_matrix);
 }
+
+} // namespace registration
+} // namespace pcl
+
 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_LLS_WEIGHTED_HPP_ */
+
index 0717db44ee2adc8fb5ed30ae1f450e82b1c83c34..a465aae812f68b4a40c63689cb5959d531ab7c99 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_HPP_
 
 #include <pcl/common/eigen.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     Matrix4 &transformation_matrix) const
@@ -61,9 +68,9 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -80,9 +87,9 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -100,9 +107,9 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     const pcl::PointCloud<PointSource> &cloud_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
     const pcl::Correspondences &correspondences,
@@ -113,9 +120,9 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
+TransformationEstimationSVD<PointSource, PointTarget, Scalar>::estimateRigidTransformation (
     ConstCloudIterator<PointSource>& source_it,
     ConstCloudIterator<PointTarget>& target_it,
     Matrix4 &transformation_matrix) const
@@ -142,7 +149,7 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
       cloud_tgt (2, i) = target_it->z;
       ++target_it;
     }
-    
+
     // Call Umeyama directly from Eigen (PCL patched version until Eigen is released)
     transformation_matrix = pcl::umeyama (cloud_src, cloud_tgt, false);
   }
@@ -167,9 +174,9 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>::getTransformationFromCorrelation (
+TransformationEstimationSVD<PointSource, PointTarget, Scalar>::getTransformationFromCorrelation (
     const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_src_demean,
     const Eigen::Matrix<Scalar, 4, 1> &centroid_src,
     const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_tgt_demean,
@@ -201,6 +208,10 @@ pcl::registration::TransformationEstimationSVD<PointSource, PointTarget, Scalar>
   transformation_matrix.block (0, 3, 3, 1) = centroid_tgt.head (3) - Rc;
 }
 
+} // namespace registration
+} // namespace pcl
+
 //#define PCL_INSTANTIATE_TransformationEstimationSVD(T,U) template class PCL_EXPORTS pcl::registration::TransformationEstimationSVD<T,U>;
 
 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_HPP_ */
+
index 553342efbf02463bc9adde9397fcd8b6bb11b266..e6b9327d184798ea7afebf17af6996fd72f3b3dd 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_SCALE_HPP_
 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_SCALE_HPP_
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationSVDScale<PointSource, PointTarget, Scalar>::getTransformationFromCorrelation (
+TransformationEstimationSVDScale<PointSource, PointTarget, Scalar>::getTransformationFromCorrelation (
     const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_src_demean,
     const Eigen::Matrix<Scalar, 4, 1> &centroid_src,
     const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_tgt_demean,
@@ -68,7 +75,7 @@ pcl::registration::TransformationEstimationSVDScale<PointSource, PointTarget, Sc
   Eigen::Matrix<Scalar, 3, 3> R = v * u.transpose ();
 
   // rotated cloud
-  Eigen::Matrix<Scalar, 4, 4> R4; 
+  Eigen::Matrix<Scalar, 4, 4> R4;
   R4.block (0, 0, 3, 3) = R;
   R4 (0, 3) = 0;
   R4 (1, 3) = 0;
@@ -76,32 +83,28 @@ pcl::registration::TransformationEstimationSVDScale<PointSource, PointTarget, Sc
   R4 (3, 3) = 1;
 
   Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> src_ = R4 * cloud_src_demean;
-  
-  float scale1, scale2;
-  double sum_ss = 0.0f, sum_tt = 0.0f, sum_tt_ = 0.0f;
+
+  double sum_ss = 0.0f, sum_tt = 0.0f;
   for (unsigned corrIdx = 0; corrIdx < cloud_src_demean.cols (); ++corrIdx)
   {
     sum_ss += cloud_src_demean (0, corrIdx) * cloud_src_demean (0, corrIdx);
     sum_ss += cloud_src_demean (1, corrIdx) * cloud_src_demean (1, corrIdx);
     sum_ss += cloud_src_demean (2, corrIdx) * cloud_src_demean (2, corrIdx);
-    
-    sum_tt += cloud_tgt_demean (0, corrIdx) * cloud_tgt_demean (0, corrIdx);
-    sum_tt += cloud_tgt_demean (1, corrIdx) * cloud_tgt_demean (1, corrIdx);
-    sum_tt += cloud_tgt_demean (2, corrIdx) * cloud_tgt_demean (2, corrIdx);
-    
-    sum_tt_ += cloud_tgt_demean (0, corrIdx) * src_ (0, corrIdx);
-    sum_tt_ += cloud_tgt_demean (1, corrIdx) * src_ (1, corrIdx);
-    sum_tt_ += cloud_tgt_demean (2, corrIdx) * src_ (2, corrIdx);
+
+    sum_tt += cloud_tgt_demean (0, corrIdx) * src_ (0, corrIdx);
+    sum_tt += cloud_tgt_demean (1, corrIdx) * src_ (1, corrIdx);
+    sum_tt += cloud_tgt_demean (2, corrIdx) * src_ (2, corrIdx);
   }
-  
-  scale1 = sqrt (sum_tt / sum_ss);
-  scale2 = sum_tt_ / sum_ss;
-  float scale = scale2;
+
+  float scale = sum_tt / sum_ss;
   transformation_matrix.topLeftCorner (3, 3) = scale * R;
   const Eigen::Matrix<Scalar, 3, 1> Rc (scale * R * centroid_src.head (3));
   transformation_matrix.block (0, 3, 3, 1) = centroid_tgt. head (3) - Rc;
 }
 
+} // namespace registration
+} // namespace pcl
+
 //#define PCL_INSTANTIATE_TransformationEstimationSVD(T,U) template class PCL_EXPORTS pcl::registration::TransformationEstimationSVD<T,U>;
 
 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_SCALE_HPP_ */
index 1cf74db0fc3c0cbaf0983f88410ccd60b8046aba..a2f3e997c4bed30839e26f6afade443112e74af4 100644 (file)
 
 #include <pcl/cloud_iterator.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
                              Matrix4 &transformation_matrix) const
@@ -55,12 +61,12 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 
   ConstCloudIterator<PointSource> source_it (cloud_src);
   ConstCloudIterator<PointTarget> target_it (cloud_tgt);
-  estimateRigidTransformation (source_it, target_it, transformation_matrix);  
+  estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const std::vector<int> &indices_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -75,13 +81,12 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 
   ConstCloudIterator<PointSource> source_it (cloud_src, indices_src);
   ConstCloudIterator<PointTarget> target_it (cloud_tgt);
-  estimateRigidTransformation (source_it, target_it, transformation_matrix);  
+  estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const std::vector<int> &indices_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -97,12 +102,12 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
 
   ConstCloudIterator<PointSource> source_it (cloud_src, indices_src);
   ConstCloudIterator<PointTarget> target_it (cloud_tgt, indices_tgt);
-  estimateRigidTransformation (source_it, target_it, transformation_matrix);  
+  estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
                              const pcl::PointCloud<PointTarget> &cloud_tgt,
                              const pcl::Correspondences &correspondences,
@@ -113,13 +118,13 @@ estimateRigidTransformation (const pcl::PointCloud<PointSource> &cloud_src,
   estimateRigidTransformation (source_it, target_it, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 constructTransformationMatrix (const Vector6 &parameters,
                                Matrix4 &transformation_matrix) const
 {
-  // Construct the transformation matrix from rotation and translation 
+  // Construct the transformation matrix from rotation and translation
   const Eigen::AngleAxis<Scalar> rotation_z (parameters (2), Eigen::Matrix<Scalar, 3, 1>::UnitZ ());
   const Eigen::AngleAxis<Scalar> rotation_y (parameters (1), Eigen::Matrix<Scalar, 3, 1>::UnitY ());
   const Eigen::AngleAxis<Scalar> rotation_x (parameters (0), Eigen::Matrix<Scalar, 3, 1>::UnitX ());
@@ -130,9 +135,9 @@ constructTransformationMatrix (const Vector6 &parameters,
   transformation_matrix = transform.matrix ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCloudIterator<PointTarget>& target_it, Matrix4 &transformation_matrix) const
 {
   using Matrix6 = Eigen::Matrix<Scalar, 6, 6>;
@@ -176,29 +181,33 @@ estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, ConstCl
     Vector6 v;
     v << (p + q).cross (n), n;
     M.rankUpdate (v);
-   
+
     ATb += v * (q - p).dot (n);
   }
 
   // Solve A*x = b
   const Vector6 x = M.ldlt ().solve (ATb);
-  
+
   // Construct the transformation matrix from x
   constructTransformationMatrix (x, transformation_matrix);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointSource, typename PointTarget, typename Scalar> inline void
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 setEnforceSameDirectionNormals (bool enforce_same_direction_normals)
 {
     enforce_same_direction_normals_ = enforce_same_direction_normals;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointSource, typename PointTarget, typename Scalar> inline bool 
-pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
+
+template <typename PointSource, typename PointTarget, typename Scalar> inline bool
+TransformationEstimationSymmetricPointToPlaneLLS<PointSource, PointTarget, Scalar>::
 getEnforceSameDirectionNormals ()
 {
     return enforce_same_direction_normals_;
 }
+
+} // namespace registration
+} // namespace pcl
+
index f5ec7fda803706d551e110c4ee5594a19d8464ef..40fbb621334f302fb13b09c47ec23a44b08eb837 100644 (file)
  * $Id$
  *
  */
+
 #ifndef PCL_REGISTRATION_TRANSFORMATION_VALIDATION_EUCLIDEAN_IMPL_H_
 #define PCL_REGISTRATION_TRANSFORMATION_VALIDATION_EUCLIDEAN_IMPL_H_
 
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace registration
+{
+
 template <typename PointSource, typename PointTarget, typename Scalar> double
-pcl::registration::TransformationValidationEuclidean<PointSource, PointTarget, Scalar>::validateTransformation (
+TransformationValidationEuclidean<PointSource, PointTarget, Scalar>::validateTransformation (
   const PointCloudSourceConstPtr &cloud_src,
   const PointCloudTargetConstPtr &cloud_tgt,
   const Matrix4 &transformation_matrix) const
@@ -78,7 +85,7 @@ pcl::registration::TransformationValidationEuclidean<PointSource, PointTarget, S
   {
     // Find its nearest neighbor in the target
     tree_->nearestKSearch (input_transformed.points[i], 1, nn_indices, nn_dists);
-    
+
     // Deal with occlusions (incomplete targets)
     if (nn_dists[0] > max_range_)
       continue;
@@ -93,5 +100,8 @@ pcl::registration::TransformationValidationEuclidean<PointSource, PointTarget, S
   return (std::numeric_limits<double>::max ());
 }
 
+} // namespace registration
+} // namespace pcl
+
 #endif    // PCL_REGISTRATION_TRANSFORMATION_VALIDATION_EUCLIDEAN_IMPL_H_
 
index 85a49c07b809d2e53eabd6157e0cac1d5a544f2e..f5ed97266002731a650cd1ea6f0676b70e59e173 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/pcl_base.h>
 #include <pcl/registration/eigen.h>
index 8767957525668b3bf16d1ff2973e70da0cf155e6..78c3223fcc8b304da780a0253c3d955330b09598 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/registration.h>
 #include <pcl/common/common.h>
index 9cca7f376885d055ed9c02c72ad0a33e7e63fed4..3ddb5d724e35e78fdf3a09f5e491776f6ab53240 100644 (file)
@@ -87,10 +87,10 @@ namespace pcl {
         virtual ~MetaRegistration () {};
 
         /** \brief Register new point cloud
-          * \note You have to set a valid registration object with @ref setICP before using this
+          * \note You have to set a valid registration object with \ref setRegistration before using this
           * \param[in] cloud point cloud to register
           * \param[in] delta_estimate estimated transform between last registered cloud and this one
-          * \return true if ICP converged
+          * \return true if registration converged
           */
         bool
         registerCloud (const PointCloudConstPtr& cloud, const Matrix4& delta_estimate = Matrix4::Identity ());
@@ -99,7 +99,7 @@ namespace pcl {
         inline Matrix4
         getAbsoluteTransform () const;
 
-        /** \brief Reset MetaICP without resetting registration_ */
+        /** \brief Reset MetaRegistration without resetting registration_ */
         inline void
         reset ();
 
index b78aa2c75d26ee39aa6fec57eee8b6cc2cdd815f..36f10f7e33188239d37842a205ba12dd898c90fa 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/registration.h>
 #include <pcl/filters/voxel_grid_covariance.h>
index e514fe5963a909c4b6182cc257dc103e46b5ff32..8551db4fd4e3834f579f2630144e6cea806f1ea0 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/registration.h>
 
index fd0aa7d707651b3523485fbb59ff33632bb7e4f8..0275020c4c8d3a2cbb5bb4ba621523b70c3b95c9 100644 (file)
@@ -121,15 +121,15 @@ namespace pcl
 
       /** \brief Returns the angle discretization step parameter (the step value between each bin of the hash map for the angular values) */
       inline float
-      getAngleDiscretizationStep () { return angle_discretization_step_; }
+      getAngleDiscretizationStep () const { return angle_discretization_step_; }
 
       /** \brief Returns the distance discretization step parameter (the step value between each bin of the hash map for the distance values) */
       inline float
-      getDistanceDiscretizationStep () { return distance_discretization_step_; }
+      getDistanceDiscretizationStep () const { return distance_discretization_step_; }
 
       /** \brief Returns the maximum distance found between any feature pair in the given input feature cloud */
       inline float
-      getModelDiameter () { return max_dist_; }
+      getModelDiameter () const { return max_dist_; }
 
       std::vector <std::vector <float> > alpha_m_;
     private:
index cf8ede47c3aa84e5282f0165a5ca7f1ab3b107bf..ab77ded7bdf674d5740986a8c10bdd62d86cf15a 100644 (file)
@@ -43,6 +43,7 @@
 // PCL includes
 #include <pcl/pcl_base.h>
 #include <pcl/common/transforms.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/search/kdtree.h>
 #include <pcl/registration/boost.h>
@@ -608,6 +609,19 @@ namespace pcl
     private:
       /** \brief The point representation used (internal). */
       PointRepresentationConstPtr point_representation_;
+
+      /**
+       * \brief Remove from public API in favor of \ref setInputSource
+       *
+       * Still gives the correct result (with a warning)
+       */
+      void setInputCloud (const PointCloudSourceConstPtr &cloud) override
+      {
+          PCL_WARN ("[pcl::registration::Registration] setInputCloud is deprecated."
+                    "Please use setInputSource instead.\n");
+          setInputSource (cloud);
+      }
+
     public:
       PCL_MAKE_ALIGNED_OPERATOR_NEW
    };
index 21c29a85945c2c6ebe7c72d770f3731f34f4826a..067784868f7d2f2684dd2bf128054625b57da005 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/transformation_estimation.h>
 #include <pcl/registration/warp_point_rigid.h>
index 165812b805dbbe84e5e346141a9304bee0d46fd3..4430702beb07f939d97789db3186b790a2553cda 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/transformation_estimation_point_to_plane.h>
 #include <pcl/registration/warp_point_rigid.h>
index 8db6f187519c73b9cecf5044df87092ffd1a6193..f70bdc780f7919e662c7cb06d642218f42469208 100644 (file)
@@ -48,7 +48,7 @@ namespace pcl
     /** \brief @b TransformationEstimationSymmetricPointToPlaneLLS implements a Linear Least Squares (LLS) approximation
       * for minimizing the symmetric point-to-plane distance between two clouds of corresponding points with normals.
       *
-      * For additional details, see 
+      * For additional details, see
       *   "Linear Least-Squares Optimization for Point-to-Plane ICP Surface Registration", Kok-Lim Low, 2004
       *   "A Symmetric Objective Function for ICP", Szymon Rusinkiewicz, 2019
       *
@@ -66,7 +66,7 @@ namespace pcl
 
         using Matrix4 = typename TransformationEstimation<PointSource, PointTarget, Scalar>::Matrix4;
         using Vector6 = Eigen::Matrix<Scalar, 6, 1>;
-        
+
         TransformationEstimationSymmetricPointToPlaneLLS () : enforce_same_direction_normals_ (true) {};
         ~TransformationEstimationSymmetricPointToPlaneLLS () {};
 
@@ -127,25 +127,25 @@ namespace pcl
         */
         inline void
         setEnforceSameDirectionNormals (bool enforce_same_direction_normals);
-        
+
         /** \brief Obtain whether source or target normals are negated on a per-point basis such that they point in the same direction or not */
         inline bool
         getEnforceSameDirectionNormals ();
 
       protected:
-        
+
         /** \brief Estimate a rigid rotation transformation between a source and a target
           * \param[in] source_it an iterator over the source point cloud dataset
           * \param[in] target_it an iterator over the target point cloud dataset
           * \param[out] transformation_matrix the resultant transformation matrix
           */
-        void 
-        estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it, 
-                                     ConstCloudIterator<PointTarget>& target_it, 
+        void
+        estimateRigidTransformation (ConstCloudIterator<PointSource>& source_it,
+                                     ConstCloudIterator<PointTarget>& target_it,
                                      Matrix4 &transformation_matrix) const;
 
         /** \brief Construct a 4 by 4 transformation matrix from the provided rotation and translation.
-          * \param[in] (alpha, beta, gamma, tx, ty, tz) specifying rotation about the x, y, and z-axis and translation along the the x, y, and z-axis respectively
+          * \param[in] parameters (alpha, beta, gamma, tx, ty, tz) specifying rotation about the x, y, and z-axis and translation along the the x, y, and z-axis respectively
           * \param[out] transformation_matrix the resultant transformation matrix
           */
         inline void
index 838f6044c2a072d5c2cb3f95946392372c346216..5d2cb4ad97a95d39f0482c98adc18cae27a1440d 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_representation.h>
 #include <pcl/search/kdtree.h>
index c96626c419389ac907fd6832117fd34008a83da5..6c1a76d407616743a855aaa070ae24c1eb0cc2ce 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/registration/eigen.h>
 
index bdf4400bd1660cb46d277c863144305ccb7f1fef..7b23e855b3ba1fc02febe0281ab2ac62e2645a69 100644 (file)
  */
 
 #include <pcl/registration/correspondence_rejection_organized_boundary.h>
+#include <pcl/memory.h>  // for static_pointer_cast
+
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
 pcl::registration::CorrespondenceRejectionOrganizedBoundary::getRemainingCorrespondences (const pcl::Correspondences& original_correspondences,
                                                                                           pcl::Correspondences& remaining_correspondences)
 {
-  pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud = boost::static_pointer_cast<pcl::registration::DataContainer<pcl::PointXYZ, pcl::PointNormal> >(data_container_)->getInputTarget ();
+  pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud = static_pointer_cast<pcl::registration::DataContainer<pcl::PointXYZ, pcl::PointNormal> >(data_container_)->getInputTarget ();
 
   if (!cloud->isOrganized ())
   {
index cc8e972c237c34e556d85e605d5cb4b93dc0f102..50e6e3a3fefa3c1b46a914a04044ead192613102 100644 (file)
@@ -79,7 +79,7 @@ pcl::registration::CorrespondenceRejectorVarTrimmed::getRemainingCorrespondences
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 float
-pcl::registration::CorrespondenceRejectorVarTrimmed::optimizeInlierRatio (std::vector <double>&  dists)
+pcl::registration::CorrespondenceRejectorVarTrimmed::optimizeInlierRatio (std::vector <double>&  dists) const
 {
   unsigned int points_nbr = static_cast<unsigned int> (dists.size ());
   std::sort (dists.begin (), dists.end ());
index 91a13895c65a8ea4c036ac91517450cf38d36ccb..aaee37f2f9b0b64a570f491bb91800f8a63be26e 100644 (file)
@@ -38,6 +38,8 @@
 
 #include <pcl/registration/gicp6d.h>
 
+#include <pcl/memory.h>  // for pcl::make_shared
+
 namespace pcl
 {
   // convert sRGB to CIELAB
@@ -160,7 +162,7 @@ namespace pcl
     // ...and build 6d-tree
     target_tree_lab_.setInputCloud (target_lab_);
     target_tree_lab_.setPointRepresentation (
-        boost::make_shared<MyPointRepresentation> (point_rep_));
+        pcl::make_shared<MyPointRepresentation> (point_rep_));
   }
 
   bool
index dd4809ee31e47278e0c7ff4d0e4780c26045296f..3816cdebd8f864fee85dd90f1fc85d3fb7d2a500 100644 (file)
@@ -57,23 +57,24 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
   iterations_ = 0;
   double d_best_penalty = std::numeric_limits<double>::max();
 
-  std::vector<int> selection;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
   std::vector<double> distances;
 
-  int n_inliers_count = 0;
-
   unsigned skipped_count = 0;
   // suppress infinite loops by just allowing 10 x maximum allowed iterations for invalid model parameters!
   const unsigned max_skip = max_iterations_ * 10;
   
   // Iterate
-  while (iterations_ < max_iterations_ && skipped_count < max_skip)
+  while ((iterations_ < max_iterations_) && (skipped_count < max_skip))
   {
     // Get X samples which satisfy the model criteria
     sac_model_->getSamples (iterations_, selection);
 
-    if (selection.empty ()) break;
+    if (selection.empty ())
+    {
+      break;
+    }
 
     // Search for inliers in the point cloud for the current plane model M
     if (!sac_model_->computeModelCoefficients (selection, model_coefficients))
@@ -83,7 +84,7 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
       continue;
     }
 
-    double d_cur_penalty = 0;
+    double d_cur_penalty;
     // d_cur_penalty = sum (min (dist, threshold))
 
     // Iterate through the 3d points and calculate the distances from them to the model
@@ -96,11 +97,14 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
       ++skipped_count;
       continue;
     }
+    // Move all NaNs in distances to the end
+    const auto new_end = (sac_model_->getInputCloud()->is_dense ? distances.end() : std::partition (distances.begin(), distances.end(), [](double d){return !std::isnan (d);}));
+    const auto nr_valid_dists = std::distance (distances.begin (), new_end);
 
-    std::sort (distances.begin (), distances.end ());
     // d_cur_penalty = median (distances)
-    std::size_t mid = sac_model_->getIndices ()->size () / 2;
-    if (mid >= distances.size ())
+    const std::size_t mid = nr_valid_dists / 2;
+    PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] There are %lu valid distances remaining after removing NaN values.\n", nr_valid_dists);
+    if (nr_valid_dists == 0)
     {
       //iterations_++;
       ++skipped_count;
@@ -108,10 +112,21 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
     }
 
     // Do we have a "middle" point or should we "estimate" one ?
-    if (sac_model_->getIndices ()->size () % 2 == 0)
-      d_cur_penalty = (sqrt (distances[mid-1]) + sqrt (distances[mid])) / 2;
+    if ((nr_valid_dists % 2) == 0)
+    {
+      // Looking at two values instead of one probably doesn't matter because they are mostly barely different, but let's do it for accuracy's sake
+      std::nth_element (distances.begin (), distances.begin () + (mid - 1), new_end);
+      const double tmp = distances[mid-1];
+      const double tmp2 = *(std::min_element (distances.begin () + mid, new_end));
+      d_cur_penalty = (sqrt (tmp) + sqrt (tmp2)) / 2.0;
+      PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] Computing median with two values (%g and %g) because number of distances is even.\n", tmp, distances[mid]);
+    }
     else
+    {
+      std::nth_element (distances.begin (), distances.begin () + mid, new_end);
       d_cur_penalty = sqrt (distances[mid]);
+      PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] Computing median with one value (%g) because number of distances is odd.\n", distances[mid]);
+    }
 
     // Better match ?
     if (d_cur_penalty < d_best_penalty)
@@ -125,13 +140,17 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
 
     ++iterations_;
     if (debug_verbosity_level > 1)
+    {
       PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] Trial %d out of %d. Best penalty is %f.\n", iterations_, max_iterations_, d_best_penalty);
+    }
   }
 
   if (model_.empty ())
   {
     if (debug_verbosity_level > 0)
+    {
       PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] Unable to find a solution!\n");
+    }
     return (false);
   }
 
@@ -150,7 +169,7 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
     return (false);
   }
 
-  std::vector<int> &indices = *sac_model_->getIndices ();
+  Indices &indices = *sac_model_->getIndices ();
 
   if (distances.size () != indices.size ())
   {
@@ -160,16 +179,22 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
 
   inliers_.resize (distances.size ());
   // Get the inliers for the best model found
-  n_inliers_count = 0;
+  std::size_t n_inliers_count = 0;
   for (std::size_t i = 0; i < distances.size (); ++i)
+  {
     if (distances[i] <= threshold_)
+    {
       inliers_[n_inliers_count++] = indices[i];
+    }
+  }
 
   // Resize the inliers vector
   inliers_.resize (n_inliers_count);
 
   if (debug_verbosity_level > 0)
-    PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] Model: %lu size, %d inliers.\n", model_.size (), n_inliers_count);
+  {
+    PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] Model: %lu size, %lu inliers.\n", model_.size (), n_inliers_count);
+  }
 
   return (true);
 }
@@ -177,4 +202,3 @@ pcl::LeastMedianSquares<PointT>::computeModel (int debug_verbosity_level)
 #define PCL_INSTANTIATE_LeastMedianSquares(T) template class PCL_EXPORTS pcl::LeastMedianSquares<T>;
 
 #endif    // PCL_SAMPLE_CONSENSUS_IMPL_LMEDS_H_
-
index 0a2ba2934cb716d5becaffb3267a295efb0e913f..15a4137a9f72ed7a46d0f60bc04e30d55c7d4a7a 100644 (file)
@@ -59,7 +59,7 @@ pcl::MaximumLikelihoodSampleConsensus<PointT>::computeModel (int debug_verbosity
   double d_best_penalty = std::numeric_limits<double>::max();
   double k = 1.0;
 
-  std::vector<int> selection;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
   std::vector<double> distances;
 
@@ -178,7 +178,7 @@ pcl::MaximumLikelihoodSampleConsensus<PointT>::computeModel (int debug_verbosity
 
   // Iterate through the 3d points and calculate the distances from them to the model again
   sac_model_->getDistancesToModel (model_coefficients_, distances);
-  std::vector<int> &indices = *sac_model_->getIndices ();
+  Indices &indices = *sac_model_->getIndices ();
   if (distances.size () != indices.size ())
   {
     PCL_ERROR ("[pcl::MaximumLikelihoodSampleConsensus::computeModel] Estimated distances (%lu) differs than the normal of indices (%lu).\n", distances.size (), indices.size ());
index dd2ed9f286ba3fe799012d8f6b5e050bc6aa2257..4dcac5b8003cae8eb90d4e17aea4e10d42005754 100644 (file)
@@ -58,7 +58,7 @@ pcl::MEstimatorSampleConsensus<PointT>::computeModel (int debug_verbosity_level)
   double d_best_penalty = std::numeric_limits<double>::max();
   double k = 1.0;
 
-  std::vector<int> selection;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
   std::vector<double> distances;
 
@@ -136,7 +136,7 @@ pcl::MEstimatorSampleConsensus<PointT>::computeModel (int debug_verbosity_level)
 
   // Iterate through the 3d points and calculate the distances from them to the model again
   sac_model_->getDistancesToModel (model_coefficients_, distances);
-  std::vector<int> &indices = *sac_model_->getIndices ();
+  Indices &indices = *sac_model_->getIndices ();
 
   if (distances.size () != indices.size ())
   {
index 41c08ce56ea4af7ce39186fe718a77bc23e08126..9ab7540bda1c054d27e7c42972dd55267b5a1622 100644 (file)
@@ -82,12 +82,12 @@ pcl::ProgressiveSampleConsensus<PointT>::computeModel (int debug_verbosity_level
   // Initialize the usual RANSAC parameters
   iterations_ = 0;
 
-  std::vector<int> inliers;
-  std::vector<int> selection;
+  Indices inliers;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
 
   // We will increase the pool so the indices_ vector can only contain m elements at first
-  std::vector<int> index_pool;
+  Indices index_pool;
   index_pool.reserve (N);
   for (unsigned int i = 0; i < n; ++i)
     index_pool.push_back (sac_model_->indices_->operator[](i));
@@ -164,8 +164,7 @@ pcl::ProgressiveSampleConsensus<PointT>::computeModel (int debug_verbosity_level
 
       // We only need to compute possible better epsilon_n_star for when _n is just about to be removed an inlier
       std::size_t I_possible_n_star = I_N;
-      for (std::vector<int>::const_reverse_iterator last_inlier = inliers.rbegin (), 
-                                                    inliers_end = inliers.rend (); 
+      for (auto last_inlier = inliers.crbegin (), inliers_end = inliers.crend ();
            last_inlier != inliers_end; 
            ++last_inlier, --I_possible_n_star)
       {
index 6cf00feb2c057d09ca5d5ec4e81add58f9336974..ae33dbcde656110d2295e7f3785a04e0c74515d6 100644 (file)
@@ -67,7 +67,7 @@ pcl::RandomSampleConsensus<PointT>::computeModel (int)
   std::size_t n_best_inliers_count = 0;
   double k = std::numeric_limits<double>::max();
 
-  std::vector<int> selection;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
 
   const double log_probability  = std::log (1.0 - probability_);
index 50c940250d47b8c7075f66e485e7825fae53f4d2..ff25956c5332b3ad61461d66e63a494d08d41652 100644 (file)
@@ -58,10 +58,10 @@ pcl::RandomizedMEstimatorSampleConsensus<PointT>::computeModel (int debug_verbos
   double d_best_penalty = std::numeric_limits<double>::max();
   double k = 1.0;
 
-  std::vector<int> selection;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
   std::vector<double> distances;
-  std::set<int> indices_subset;
+  std::set<index_t> indices_subset;
 
   int n_inliers_count = 0;
   unsigned skipped_count = 0;
@@ -154,7 +154,7 @@ pcl::RandomizedMEstimatorSampleConsensus<PointT>::computeModel (int debug_verbos
 
   // Iterate through the 3d points and calculate the distances from them to the model again
   sac_model_->getDistancesToModel (model_coefficients_, distances);
-  std::vector<int> &indices = *sac_model_->getIndices ();
+  Indices &indices = *sac_model_->getIndices ();
   if (distances.size () != indices.size ())
   {
     PCL_ERROR ("[pcl::RandomizedMEstimatorSampleConsensus::computeModel] Estimated distances (%lu) differs than the normal of indices (%lu).\n", distances.size (), indices.size ());
index 7a839ff8387d8dc7b77b3ed809642395f60c7b59..0e952f0855f17bd1d79980c16622ea8246e37ea4 100644 (file)
@@ -58,9 +58,9 @@ pcl::RandomizedRandomSampleConsensus<PointT>::computeModel (int debug_verbosity_
   std::size_t n_best_inliers_count = 0;
   double k = std::numeric_limits<double>::max();
 
-  std::vector<int> selection;
+  Indices selection;
   Eigen::VectorXf model_coefficients;
-  std::set<int> indices_subset;
+  std::set<index_t> indices_subset;
 
   const double log_probability  = std::log (1.0 - probability_);
   const double one_over_indices = 1.0 / static_cast<double> (sac_model_->getIndices ()->size ());
index 9ba524a8093f09f5cd737ccb14d279c673d15510..1900088f28022c5c92c34d71407e333249965441 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelCircle2D<PointT>::isSampleGood(const std::vector<int> &samples) const
+pcl::SampleConsensusModelCircle2D<PointT>::isSampleGood(const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   // Get the values at the two points
   Eigen::Array2d p0 (input_->points[samples[0]].x, input_->points[samples[0]].y);
   Eigen::Array2d p1 (input_->points[samples[1]].x, input_->points[samples[1]].y);
@@ -66,16 +71,16 @@ pcl::SampleConsensusModelCircle2D<PointT>::isSampleGood(const std::vector<int> &
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelCircle2D<PointT>::computeModelCoefficients (const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+pcl::SampleConsensusModelCircle2D<PointT>::computeModelCoefficients (const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 3 samples
-  if (samples.size () != 3)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
   }
 
-  model_coefficients.resize (3);
+  model_coefficients.resize (model_size_);
 
   Eigen::Vector2d p0 (input_->points[samples[0]].x, input_->points[samples[0]].y);
   Eigen::Vector2d p1 (input_->points[samples[1]].x, input_->points[samples[1]].y);
@@ -129,7 +134,7 @@ pcl::SampleConsensusModelCircle2D<PointT>::getDistancesToModel (const Eigen::Vec
 template <typename PointT> void
 pcl::SampleConsensusModelCircle2D<PointT>::selectWithinDistance (
     const Eigen::VectorXf &model_coefficients, const double threshold, 
-    std::vector<int> &inliers)
+    Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -137,9 +142,10 @@ pcl::SampleConsensusModelCircle2D<PointT>::selectWithinDistance (
     inliers.clear ();
     return;
   }
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Iterate through the 3d points and calculate the distances from them to the circle
   for (std::size_t i = 0; i < indices_->size (); ++i)
@@ -156,13 +162,10 @@ pcl::SampleConsensusModelCircle2D<PointT>::selectWithinDistance (
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = static_cast<double> (distance);
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (static_cast<double> (distance));
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -196,21 +199,21 @@ pcl::SampleConsensusModelCircle2D<PointT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelCircle2D<PointT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   optimized_coefficients = model_coefficients;
 
   // Needs a set of valid model coefficients
-  if (model_coefficients.size () != 3)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] Given model is invalid!\n");
     return;
   }
 
-  // Need at least 3 samples
-  if (inliers.size () <= 3)
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] Not enough inliers found to support a model (%lu)! Returning the same coefficients.\n", inliers.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     return;
   }
 
@@ -227,13 +230,13 @@ pcl::SampleConsensusModelCircle2D<PointT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelCircle2D<PointT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients,
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients,
       PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != 3)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::projectPoints] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::projectPoints] Given model is invalid!\n");
     return;
   }
 
@@ -255,7 +258,7 @@ pcl::SampleConsensusModelCircle2D<PointT>::projectPoints (
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
 
     // Iterate through the points and project them to the circle
-    for (const int &inlier : inliers)
+    for (const auto &inlier : inliers)
     {
       float dx = input_->points[inlier].x - model_coefficients[0];
       float dy = input_->points[inlier].y - model_coefficients[1];
@@ -294,16 +297,16 @@ pcl::SampleConsensusModelCircle2D<PointT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelCircle2D<PointT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid model coefficients
-  if (model_coefficients.size () != 3)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::doSamplesVerifyModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle2D::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
   }
 
-  for (const int &index : indices)
+  for (const auto &index : indices)
     // Calculate the distance from the point to the circle as the difference between
     //dist(point,circle_origin) and circle_radius
     if (std::abs (std::sqrt (
index 4273a890102c66f0077f9d819b500d57d5fc9945..781758c61bb0293ee26d8cfea3a24fe9ad8cdfa9 100644 (file)
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelCircle3D<PointT>::isSampleGood (
-    const std::vector<int> &samples) const
+    const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   // Get the values at the three points
   Eigen::Vector3d p0 (input_->points[samples[0]].x, input_->points[samples[0]].y, input_->points[samples[0]].z);
   Eigen::Vector3d p1 (input_->points[samples[1]].x, input_->points[samples[1]].y, input_->points[samples[1]].z);
@@ -62,16 +67,16 @@ pcl::SampleConsensusModelCircle3D<PointT>::isSampleGood (
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelCircle3D<PointT>::computeModelCoefficients (const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+pcl::SampleConsensusModelCircle3D<PointT>::computeModelCoefficients (const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 3 samples
-  if (samples.size () != 3)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
   }
 
-  model_coefficients.resize (7);   //needing 7 coefficients: centerX, centerY, centerZ, radius, normalX, normalY, normalZ
+  model_coefficients.resize (model_size_);   //needing 7 coefficients: centerX, centerY, centerZ, radius, normalX, normalY, normalZ
 
   Eigen::Vector3d p0 (input_->points[samples[0]].x, input_->points[samples[0]].y, input_->points[samples[0]].z);
   Eigen::Vector3d p1 (input_->points[samples[1]].x, input_->points[samples[1]].y, input_->points[samples[1]].z);
@@ -161,7 +166,7 @@ pcl::SampleConsensusModelCircle3D<PointT>::getDistancesToModel (const Eigen::Vec
 template <typename PointT> void
 pcl::SampleConsensusModelCircle3D<PointT>::selectWithinDistance (
     const Eigen::VectorXf &model_coefficients, const double threshold,
-    std::vector<int> &inliers)
+    Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -169,8 +174,8 @@ pcl::SampleConsensusModelCircle3D<PointT>::selectWithinDistance (
     inliers.clear ();
     return;
   }
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
+  inliers.clear ();
+  inliers.reserve (indices_->size ());
 
   // Iterate through the 3d points and calculate the distances from them to the sphere
   for (std::size_t i = 0; i < indices_->size (); ++i)
@@ -199,11 +204,9 @@ pcl::SampleConsensusModelCircle3D<PointT>::selectWithinDistance (
     if (distanceVector.norm () < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      nr_p++;
+      inliers.push_back ((*indices_)[i]);
     }
   }
-  inliers.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -250,23 +253,23 @@ pcl::SampleConsensusModelCircle3D<PointT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelCircle3D<PointT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers,
+      const Indices &inliers,
       const Eigen::VectorXf &model_coefficients,
       Eigen::VectorXf &optimized_coefficients) const
 {
   optimized_coefficients = model_coefficients;
 
   // Needs a set of valid model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::optimizeModelCoefficients] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::optimizeModelCoefficients] Given model is invalid!\n");
     return;
   }
 
-  // Need at least 3 samples
-  if (inliers.size () <= 3)
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::optimizeModelCoefficients] Not enough inliers found to support a model (%lu)! Returning the same coefficients.\n", inliers.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     return;
   }
 
@@ -286,13 +289,13 @@ pcl::SampleConsensusModelCircle3D<PointT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelCircle3D<PointT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients,
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients,
       PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::projectPoints] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::projectPoints] Given model is invalid!\n");
     return;
   }
 
@@ -388,18 +391,18 @@ pcl::SampleConsensusModelCircle3D<PointT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelCircle3D<PointT>::doSamplesVerifyModel (
-      const std::set<int> &indices,
+      const std::set<index_t> &indices,
       const Eigen::VectorXf &model_coefficients,
       const double threshold) const
 {
   // Needs a valid model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::doSamplesVerifyModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
   }
 
-  for (const int &index : indices)
+  for (const auto &index : indices)
   {
     // Calculate the distance from the point to the sphere as the difference between
     //dist(point,sphere_origin) and sphere_radius
index dabe69c0dd77c42e39a5279b45ac32ddc8b018b6..6d52c254b19ac340a7713cf60ff0c5da6a2a596d 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> bool
-pcl::SampleConsensusModelCone<PointT, PointNT>::isSampleGood(const std::vector<int> &) const
+pcl::SampleConsensusModelCone<PointT, PointNT>::isSampleGood(const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelCone::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   return (true);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> bool
 pcl::SampleConsensusModelCone<PointT, PointNT>::computeModelCoefficients (
-    const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+    const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 3 samples
-  if (samples.size () != 3)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelCone::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
@@ -68,13 +73,13 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::computeModelCoefficients (
     return (false);
   }
 
-  Eigen::Vector4f p1 (input_->points[samples[0]].x, input_->points[samples[0]].y, input_->points[samples[0]].z, 0);
-  Eigen::Vector4f p2 (input_->points[samples[1]].x, input_->points[samples[1]].y, input_->points[samples[1]].z, 0);
-  Eigen::Vector4f p3 (input_->points[samples[2]].x, input_->points[samples[2]].y, input_->points[samples[2]].z, 0);
+  Eigen::Vector4f p1 (input_->points[samples[0]].x, input_->points[samples[0]].y, input_->points[samples[0]].z, 0.0f);
+  Eigen::Vector4f p2 (input_->points[samples[1]].x, input_->points[samples[1]].y, input_->points[samples[1]].z, 0.0f);
+  Eigen::Vector4f p3 (input_->points[samples[2]].x, input_->points[samples[2]].y, input_->points[samples[2]].z, 0.0f);
 
-  Eigen::Vector4f n1 (normals_->points[samples[0]].normal[0], normals_->points[samples[0]].normal[1], normals_->points[samples[0]].normal[2], 0);
-  Eigen::Vector4f n2 (normals_->points[samples[1]].normal[0], normals_->points[samples[1]].normal[1], normals_->points[samples[1]].normal[2], 0);
-  Eigen::Vector4f n3 (normals_->points[samples[2]].normal[0], normals_->points[samples[2]].normal[1], normals_->points[samples[2]].normal[2], 0);
+  Eigen::Vector4f n1 (normals_->points[samples[0]].normal[0], normals_->points[samples[0]].normal[1], normals_->points[samples[0]].normal[2], 0.0f);
+  Eigen::Vector4f n2 (normals_->points[samples[1]].normal[0], normals_->points[samples[1]].normal[1], normals_->points[samples[1]].normal[2], 0.0f);
+  Eigen::Vector4f n3 (normals_->points[samples[2]].normal[0], normals_->points[samples[2]].normal[1], normals_->points[samples[2]].normal[2], 0.0f);
 
   //calculate apex (intersection of the three planes defined by points and belonging normals
   Eigen::Vector4f ortho12 = n1.cross3(n2);
@@ -112,7 +117,7 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::computeModelCoefficients (
   //compute opening angle
   float opening_angle = ( std::acos (ap1.dot (axis_dir)) + std::acos (ap2.dot (axis_dir)) + std::acos (ap3.dot (axis_dir)) ) / 3.0f;
 
-  model_coefficients.resize (7);
+  model_coefficients.resize (model_size_);
   // model_coefficients.template head<3> ()    = line_pt.template head<3> ();
   model_coefficients[0] = apex[0];
   model_coefficients[1] = apex[1];
@@ -146,8 +151,8 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::getDistancesToModel (
 
   distances.resize (indices_->size ());
 
-  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float opening_angle = model_coefficients[6];
 
   float apexdotdir = apex.dot (axis_dir);
@@ -155,8 +160,8 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::getDistancesToModel (
   // Iterate through the 3d points and calculate the distances from them to the cone
   for (std::size_t i = 0; i  < indices_->size (); ++i)
   {
-    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
-    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
+    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0.0f);
+    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0.0f);
 
     // Calculate the point's projection on the cone axis
     float k = (pt.dot (axis_dir) - apexdotdir) * dirdotdir;
@@ -180,14 +185,14 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::getDistancesToModel (
     double d_normal = std::abs (getAngle3D (n, cone_normal));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    distances[i] = std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid);
+    distances[i] = std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid);
   }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCone<PointT, PointNT>::selectWithinDistance (
-    const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+    const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -196,12 +201,13 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::selectWithinDistance (
     return;
   }
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
-  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float opening_angle = model_coefficients[6];
 
   float apexdotdir = apex.dot (axis_dir);
@@ -209,8 +215,8 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::selectWithinDistance (
   // Iterate through the 3d points and calculate the distances from them to the cone
   for (std::size_t i = 0; i < indices_->size (); ++i)
   {
-    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
-    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
+    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0.0f);
+    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0.0f);
 
     // Calculate the point's projection on the cone axis
     float k = (pt.dot (axis_dir) - apexdotdir) * dirdotdir;
@@ -236,18 +242,15 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::selectWithinDistance (
     double d_normal = std::abs (getAngle3D (n, cone_normal));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    double distance = std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid);
+    double distance = std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid);
     
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = distance;
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (distance);
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -262,8 +265,8 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::countWithinDistance (
 
   std::size_t nr_p = 0;
 
-  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float opening_angle = model_coefficients[6];
 
   float apexdotdir = apex.dot (axis_dir);
@@ -271,8 +274,8 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::countWithinDistance (
   // Iterate through the 3d points and calculate the distances from them to the cone
   for (std::size_t i = 0; i < indices_->size (); ++i)
   {
-    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
-    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
+    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0.0f);
+    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0.0f);
 
     // Calculate the point's projection on the cone axis
     float k = (pt.dot (axis_dir) - apexdotdir) * dirdotdir;
@@ -298,7 +301,7 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::countWithinDistance (
     double d_normal = std::abs (getAngle3D (n, cone_normal));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    if (std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
+    if (std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid) < threshold)
       nr_p++;
   }
   return (nr_p);
@@ -307,20 +310,21 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCone<PointT, PointNT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   optimized_coefficients = model_coefficients;
 
   // Needs a set of valid model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCone::optimizeModelCoefficients] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCone::optimizeModelCoefficients] Given model is invalid!\n");
     return;
   }
 
-  if (inliers.empty ())
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_DEBUG ("[pcl::SampleConsensusModelCone:optimizeModelCoefficients] Inliers vector empty! Returning the same coefficients.\n");
+    PCL_ERROR ("[pcl::SampleConsensusModelCone:optimizeModelCoefficients] Not enough inliers found to optimize model coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     return;
   }
 
@@ -344,20 +348,20 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCone<PointT, PointNT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCone::projectPoints] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCone::projectPoints] Given model is invalid!\n");
     return;
   }
 
   projected_points.header = input_->header;
   projected_points.is_dense = input_->is_dense;
 
-  Eigen::Vector4f apex  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f apex  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float opening_angle = model_coefficients[6];
 
   float apexdotdir = apex.dot (axis_dir);
@@ -378,7 +382,7 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::projectPoints (
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
 
     // Iterate through the 3d points and calculate the distances from them to the cone
-    for (const int &inlier : inliers)
+    for (const auto &inlier : inliers)
     {
       Eigen::Vector4f pt (input_->points[inlier].x, 
                           input_->points[inlier].y, 
@@ -440,26 +444,26 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> bool
 pcl::SampleConsensusModelCone<PointT, PointNT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCone::doSamplesVerifyModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCone::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
   }
 
-  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f apex (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float openning_angle = model_coefficients[6];
 
   float apexdotdir = apex.dot (axis_dir);
   float dirdotdir = 1.0f / axis_dir.dot (axis_dir);
 
   // Iterate through the 3d points and calculate the distances from them to the cone
-  for (const int &index : indices)
+  for (const auto &index : indices)
   {
-    Eigen::Vector4f pt (input_->points[index].x, input_->points[index].y, input_->points[index].z, 0);
+    Eigen::Vector4f pt (input_->points[index].x, input_->points[index].y, input_->points[index].z, 0.0f);
 
     // Calculate the point's projection on the cone axis
     float k = (pt.dot (axis_dir) - apexdotdir) * dirdotdir;
@@ -485,8 +489,8 @@ template <typename PointT, typename PointNT> double
 pcl::SampleConsensusModelCone<PointT, PointNT>::pointToAxisDistance (
       const Eigen::Vector4f &pt, const Eigen::VectorXf &model_coefficients) const
 {
-  Eigen::Vector4f apex  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f apex  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f axis_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   return sqrt(pcl::sqrPointToLineDistance (pt, apex, axis_dir));
 }
 
@@ -501,14 +505,9 @@ pcl::SampleConsensusModelCone<PointT, PointNT>::isModelValid (const Eigen::Vecto
   if (eps_angle_ > 0.0)
   {
     // Obtain the cone direction
-    Eigen::Vector4f coeff;
-    coeff[0] = model_coefficients[3];
-    coeff[1] = model_coefficients[4];
-    coeff[2] = model_coefficients[5];
-    coeff[3] = 0;
-
-    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0);
-    double angle_diff = std::abs (getAngle3D (axis, coeff));
+    const Eigen::Vector3f coeff(model_coefficients[3], model_coefficients[4], model_coefficients[5]);
+
+    double angle_diff = std::abs (getAngle3D (axis_, coeff));
     angle_diff = (std::min) (angle_diff, M_PI - angle_diff);
     // Check whether the current cone model satisfies our angle threshold criterion with respect to the given axis
     if (angle_diff > eps_angle_)
index 733f8d7f0c19d9f226a8993a81f69b42793a486e..10e32744c3427e4f5b45b035bbdcb947302247da 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> bool
-pcl::SampleConsensusModelCylinder<PointT, PointNT>::isSampleGood (const std::vector<int> &) const
+pcl::SampleConsensusModelCylinder<PointT, PointNT>::isSampleGood (const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   return (true);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> bool
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::computeModelCoefficients (
-      const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+      const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 2 samples
-  if (samples.size () != 2)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelCylinder::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
@@ -77,11 +82,11 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::computeModelCoefficients (
     return (false);
   }
   
-  Eigen::Vector4f p1 (input_->points[samples[0]].x, input_->points[samples[0]].y, input_->points[samples[0]].z, 0);
-  Eigen::Vector4f p2 (input_->points[samples[1]].x, input_->points[samples[1]].y, input_->points[samples[1]].z, 0);
+  Eigen::Vector4f p1 (input_->points[samples[0]].x, input_->points[samples[0]].y, input_->points[samples[0]].z, 0.0f);
+  Eigen::Vector4f p2 (input_->points[samples[1]].x, input_->points[samples[1]].y, input_->points[samples[1]].z, 0.0f);
 
-  Eigen::Vector4f n1 (normals_->points[samples[0]].normal[0], normals_->points[samples[0]].normal[1], normals_->points[samples[0]].normal[2], 0);
-  Eigen::Vector4f n2 (normals_->points[samples[1]].normal[0], normals_->points[samples[1]].normal[1], normals_->points[samples[1]].normal[2], 0);
+  Eigen::Vector4f n1 (normals_->points[samples[0]].normal[0], normals_->points[samples[0]].normal[1], normals_->points[samples[0]].normal[2], 0.0f);
+  Eigen::Vector4f n2 (normals_->points[samples[1]].normal[0], normals_->points[samples[1]].normal[1], normals_->points[samples[1]].normal[2], 0.0f);
   Eigen::Vector4f w = n1 + p1 - p2;
 
   float a = n1.dot (n1);
@@ -108,7 +113,7 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::computeModelCoefficients (
   Eigen::Vector4f line_dir = p2 + tc * n2 - line_pt;
   line_dir.normalize ();
 
-  model_coefficients.resize (7);
+  model_coefficients.resize (model_size_);
   // model_coefficients.template head<3> ()    = line_pt.template head<3> ();
   model_coefficients[0] = line_pt[0];
   model_coefficients[1] = line_pt[1];
@@ -140,8 +145,8 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::getDistancesToModel (
 
   distances.resize (indices_->size ());
 
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float ptdotdir = line_pt.dot (line_dir);
   float dirdotdir = 1.0f / line_dir.dot (line_dir);
   // Iterate through the 3d points and calculate the distances from them to the sphere
@@ -150,8 +155,8 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::getDistancesToModel (
     // Approximate the distance from the point to the cylinder as the difference between
     // dist(point,cylinder_axis) and cylinder radius
     // @note need to revise this.
-    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
-    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
+    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0.0f);
+    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0.0f);
 
     double d_euclid = std::abs (pointToLineDistance (pt, model_coefficients) - model_coefficients[6]);
 
@@ -165,14 +170,14 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::getDistancesToModel (
     double d_normal = std::abs (getAngle3D (n, dir));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    distances[i] = std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid);
+    distances[i] = std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid);
   }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -181,12 +186,13 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::selectWithinDistance (
     return;
   }
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float ptdotdir = line_pt.dot (line_dir);
   float dirdotdir = 1.0f / line_dir.dot (line_dir);
   // Iterate through the 3d points and calculate the distances from them to the sphere
@@ -194,8 +200,8 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::selectWithinDistance (
   {
     // Approximate the distance from the point to the cylinder as the difference between
     // dist(point,cylinder_axis) and cylinder radius
-    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
-    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
+    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0.0f);
+    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0.0f);
     double d_euclid = std::abs (pointToLineDistance (pt, model_coefficients) - model_coefficients[6]);
 
     // Calculate the point's projection on the cylinder axis
@@ -208,17 +214,14 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::selectWithinDistance (
     double d_normal = std::abs (getAngle3D (n, dir));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    double distance = std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid); 
+    double distance = std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid);
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = distance;
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (distance);
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -241,8 +244,8 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::countWithinDistance (
   {
     // Approximate the distance from the point to the cylinder as the difference between
     // dist(point,cylinder_axis) and cylinder radius
-    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
-    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
+    Eigen::Vector4f pt (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0.0f);
+    Eigen::Vector4f n  (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0.0f);
     double d_euclid = std::abs (pointToLineDistance (pt, model_coefficients) - model_coefficients[6]);
 
     // Calculate the point's projection on the cylinder axis
@@ -255,7 +258,7 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::countWithinDistance (
     double d_normal = std::abs (getAngle3D (n, dir));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    if (std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
+    if (std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid) < threshold)
       nr_p++;
   }
   return (nr_p);
@@ -264,20 +267,21 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   optimized_coefficients = model_coefficients;
 
   // Needs a set of valid model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::optimizeModelCoefficients] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::optimizeModelCoefficients] Given model is invalid!\n");
     return;
   }
 
-  if (inliers.empty ())
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_DEBUG ("[pcl::SampleConsensusModelCylinder:optimizeModelCoefficients] Inliers vector empty! Returning the same coefficients.\n"); 
+    PCL_ERROR ("[pcl::SampleConsensusModelCylinder:optimizeModelCoefficients] Not enough inliers found to optimize model coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     return;
   }
 
@@ -301,20 +305,20 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::projectPoints] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::projectPoints] Given model is invalid!\n");
     return;
   }
 
   projected_points.header = input_->header;
   projected_points.is_dense = input_->is_dense;
 
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   float ptdotdir = line_pt.dot (line_dir);
   float dirdotdir = 1.0f / line_dir.dot (line_dir);
 
@@ -333,7 +337,7 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::projectPoints (
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
 
     // Iterate through the 3d points and calculate the distances from them to the cylinder
-    for (const int &inlier : inliers)
+    for (const auto &inlier : inliers)
     {
       Eigen::Vector4f p (input_->points[inlier].x,
                          input_->points[inlier].y,
@@ -387,21 +391,21 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> bool
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid model coefficients
-  if (model_coefficients.size () != 7)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::doSamplesVerifyModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelCylinder::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
   }
 
-  for (const int &index : indices)
+  for (const auto &index : indices)
   {
     // Approximate the distance from the point to the cylinder as the difference between
     // dist(point,cylinder_axis) and cylinder radius
     // @note need to revise this.
-    Eigen::Vector4f pt (input_->points[index].x, input_->points[index].y, input_->points[index].z, 0);
+    Eigen::Vector4f pt (input_->points[index].x, input_->points[index].y, input_->points[index].z, 0.0f);
     if (std::abs (pointToLineDistance (pt, model_coefficients) - model_coefficients[6]) > threshold)
       return (false);
   }
@@ -414,8 +418,8 @@ template <typename PointT, typename PointNT> double
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::pointToLineDistance (
       const Eigen::Vector4f &pt, const Eigen::VectorXf &model_coefficients) const
 {
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   return sqrt(pcl::sqrPointToLineDistance (pt, line_pt, line_dir));
 }
 
@@ -424,8 +428,8 @@ template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelCylinder<PointT, PointNT>::projectPointToCylinder (
       const Eigen::Vector4f &pt, const Eigen::VectorXf &model_coefficients, Eigen::Vector4f &pt_proj) const
 {
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
 
   float k = (pt.dot (line_dir) - line_pt.dot (line_dir)) * line_dir.dot (line_dir);
   pt_proj = line_pt + k * line_dir;
@@ -448,14 +452,9 @@ pcl::SampleConsensusModelCylinder<PointT, PointNT>::isModelValid (const Eigen::V
   if (eps_angle_ > 0.0)
   {
     // Obtain the cylinder direction
-    Eigen::Vector4f coeff;
-    coeff[0] = model_coefficients[3];
-    coeff[1] = model_coefficients[4];
-    coeff[2] = model_coefficients[5];
-    coeff[3] = 0;
-
-    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0);
-    double angle_diff = std::abs (getAngle3D (axis, coeff));
+    const Eigen::Vector3f coeff(model_coefficients[3], model_coefficients[4], model_coefficients[5]);
+
+    double angle_diff = std::abs (getAngle3D (axis_, coeff));
     angle_diff = (std::min) (angle_diff, M_PI - angle_diff);
     // Check whether the current cylinder model satisfies our angle threshold criterion with respect to the given axis
     if (angle_diff > eps_angle_)
index 30a1588437316b582e67dc77a91ec46e506f2c25..bd06fcefbf3bb907df4d595a5ced43395dbd76c8 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelLine<PointT>::isSampleGood (const std::vector<int> &samples) const
+pcl::SampleConsensusModelLine<PointT>::isSampleGood (const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelLine::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   // Make sure that the two sample points are not identical
   if (
       (input_->points[samples[0]].x != input_->points[samples[1]].x)
@@ -66,10 +71,10 @@ pcl::SampleConsensusModelLine<PointT>::isSampleGood (const std::vector<int> &sam
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelLine<PointT>::computeModelCoefficients (
-      const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+      const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 2 samples
-  if (samples.size () != 2)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelLine::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
@@ -82,7 +87,7 @@ pcl::SampleConsensusModelLine<PointT>::computeModelCoefficients (
     return (false);
   }
 
-  model_coefficients.resize (6);
+  model_coefficients.resize (model_size_);
   model_coefficients[0] = input_->points[samples[0]].x;
   model_coefficients[1] = input_->points[samples[0]].y;
   model_coefficients[2] = input_->points[samples[0]].z;
@@ -102,7 +107,9 @@ pcl::SampleConsensusModelLine<PointT>::getDistancesToModel (
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
+  {
     return;
+  }
 
   distances.resize (indices_->size ());
 
@@ -124,7 +131,7 @@ pcl::SampleConsensusModelLine<PointT>::getDistancesToModel (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelLine<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
@@ -132,9 +139,10 @@ pcl::SampleConsensusModelLine<PointT>::selectWithinDistance (
 
   double sqr_threshold = threshold * threshold;
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Obtain the line point and direction
   Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
@@ -151,13 +159,10 @@ pcl::SampleConsensusModelLine<PointT>::selectWithinDistance (
     if (sqr_distance < sqr_threshold)
     {
       // Returns the indices of the points whose squared distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = sqr_distance;
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (sqr_distance);
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -174,8 +179,8 @@ pcl::SampleConsensusModelLine<PointT>::countWithinDistance (
   std::size_t nr_p = 0;
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   line_dir.normalize ();
 
   // Iterate through the 3d points and calculate the distances from them to the line
@@ -194,7 +199,7 @@ pcl::SampleConsensusModelLine<PointT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelLine<PointT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
@@ -203,15 +208,15 @@ pcl::SampleConsensusModelLine<PointT>::optimizeModelCoefficients (
     return;
   }
 
-  // Need at least 2 points to estimate a line
-  if (inliers.size () <= 2)
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelLine::optimizeModelCoefficients] Not enough inliers found to support a model (%lu)! Returning the same coefficients.\n", inliers.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelLine::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     optimized_coefficients = model_coefficients;
     return;
   }
 
-  optimized_coefficients.resize (6);
+  optimized_coefficients.resize (model_size_);
 
   // Compute the 3x3 covariance matrix
   Eigen::Vector4f centroid;
@@ -235,15 +240,15 @@ pcl::SampleConsensusModelLine<PointT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelLine<PointT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid model coefficients
   if (!isModelValid (model_coefficients))
     return;
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
 
   projected_points.header = input_->header;
   projected_points.is_dense = input_->is_dense;
@@ -263,9 +268,9 @@ pcl::SampleConsensusModelLine<PointT>::projectPoints (
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
 
     // Iterate through the 3d points and calculate the distances from them to the line
-    for (const int &inlier : inliers)
+    for (const auto &inlier : inliers)
     {
-      Eigen::Vector4f pt (input_->points[inlier].x, input_->points[inlier].y, input_->points[inlier].z, 0);
+      Eigen::Vector4f pt (input_->points[inlier].x, input_->points[inlier].y, input_->points[inlier].z, 0.0f);
       // double k = (DOT_PROD_3D (points[i], p21) - dotA_B) / dotB_B;
       float k = (pt.dot (line_dir) - line_pt.dot (line_dir)) / line_dir.dot (line_dir);
 
@@ -292,7 +297,7 @@ pcl::SampleConsensusModelLine<PointT>::projectPoints (
     // Iterate through the 3d points and calculate the distances from them to the line
     for (std::size_t i = 0; i < inliers.size (); ++i)
     {
-      Eigen::Vector4f pt (input_->points[inliers[i]].x, input_->points[inliers[i]].y, input_->points[inliers[i]].z, 0);
+      Eigen::Vector4f pt (input_->points[inliers[i]].x, input_->points[inliers[i]].y, input_->points[inliers[i]].z, 0.0f);
       // double k = (DOT_PROD_3D (points[i], p21) - dotA_B) / dotB_B;
       float k = (pt.dot (line_dir) - line_pt.dot (line_dir)) / line_dir.dot (line_dir);
 
@@ -308,20 +313,20 @@ pcl::SampleConsensusModelLine<PointT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelLine<PointT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
     return (false);
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   line_dir.normalize ();
 
   double sqr_threshold = threshold * threshold;
   // Iterate through the 3d points and calculate the distances from them to the line
-  for (const int &index : indices)
+  for (const auto &index : indices)
   {
     // Calculate the distance from the point to the line
     // D = ||(P2-P1) x (P1-P0)|| / ||P2-P1|| = norm (cross (p2-p1, p2-p0)) / norm(p2-p1)
index bee55e1c4249949c3c49ed0efbad652ff1ffb521..f90662298981ae5ea0e095d735631d423b1d695d 100644 (file)
@@ -55,7 +55,7 @@ pcl::SampleConsensusModelNormalParallelPlane<PointT, PointNT>::isModelValid (con
   {
     // Obtain the plane normal
     Eigen::Vector4f coeff = model_coefficients;
-    coeff[3] = 0;
+    coeff[3] = 0.0f;
     coeff.normalize ();
 
     if (std::abs (axis_.dot (coeff)) < cos_angle_)
index e8ed669a19e82c87cce2f58c6e6e893684a36125..62fc5c41f24e961af1b4f3b4c6146f5cbe8f2624 100644 (file)
@@ -46,7 +46,7 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   if (!normals_)
   {
@@ -64,11 +64,12 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::selectWithinDistance (
 
   // Obtain the plane normal
   Eigen::Vector4f coeff = model_coefficients;
-  coeff[3] = 0;
+  coeff[3] = 0.0f;
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Iterate through the 3d points and calculate the distances from them to the plane
   for (std::size_t i = 0; i < indices_->size (); ++i)
@@ -77,8 +78,8 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::selectWithinDistance (
     const PointNT &nt = normals_->points[(*indices_)[i]];
     // Calculate the distance from the point to the plane normal as the dot product
     // D = (P-A).N/|N|
-    Eigen::Vector4f p (pt.x, pt.y, pt.z, 0);
-    Eigen::Vector4f n (nt.normal_x, nt.normal_y, nt.normal_z, 0);
+    Eigen::Vector4f p (pt.x, pt.y, pt.z, 0.0f);
+    Eigen::Vector4f n (nt.normal_x, nt.normal_y, nt.normal_z, 0.0f);
     double d_euclid = std::abs (coeff.dot (p) + model_coefficients[3]);
 
     // Calculate the angular distance between the point normal and the plane normal
@@ -92,13 +93,10 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::selectWithinDistance (
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = distance;
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (distance);
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -118,7 +116,7 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::countWithinDistance (
 
   // Obtain the plane normal
   Eigen::Vector4f coeff = model_coefficients;
-  coeff[3] = 0;
+  coeff[3] = 0.0f;
 
   std::size_t nr_p = 0;
 
@@ -129,8 +127,8 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::countWithinDistance (
     const PointNT &nt = normals_->points[(*indices_)[i]];
     // Calculate the distance from the point to the plane normal as the dot product
     // D = (P-A).N/|N|
-    Eigen::Vector4f p (pt.x, pt.y, pt.z, 0);
-    Eigen::Vector4f n (nt.normal_x, nt.normal_y, nt.normal_z, 0);
+    Eigen::Vector4f p (pt.x, pt.y, pt.z, 0.0f);
+    Eigen::Vector4f n (nt.normal_x, nt.normal_y, nt.normal_z, 0.0f);
     double d_euclid = std::abs (coeff.dot (p) + model_coefficients[3]);
 
     // Calculate the angular distance between the point normal and the plane normal
@@ -166,7 +164,7 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::getDistancesToModel (
 
   // Obtain the plane normal
   Eigen::Vector4f coeff = model_coefficients;
-  coeff[3] = 0;
+  coeff[3] = 0.0f;
 
   distances.resize (indices_->size ());
 
@@ -177,8 +175,8 @@ pcl::SampleConsensusModelNormalPlane<PointT, PointNT>::getDistancesToModel (
     const PointNT &nt = normals_->points[(*indices_)[i]];
     // Calculate the distance from the point to the plane normal as the dot product
     // D = (P-A).N/|N|
-    Eigen::Vector4f p (pt.x, pt.y, pt.z, 0);
-    Eigen::Vector4f n (nt.normal_x, nt.normal_y, nt.normal_z, 0);
+    Eigen::Vector4f p (pt.x, pt.y, pt.z, 0.0f);
+    Eigen::Vector4f n (nt.normal_x, nt.normal_y, nt.normal_z, 0.0f);
     double d_euclid = std::abs (coeff.dot (p) + model_coefficients[3]);
 
     // Calculate the angular distance between the point normal and the plane normal
index c33f06494d9e124c3bd4c5b1963088c7ed2d68a9..8b82c62f919c160590988a1547b9d4dcfb19228a 100644 (file)
@@ -46,7 +46,7 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename PointNT> void
 pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   if (!normals_)
   {
@@ -64,11 +64,12 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::selectWithinDistance (
 
   // Obtain the sphere center
   Eigen::Vector4f center = model_coefficients;
-  center[3] = 0;
+  center[3] = 0.0f;
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Iterate through the 3d points and calculate the distances from them to the sphere
   for (std::size_t i = 0; i < indices_->size (); ++i)
@@ -78,12 +79,12 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::selectWithinDistance (
     Eigen::Vector4f p (input_->points[(*indices_)[i]].x, 
                        input_->points[(*indices_)[i]].y,
                        input_->points[(*indices_)[i]].z, 
-                       0);
+                       0.0f);
 
     Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], 
                        normals_->points[(*indices_)[i]].normal[1], 
                        normals_->points[(*indices_)[i]].normal[2], 
-                       0);
+                       0.0f);
 
     Eigen::Vector4f n_dir = p - center;
     double d_euclid = std::abs (n_dir.norm () - model_coefficients[3]);
@@ -92,17 +93,14 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::selectWithinDistance (
     double d_normal = std::abs (getAngle3D (n, n_dir));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    double distance = std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid); 
+    double distance = std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid);
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = static_cast<double> (distance);
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (static_cast<double> (distance));
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -123,7 +121,7 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::countWithinDistance (
 
   // Obtain the sphere centroid
   Eigen::Vector4f center = model_coefficients;
-  center[3] = 0;
+  center[3] = 0.0f;
 
   std::size_t nr_p = 0;
 
@@ -135,12 +133,12 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::countWithinDistance (
     Eigen::Vector4f p (input_->points[(*indices_)[i]].x, 
                        input_->points[(*indices_)[i]].y, 
                        input_->points[(*indices_)[i]].z, 
-                       0);
+                       0.0f);
 
     Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], 
                        normals_->points[(*indices_)[i]].normal[1], 
                        normals_->points[(*indices_)[i]].normal[2], 
-                       0);
+                       0.0f);
 
     Eigen::Vector4f n_dir = (p-center);
     double d_euclid = std::abs (n_dir.norm () - model_coefficients[3]);
@@ -149,7 +147,7 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::countWithinDistance (
     double d_normal = std::abs (getAngle3D (n, n_dir));
     d_normal = (std::min) (d_normal, M_PI - d_normal);
 
-    if (std::abs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
+    if (std::abs (normal_distance_weight_ * d_normal + (1.0 - normal_distance_weight_) * d_euclid) < threshold)
       nr_p++;
   }
   return (nr_p);
@@ -175,7 +173,7 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::getDistancesToModel (
 
   // Obtain the sphere centroid
   Eigen::Vector4f center = model_coefficients;
-  center[3] = 0;
+  center[3] = 0.0f;
 
   distances.resize (indices_->size ());
 
@@ -187,12 +185,12 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::getDistancesToModel (
     Eigen::Vector4f p (input_->points[(*indices_)[i]].x, 
                        input_->points[(*indices_)[i]].y, 
                        input_->points[(*indices_)[i]].z, 
-                       0);
+                       0.0f);
 
     Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], 
                        normals_->points[(*indices_)[i]].normal[1], 
                        normals_->points[(*indices_)[i]].normal[2], 
-                       0);
+                       0.0f);
 
     Eigen::Vector4f n_dir = (p-center);
     double d_euclid = std::abs (n_dir.norm () - model_coefficients[3]);
@@ -205,21 +203,6 @@ pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::getDistancesToModel (
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT, typename PointNT> bool 
-pcl::SampleConsensusModelNormalSphere<PointT, PointNT>::isModelValid (const Eigen::VectorXf &model_coefficients) const
-{
-  if (!SampleConsensusModel<PointT>::isModelValid (model_coefficients))
-    return (false);
-
-  if (radius_min_ != -std::numeric_limits<double>::max() && model_coefficients[3] < radius_min_)
-    return (false);
-  if (radius_max_ != std::numeric_limits<double>::max() && model_coefficients[3] > radius_max_)
-    return (false);
-
-  return (true);
-}
-
 #define PCL_INSTANTIATE_SampleConsensusModelNormalSphere(PointT, PointNT) template class PCL_EXPORTS pcl::SampleConsensusModelNormalSphere<PointT, PointNT>;
 
 #endif    // PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_SPHERE_H_
index 1ab1a430192c491a42adf9a75fedebaacb33c645..b6d74a4688ef8bacca5a385558f3ef5262439520 100644 (file)
@@ -47,7 +47,7 @@
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelParallelLine<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -66,7 +66,9 @@ pcl::SampleConsensusModelParallelLine<PointT>::countWithinDistance (
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
+  {
     return (0);
+  }
 
   return (SampleConsensusModelLine<PointT>::countWithinDistance (model_coefficients, threshold));
 }
@@ -97,14 +99,16 @@ pcl::SampleConsensusModelParallelLine<PointT>::isModelValid (const Eigen::Vector
   if (eps_angle_ > 0.0)
   {
     // Obtain the line direction
-    Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+    Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
 
-    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0);
+    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0.0f);
     double angle_diff = std::abs (getAngle3D (axis, line_dir));
     angle_diff = (std::min) (angle_diff, M_PI - angle_diff);
     // Check whether the current line model satisfies our angle threshold criterion with respect to the given axis
     if (angle_diff > eps_angle_)
+    {
       return (false);
+    }
   }
 
   return (true);
index 3de6be6def68093d4a8b4ac104743ebe800c1948..e2db128690a1ead1300452305d5b01fb8f163ee0 100644 (file)
@@ -46,7 +46,7 @@
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelParallelPlane<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -65,7 +65,9 @@ pcl::SampleConsensusModelParallelPlane<PointT>::countWithinDistance (
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
+  {
     return (0);
+  }
 
   return (SampleConsensusModelPlane<PointT>::countWithinDistance (model_coefficients, threshold));
 }
@@ -90,19 +92,23 @@ template <typename PointT> bool
 pcl::SampleConsensusModelParallelPlane<PointT>::isModelValid (const Eigen::VectorXf &model_coefficients) const
 {
   if (!SampleConsensusModel<PointT>::isModelValid (model_coefficients))
+  {
     return (false);
+  }
 
   // Check against template, if given
   if (eps_angle_ > 0.0)
   {
     // Obtain the plane normal
     Eigen::Vector4f coeff = model_coefficients;
-    coeff[3] = 0;
+    coeff[3] = 0.0f;
     coeff.normalize ();
 
-    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0);
+    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0.0f);
     if (std::abs (axis.dot (coeff)) > sin_angle_)
+    {
       return  (false);
+    }
   }
 
   return (true);
index e7bc7f0e98b6767f81ec19579b7d873adc0c7c9d..9f04f4310bbb78b057d207cf0800ac9ba5b3198c 100644 (file)
@@ -46,7 +46,7 @@
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelPerpendicularPlane<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -65,7 +65,9 @@ pcl::SampleConsensusModelPerpendicularPlane<PointT>::countWithinDistance (
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
+  {
     return (0);
+  }
 
   return (SampleConsensusModelPlane<PointT>::countWithinDistance (model_coefficients, threshold));
 }
@@ -90,21 +92,25 @@ template <typename PointT> bool
 pcl::SampleConsensusModelPerpendicularPlane<PointT>::isModelValid (const Eigen::VectorXf &model_coefficients) const
 {
   if (!SampleConsensusModel<PointT>::isModelValid (model_coefficients))
+  {
     return (false);
+  }
 
   // Check against template, if given
   if (eps_angle_ > 0.0)
   {
     // Obtain the plane normal
     Eigen::Vector4f coeff = model_coefficients;
-    coeff[3] = 0;
+    coeff[3] = 0.0f;
 
-    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0);
+    Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0.0f);
     double angle_diff = std::abs (getAngle3D (axis, coeff));
     angle_diff = (std::min) (angle_diff, M_PI - angle_diff);
     // Check whether the current plane model satisfies our angle threshold criterion with respect to the given axis
     if (angle_diff > eps_angle_)
+    {
       return (false);
+    }
   }
 
   return (true);
index 5b99792fba81928af70ed01a435c9f2b06bef33d..c4efebe995b08b88fc83e5a511f0ea305c3165b0 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelPlane<PointT>::isSampleGood (const std::vector<int> &samples) const
+pcl::SampleConsensusModelPlane<PointT>::isSampleGood (const Indices &samples) const
 {
-  // Need an extra check in case the sample selection is empty
-  if (samples.empty ())
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
     return (false);
+  }
   // Get the values at the two points
   pcl::Array4fMapConst p0 = input_->points[samples[0]].getArray4fMap ();
   pcl::Array4fMapConst p1 = input_->points[samples[1]].getArray4fMap ();
@@ -67,7 +69,7 @@ pcl::SampleConsensusModelPlane<PointT>::isSampleGood (const std::vector<int> &sa
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelPlane<PointT>::computeModelCoefficients (
-      const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+      const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 3 samples
   if (samples.size () != sample_size_)
@@ -88,21 +90,23 @@ pcl::SampleConsensusModelPlane<PointT>::computeModelCoefficients (
   // Avoid some crashes by checking for collinearity here
   Eigen::Array4f dy1dy2 = p1p0 / p2p0;
   if ( (dy1dy2[0] == dy1dy2[1]) && (dy1dy2[2] == dy1dy2[1]) )          // Check for collinearity
+  {
     return (false);
+  }
 
   // Compute the plane coefficients from the 3 given points in a straightforward manner
   // calculate the plane normal n = (p2-p1) x (p3-p1) = cross (p2-p1, p3-p1)
-  model_coefficients.resize (4);
+  model_coefficients.resize (model_size_);
   model_coefficients[0] = p1p0[1] * p2p0[2] - p1p0[2] * p2p0[1];
   model_coefficients[1] = p1p0[2] * p2p0[0] - p1p0[0] * p2p0[2];
   model_coefficients[2] = p1p0[0] * p2p0[1] - p1p0[1] * p2p0[0];
-  model_coefficients[3] = 0;
+  model_coefficients[3] = 0.0f;
 
   // Normalize
   model_coefficients.normalize ();
 
   // ... + d = 0
-  model_coefficients[3] = -1 * (model_coefficients.template head<4>().dot (p0.matrix ()));
+  model_coefficients[3] = -1.0f * (model_coefficients.template head<4>().dot (p0.matrix ()));
 
   return (true);
 }
@@ -113,9 +117,9 @@ pcl::SampleConsensusModelPlane<PointT>::getDistancesToModel (
       const Eigen::VectorXf &model_coefficients, std::vector<double> &distances) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != model_size_)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelPlane::getDistancesToModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::getDistancesToModel] Given model is invalid!\n");
     return;
   }
 
@@ -133,7 +137,7 @@ pcl::SampleConsensusModelPlane<PointT>::getDistancesToModel (
     Eigen::Vector4f pt (input_->points[(*indices_)[i]].x,
                         input_->points[(*indices_)[i]].y,
                         input_->points[(*indices_)[i]].z,
-                        1);
+                        1.0f);
     distances[i] = std::abs (model_coefficients.dot (pt));
   }
 }
@@ -141,18 +145,19 @@ pcl::SampleConsensusModelPlane<PointT>::getDistancesToModel (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelPlane<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != model_size_)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelPlane::selectWithinDistance] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::selectWithinDistance] Given model is invalid!\n");
     return;
   }
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Iterate through the 3d points and calculate the distances from them to the plane
   for (std::size_t i = 0; i < indices_->size (); ++i)
@@ -162,20 +167,17 @@ pcl::SampleConsensusModelPlane<PointT>::selectWithinDistance (
     Eigen::Vector4f pt (input_->points[(*indices_)[i]].x,
                         input_->points[(*indices_)[i]].y,
                         input_->points[(*indices_)[i]].z,
-                        1);
+                        1.0f);
     
     float distance = std::abs (model_coefficients.dot (pt));
     
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = static_cast<double> (distance);
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (static_cast<double> (distance));
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -184,9 +186,9 @@ pcl::SampleConsensusModelPlane<PointT>::countWithinDistance (
       const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != model_size_)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelPlane::countWithinDistance] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::countWithinDistance] Given model is invalid!\n");
     return (0);
   }
 
@@ -200,9 +202,11 @@ pcl::SampleConsensusModelPlane<PointT>::countWithinDistance (
     Eigen::Vector4f pt (input_->points[(*indices_)[i]].x,
                         input_->points[(*indices_)[i]].y,
                         input_->points[(*indices_)[i]].z,
-                        1);
+                        1.0f);
     if (std::abs (model_coefficients.dot (pt)) < threshold)
+    {
       nr_p++;
+    }
   }
   return (nr_p);
 }
@@ -210,12 +214,12 @@ pcl::SampleConsensusModelPlane<PointT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelPlane<PointT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != model_size_)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelPlane::optimizeModelCoefficients] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::optimizeModelCoefficients] Given model is invalid!\n");
     optimized_coefficients = model_coefficients;
     return;
   }
@@ -242,12 +246,12 @@ pcl::SampleConsensusModelPlane<PointT>::optimizeModelCoefficients (
   pcl::eigen33 (covariance_matrix, eigen_value, eigen_vector);
 
   // Hessian form (D = nc . p_plane (centroid here) + p)
-  optimized_coefficients.resize (4);
+  optimized_coefficients.resize (model_size_);
   optimized_coefficients[0] = eigen_vector [0];
   optimized_coefficients[1] = eigen_vector [1];
   optimized_coefficients[2] = eigen_vector [2];
-  optimized_coefficients[3] = 0;
-  optimized_coefficients[3] = -1 * optimized_coefficients.dot (xyz_centroid);
+  optimized_coefficients[3] = 0.0f;
+  optimized_coefficients[3] = -1.0f * optimized_coefficients.dot (xyz_centroid);
 
   // Make sure it results in a valid model
   if (!isModelValid (optimized_coefficients))
@@ -259,19 +263,19 @@ pcl::SampleConsensusModelPlane<PointT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelPlane<PointT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != model_size_)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelPlane::projectPoints] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::projectPoints] Given model is invalid!\n");
     return;
   }
 
   projected_points.header = input_->header;
   projected_points.is_dense = input_->is_dense;
 
-  Eigen::Vector4f mc (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
+  Eigen::Vector4f mc (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
 
   // normalize the vector perpendicular to the plane...
   mc.normalize ();
@@ -296,7 +300,7 @@ pcl::SampleConsensusModelPlane<PointT>::projectPoints (
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
 
     // Iterate through the 3d points and calculate the distances from them to the plane
-    for (const int &inlier : inliers)
+    for (const auto &inlier : inliers)
     {
       // Calculate the distance from the point to the plane
       Eigen::Vector4f p (input_->points[inlier].x,
@@ -320,8 +324,10 @@ pcl::SampleConsensusModelPlane<PointT>::projectPoints (
     using FieldList = typename pcl::traits::fieldList<PointT>::type;
     // Iterate over each point
     for (std::size_t i = 0; i < inliers.size (); ++i)
+    {
       // Iterate over each dimension
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[inliers[i]], projected_points.points[i]));
+    }
 
     // Iterate through the 3d points and calculate the distances from them to the plane
     for (std::size_t i = 0; i < inliers.size (); ++i)
@@ -330,7 +336,7 @@ pcl::SampleConsensusModelPlane<PointT>::projectPoints (
       Eigen::Vector4f p (input_->points[inliers[i]].x,
                          input_->points[inliers[i]].y,
                          input_->points[inliers[i]].z,
-                         1);
+                         1.0f);
       // use normalized coefficients to calculate the scalar projection
       float distance_to_plane = tmp_mc.dot (p);
 
@@ -343,23 +349,25 @@ pcl::SampleConsensusModelPlane<PointT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelPlane<PointT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid set of model coefficients
-  if (model_coefficients.size () != model_size_)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelPlane::doSamplesVerifyModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelPlane::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
   }
 
-  for (const int &index : indices)
+  for (const auto &index : indices)
   {
     Eigen::Vector4f pt (input_->points[index].x,
                         input_->points[index].y,
                         input_->points[index].z,
-                        1);
+                        1.0f);
     if (std::abs (model_coefficients.dot (pt)) > threshold)
+    {
       return (false);
+    }
   }
 
   return (true);
index 5b9d1f7ddd24f786c47ea99e1df487554e82a69f..be1d34b72bec75537b3c068dd5122d3d08aaa58d 100644 (file)
 #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_REGISTRATION_H_
 
 #include <pcl/sample_consensus/sac_model_registration.h>
-#include <pcl/common/point_operators.h>
 #include <pcl/common/eigen.h>
 #include <pcl/point_types.h>
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelRegistration<PointT>::isSampleGood (const std::vector<int> &samples) const
+pcl::SampleConsensusModelRegistration<PointT>::isSampleGood (const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelRegistration::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   using namespace pcl::common;
   using namespace pcl::traits;
 
@@ -64,7 +68,7 @@ pcl::SampleConsensusModelRegistration<PointT>::isSampleGood (const std::vector<i
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelRegistration<PointT>::computeModelCoefficients (const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+pcl::SampleConsensusModelRegistration<PointT>::computeModelCoefficients (const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   if (!target_)
   {
@@ -72,12 +76,16 @@ pcl::SampleConsensusModelRegistration<PointT>::computeModelCoefficients (const s
     return (false);
   }
   // Need 3 samples
-  if (samples.size () != 3)
+  if (samples.size () != sample_size_)
+  {
     return (false);
+  }
 
-  std::vector<int> indices_tgt (3);
+  Indices indices_tgt (3);
   for (int i = 0; i < 3; ++i)
+  {
     indices_tgt[i] = correspondences_.at (samples[i]);
+  }
 
   estimateRigidTransformationSVD (*input_, samples, *target_, indices_tgt, model_coefficients);
   return (true);
@@ -117,10 +125,10 @@ pcl::SampleConsensusModelRegistration<PointT>::getDistancesToModel (const Eigen:
   {
     Eigen::Vector4f pt_src (input_->points[(*indices_)[i]].x, 
                             input_->points[(*indices_)[i]].y, 
-                            input_->points[(*indices_)[i]].z, 1); 
+                            input_->points[(*indices_)[i]].z, 1.0f);
     Eigen::Vector4f pt_tgt (target_->points[(*indices_tgt_)[i]].x, 
                             target_->points[(*indices_tgt_)[i]].y, 
-                            target_->points[(*indices_tgt_)[i]].z, 1); 
+                            target_->points[(*indices_tgt_)[i]].z, 1.0f);
 
     Eigen::Vector4f p_tr (transform * pt_src);
     // Calculate the distance from the transformed point to its correspondence
@@ -131,7 +139,7 @@ pcl::SampleConsensusModelRegistration<PointT>::getDistancesToModel (const Eigen:
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
-pcl::SampleConsensusModelRegistration<PointT>::selectWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers) 
+pcl::SampleConsensusModelRegistration<PointT>::selectWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   if (indices_->size () != indices_tgt_->size ())
   {
@@ -154,9 +162,10 @@ pcl::SampleConsensusModelRegistration<PointT>::selectWithinDistance (const Eigen
     return;
   }
   
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   Eigen::Matrix4f transform;
   transform.row (0).matrix () = model_coefficients.segment<4>(0);
@@ -179,13 +188,10 @@ pcl::SampleConsensusModelRegistration<PointT>::selectWithinDistance (const Eigen
     // Calculate the distance from the transformed point to its correspondence
     if (distance < thresh)
     {
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = static_cast<double> (distance);
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (static_cast<double> (distance));
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 } 
 
 //////////////////////////////////////////////////////////////////////////
@@ -208,7 +214,9 @@ pcl::SampleConsensusModelRegistration<PointT>::countWithinDistance (
 
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
+  {
     return (0);
+  }
   
   Eigen::Matrix4f transform;
   transform.row (0).matrix () = model_coefficients.segment<4>(0);
@@ -236,7 +244,7 @@ pcl::SampleConsensusModelRegistration<PointT>::countWithinDistance (
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
-pcl::SampleConsensusModelRegistration<PointT>::optimizeModelCoefficients (const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+pcl::SampleConsensusModelRegistration<PointT>::optimizeModelCoefficients (const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   if (indices_->size () != indices_tgt_->size ())
   {
@@ -252,8 +260,8 @@ pcl::SampleConsensusModelRegistration<PointT>::optimizeModelCoefficients (const
     return;
   }
 
-  std::vector<int> indices_src (inliers.size ());
-  std::vector<int> indices_tgt (inliers.size ());
+  Indices indices_src (inliers.size ());
+  Indices indices_tgt (inliers.size ());
   for (std::size_t i = 0; i < inliers.size (); ++i)
   {
     indices_src[i] = inliers[i];
@@ -267,9 +275,9 @@ pcl::SampleConsensusModelRegistration<PointT>::optimizeModelCoefficients (const
 template <typename PointT> void
 pcl::SampleConsensusModelRegistration<PointT>::estimateRigidTransformationSVD (
     const pcl::PointCloud<PointT> &cloud_src,
-    const std::vector<int> &indices_src,
+    const Indices &indices_src,
     const pcl::PointCloud<PointT> &cloud_tgt,
-    const std::vector<int> &indices_tgt,
+    const Indices &indices_tgt,
     Eigen::VectorXf &transform) const
 {
   transform.resize (16);
index 0a12544a239dbeddb9c75b6407e246fbc0b8aef7..fc94efce7a15e23e04d126c61b9b69eb0e99bbbc 100644 (file)
 #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_REGISTRATION_2D_HPP_
 
 #include <pcl/sample_consensus/sac_model_registration_2d.h>
-#include <pcl/common/point_operators.h>
 #include <pcl/common/eigen.h>
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelRegistration2D<PointT>::isSampleGood (const std::vector<int>&) const
+pcl::SampleConsensusModelRegistration2D<PointT>::isSampleGood (const Indices&samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelRegistration2D::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   return (true);
   //using namespace pcl::common;
   //using namespace pcl::traits;
@@ -89,7 +93,7 @@ pcl::SampleConsensusModelRegistration2D<PointT>::getDistancesToModel (const Eige
   {
     Eigen::Vector4f pt_src (input_->points[(*indices_)[i]].x, 
                             input_->points[(*indices_)[i]].y, 
-                            input_->points[(*indices_)[i]].z, 1); 
+                            input_->points[(*indices_)[i]].z, 1.0f);
 
     Eigen::Vector4f p_tr (transform * pt_src);
 
@@ -97,8 +101,10 @@ pcl::SampleConsensusModelRegistration2D<PointT>::getDistancesToModel (const Eige
     Eigen::Vector3f p_tr3 (p_tr[0], p_tr[1], p_tr[2]);
     Eigen::Vector3f uv (projection_matrix_ * p_tr3);
 
-    if (uv[2] < 0)
+    if (uv[2] < 0.0f)
+    {
       continue;
+    }
 
     uv /= uv[2];
 
@@ -113,7 +119,7 @@ pcl::SampleConsensusModelRegistration2D<PointT>::getDistancesToModel (const Eige
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
-pcl::SampleConsensusModelRegistration2D<PointT>::selectWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers) 
+pcl::SampleConsensusModelRegistration2D<PointT>::selectWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   if (indices_->size () != indices_tgt_->size ())
   {
@@ -129,9 +135,10 @@ pcl::SampleConsensusModelRegistration2D<PointT>::selectWithinDistance (const Eig
 
   double thresh = threshold * threshold;
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   Eigen::Matrix4f transform;
   transform.row (0).matrix () = model_coefficients.segment<4>(0);
@@ -143,7 +150,7 @@ pcl::SampleConsensusModelRegistration2D<PointT>::selectWithinDistance (const Eig
   {
     Eigen::Vector4f pt_src (input_->points[(*indices_)[i]].x, 
                             input_->points[(*indices_)[i]].y, 
-                            input_->points[(*indices_)[i]].z, 1); 
+                            input_->points[(*indices_)[i]].z, 1.0f);
 
     Eigen::Vector4f p_tr (transform * pt_src);
 
@@ -151,7 +158,7 @@ pcl::SampleConsensusModelRegistration2D<PointT>::selectWithinDistance (const Eig
     Eigen::Vector3f p_tr3 (p_tr[0], p_tr[1], p_tr[2]);
     Eigen::Vector3f uv (projection_matrix_ * p_tr3);
 
-    if (uv[2] < 0)
+    if (uv[2] < 0.0f)
       continue;
 
     uv /= uv[2];
@@ -164,13 +171,10 @@ pcl::SampleConsensusModelRegistration2D<PointT>::selectWithinDistance (const Eig
     // Calculate the distance from the transformed point to its correspondence
     if (distance < thresh)
     {
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = distance;
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (distance);
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 } 
 
 //////////////////////////////////////////////////////////////////////////
@@ -203,7 +207,7 @@ pcl::SampleConsensusModelRegistration2D<PointT>::countWithinDistance (
   {
     Eigen::Vector4f pt_src (input_->points[(*indices_)[i]].x, 
                             input_->points[(*indices_)[i]].y, 
-                            input_->points[(*indices_)[i]].z, 1); 
+                            input_->points[(*indices_)[i]].z, 1.0f);
 
     Eigen::Vector4f p_tr (transform * pt_src);
 
@@ -211,8 +215,10 @@ pcl::SampleConsensusModelRegistration2D<PointT>::countWithinDistance (
     Eigen::Vector3f p_tr3 (p_tr[0], p_tr[1], p_tr[2]);
     Eigen::Vector3f uv (projection_matrix_ * p_tr3);
 
-    if (uv[2] < 0)
+    if (uv[2] < 0.0f)
+    {
       continue;
+    }
 
     uv /= uv[2];
 
@@ -221,7 +227,9 @@ pcl::SampleConsensusModelRegistration2D<PointT>::countWithinDistance (
          (uv[0] - target_->points[(*indices_tgt_)[i]].u) +
          (uv[1] - target_->points[(*indices_tgt_)[i]].v) *
          (uv[1] - target_->points[(*indices_tgt_)[i]].v)) < thresh)
+    {
       ++nr_p;
+    }
   }
   return (nr_p);
 } 
index fb392efc92f3ea1a663dd35109d4dcc8b05aa05f..b18a9a3a0ba4a34e6a0fa567871e72e6ce9f69dc 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelSphere<PointT>::isSampleGood (const std::vector<int> &) const
+pcl::SampleConsensusModelSphere<PointT>::isSampleGood (const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelSphere::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   return (true);
 }
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelSphere<PointT>::computeModelCoefficients (
-      const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+      const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 4 samples
-  if (samples.size () != 4)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelSphere::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
@@ -73,12 +78,16 @@ pcl::SampleConsensusModelSphere<PointT>::computeModelCoefficients (
   }
   float m11 = temp.determinant ();
   if (m11 == 0)
+  {
     return (false);             // the points don't define a sphere!
+  }
 
   for (int i = 0; i < 4; ++i)
+  {
     temp (i, 0) = (input_->points[samples[i]].x) * (input_->points[samples[i]].x) +
                   (input_->points[samples[i]].y) * (input_->points[samples[i]].y) +
                   (input_->points[samples[i]].z) * (input_->points[samples[i]].z);
+  }
   float m12 = temp.determinant ();
 
   for (int i = 0; i < 4; ++i)
@@ -105,7 +114,7 @@ pcl::SampleConsensusModelSphere<PointT>::computeModelCoefficients (
   float m15 = temp.determinant ();
 
   // Center (x , y, z)
-  model_coefficients.resize (4);
+  model_coefficients.resize (model_size_);
   model_coefficients[0] = 0.5f * m12 / m11;
   model_coefficients[1] = 0.5f * m13 / m11;
   model_coefficients[2] = 0.5f * m14 / m11;
@@ -132,6 +141,7 @@ pcl::SampleConsensusModelSphere<PointT>::getDistancesToModel (
 
   // Iterate through the 3d points and calculate the distances from them to the sphere
   for (std::size_t i = 0; i < indices_->size (); ++i)
+  {
     // Calculate the distance from the point to the sphere as the difference between
     //dist(point,sphere_origin) and sphere_radius
     distances[i] = std::abs (std::sqrt (
@@ -144,12 +154,13 @@ pcl::SampleConsensusModelSphere<PointT>::getDistancesToModel (
                                ( input_->points[(*indices_)[i]].z - model_coefficients[2] ) *
                                ( input_->points[(*indices_)[i]].z - model_coefficients[2] )
                                ) - model_coefficients[3]);
+  }
 }
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelSphere<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Check if the model is valid given the user constraints
   if (!isModelValid (model_coefficients))
@@ -158,9 +169,10 @@ pcl::SampleConsensusModelSphere<PointT>::selectWithinDistance (
     return;
   }
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Iterate through the 3d points and calculate the distances from them to the sphere
   for (std::size_t i = 0; i < indices_->size (); ++i)
@@ -180,13 +192,10 @@ pcl::SampleConsensusModelSphere<PointT>::selectWithinDistance (
     if (distance < threshold)
     {
       // Returns the indices of the points whose distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = static_cast<double> (distance);
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (static_cast<double> (distance));
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -223,21 +232,21 @@ pcl::SampleConsensusModelSphere<PointT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelSphere<PointT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   optimized_coefficients = model_coefficients;
 
   // Needs a set of valid model coefficients
-  if (model_coefficients.size () != 4)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Given model is invalid!\n");
     return;
   }
 
-  // Need at least 4 samples
-  if (inliers.size () <= 4)
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Not enough inliers found to support a model (%lu)! Returning the same coefficients.\n", inliers.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     return;
   }
 
@@ -254,12 +263,12 @@ pcl::SampleConsensusModelSphere<PointT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelSphere<PointT>::projectPoints (
-      const std::vector<int> &, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool) const
+      const Indices &, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool) const
 {
   // Needs a valid model coefficients
-  if (model_coefficients.size () != 4)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelSphere::projectPoints] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelSphere::projectPoints] Given model is invalid!\n");
     return;
   }
 
@@ -277,16 +286,17 @@ pcl::SampleConsensusModelSphere<PointT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelSphere<PointT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid model coefficients
-  if (model_coefficients.size () != 4)
+  if (!isModelValid (model_coefficients))
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelSphere::doSamplesVerifyModel] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelSphere::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
   }
 
-  for (const int &index : indices)
+  for (const auto &index : indices)
+  {
     // Calculate the distance from the point to the sphere as the difference between
     //dist(point,sphere_origin) and sphere_radius
     if (std::abs (sqrt (
@@ -297,7 +307,10 @@ pcl::SampleConsensusModelSphere<PointT>::doSamplesVerifyModel (
                     ( input_->points[index].z - model_coefficients[2] ) *
                     ( input_->points[index].z - model_coefficients[2] )
                    ) - model_coefficients[3]) > threshold)
+    {
       return (false);
+    }
+  }
 
   return (true);
 }
index 8d030eafa859215eb1d8e8ce778803dc782349c8..37655c7cf4b89351ae7544b8ee836f98d3c77e26 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
-pcl::SampleConsensusModelStick<PointT>::isSampleGood (const std::vector<int> &samples) const
+pcl::SampleConsensusModelStick<PointT>::isSampleGood (const Indices &samples) const
 {
+  if (samples.size () != sample_size_)
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::isSampleGood] Wrong number of samples (is %lu, should be %lu)!\n", samples.size (), sample_size_);
+    return (false);
+  }
   if (
       (input_->points[samples[0]].x != input_->points[samples[1]].x)
     &&
       (input_->points[samples[0]].y != input_->points[samples[1]].y)
     &&
       (input_->points[samples[0]].z != input_->points[samples[1]].z))
+  {
     return (true);
+  }
 
   return (false);
 }
@@ -63,16 +70,16 @@ pcl::SampleConsensusModelStick<PointT>::isSampleGood (const std::vector<int> &sa
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelStick<PointT>::computeModelCoefficients (
-      const std::vector<int> &samples, Eigen::VectorXf &model_coefficients) const
+      const Indices &samples, Eigen::VectorXf &model_coefficients) const
 {
   // Need 2 samples
-  if (samples.size () != 2)
+  if (samples.size () != sample_size_)
   {
     PCL_ERROR ("[pcl::SampleConsensusModelStick::computeModelCoefficients] Invalid set of samples given (%lu)!\n", samples.size ());
     return (false);
   }
 
-  model_coefficients.resize (7);
+  model_coefficients.resize (model_size_);
   model_coefficients[0] = input_->points[samples[0]].x;
   model_coefficients[1] = input_->points[samples[0]].y;
   model_coefficients[2] = input_->points[samples[0]].z;
@@ -98,14 +105,17 @@ pcl::SampleConsensusModelStick<PointT>::getDistancesToModel (
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::getDistancesToModel] Given model is invalid!\n");
     return;
+  }
 
   float sqr_threshold = static_cast<float> (radius_max_ * radius_max_);
   distances.resize (indices_->size ());
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   line_dir.normalize ();
 
   // Iterate through the 3d points and calculate the distances from them to the line
@@ -116,32 +126,40 @@ pcl::SampleConsensusModelStick<PointT>::getDistancesToModel (
     float sqr_distance = (line_pt - input_->points[(*indices_)[i]].getVector4fMap ()).cross3 (line_dir).squaredNorm ();
 
     if (sqr_distance < sqr_threshold)
+    {
       // Need to estimate sqrt here to keep MSAC and friends general
       distances[i] = sqrt (sqr_distance);
+    }
     else
+    {
       // Penalize outliers by doubling the distance
       distances[i] = 2 * sqrt (sqr_distance);
+    }
   }
 }
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelStick<PointT>::selectWithinDistance (
-      const Eigen::VectorXf &model_coefficients, const double threshold, std::vector<int> &inliers)
+      const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::selectWithinDistance] Given model is invalid!\n");
     return;
+  }
 
   float sqr_threshold = static_cast<float> (threshold * threshold);
 
-  int nr_p = 0;
-  inliers.resize (indices_->size ());
-  error_sqr_dists_.resize (indices_->size ());
+  inliers.clear ();
+  error_sqr_dists_.clear ();
+  inliers.reserve (indices_->size ());
+  error_sqr_dists_.reserve (indices_->size ());
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt1 (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_pt2 (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt1 (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_pt2 (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   Eigen::Vector4f line_dir = line_pt2 - line_pt1;
   //Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
   //Eigen::Vector4f line_dir (model_coefficients[3] - model_coefficients[0], model_coefficients[4] - model_coefficients[1], model_coefficients[5] - model_coefficients[2], 0);
@@ -164,13 +182,10 @@ pcl::SampleConsensusModelStick<PointT>::selectWithinDistance (
     if (sqr_distance < sqr_threshold)
     {
       // Returns the indices of the points whose squared distances are smaller than the threshold
-      inliers[nr_p] = (*indices_)[i];
-      error_sqr_dists_[nr_p] = static_cast<double> (sqr_distance);
-      ++nr_p;
+      inliers.push_back ((*indices_)[i]);
+      error_sqr_dists_.push_back (static_cast<double> (sqr_distance));
     }
   }
-  inliers.resize (nr_p);
-  error_sqr_dists_.resize (nr_p);
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -180,15 +195,18 @@ pcl::SampleConsensusModelStick<PointT>::countWithinDistance (
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::countWithinDistance] Given model is invalid!\n");
     return (0);
+  }
 
   float sqr_threshold = static_cast<float> (threshold * threshold);
 
   std::size_t nr_i = 0, nr_o = 0;
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt1 (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_pt2 (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt1 (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_pt2 (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
   Eigen::Vector4f line_dir = line_pt2 - line_pt1;
   line_dir.normalize ();
 
@@ -210,9 +228,13 @@ pcl::SampleConsensusModelStick<PointT>::countWithinDistance (
     float sqr_distance = dir.cross3 (line_dir).squaredNorm ();
     // Use a larger threshold (4 times the radius) to get more points in
     if (sqr_distance < sqr_threshold)
+    {
       nr_i++;
-    else if (sqr_distance < 4 * sqr_threshold)
+    }
+    else if (sqr_distance < 4.0f * sqr_threshold)
+    {
       nr_o++;
+    }
   }
 
   return (nr_i <= nr_o ? 0 : nr_i - nr_o);
@@ -221,7 +243,7 @@ pcl::SampleConsensusModelStick<PointT>::countWithinDistance (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelStick<PointT>::optimizeModelCoefficients (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
@@ -230,15 +252,15 @@ pcl::SampleConsensusModelStick<PointT>::optimizeModelCoefficients (
     return;
   }
 
-  // Need at least 2 points to estimate a line
-  if (inliers.size () <= 2)
+  // Need more than the minimum sample size to make a difference
+  if (inliers.size () <= sample_size_)
   {
-    PCL_ERROR ("[pcl::SampleConsensusModelStick::optimizeModelCoefficients] Not enough inliers found to support a model (%lu)! Returning the same coefficients.\n", inliers.size ());
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::optimizeModelCoefficients] Not enough inliers to refine/optimize the model's coefficients (%lu)! Returning the same coefficients.\n", inliers.size ());
     optimized_coefficients = model_coefficients;
     return;
   }
 
-  optimized_coefficients.resize (7);
+  optimized_coefficients.resize (model_size_);
 
   // Compute the 3x3 covariance matrix
   Eigen::Vector4f centroid;
@@ -262,15 +284,18 @@ pcl::SampleConsensusModelStick<PointT>::optimizeModelCoefficients (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SampleConsensusModelStick<PointT>::projectPoints (
-      const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
+      const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
 {
   // Needs a valid model coefficients
   if (!isModelValid (model_coefficients))
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::projectPoints] Given model is invalid!\n");
     return;
+  }
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0.0f);
 
   projected_points.header = input_->header;
   projected_points.is_dense = input_->is_dense;
@@ -286,13 +311,15 @@ pcl::SampleConsensusModelStick<PointT>::projectPoints (
     using FieldList = typename pcl::traits::fieldList<PointT>::type;
     // Iterate over each point
     for (std::size_t i = 0; i < projected_points.points.size (); ++i)
+    {
       // Iterate over each dimension
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
+    }
 
     // Iterate through the 3d points and calculate the distances from them to the line
-    for (const int &inlier : inliers)
+    for (const auto &inlier : inliers)
     {
-      Eigen::Vector4f pt (input_->points[inlier].x, input_->points[inlier].y, input_->points[inlier].z, 0);
+      Eigen::Vector4f pt (input_->points[inlier].x, input_->points[inlier].y, input_->points[inlier].z, 0.0f);
       // double k = (DOT_PROD_3D (points[i], p21) - dotA_B) / dotB_B;
       float k = (pt.dot (line_dir) - line_pt.dot (line_dir)) / line_dir.dot (line_dir);
 
@@ -313,13 +340,15 @@ pcl::SampleConsensusModelStick<PointT>::projectPoints (
     using FieldList = typename pcl::traits::fieldList<PointT>::type;
     // Iterate over each point
     for (std::size_t i = 0; i < inliers.size (); ++i)
+    {
       // Iterate over each dimension
       pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[inliers[i]], projected_points.points[i]));
+    }
 
     // Iterate through the 3d points and calculate the distances from them to the line
     for (std::size_t i = 0; i < inliers.size (); ++i)
     {
-      Eigen::Vector4f pt (input_->points[inliers[i]].x, input_->points[inliers[i]].y, input_->points[inliers[i]].z, 0);
+      Eigen::Vector4f pt (input_->points[inliers[i]].x, input_->points[inliers[i]].y, input_->points[inliers[i]].z, 0.0f);
       // double k = (DOT_PROD_3D (points[i], p21) - dotA_B) / dotB_B;
       float k = (pt.dot (line_dir) - line_pt.dot (line_dir)) / line_dir.dot (line_dir);
 
@@ -335,26 +364,31 @@ pcl::SampleConsensusModelStick<PointT>::projectPoints (
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> bool
 pcl::SampleConsensusModelStick<PointT>::doSamplesVerifyModel (
-      const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
+      const std::set<index_t> &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
 {
   // Needs a valid set of model coefficients
   if (!isModelValid (model_coefficients))
+  {
+    PCL_ERROR ("[pcl::SampleConsensusModelStick::doSamplesVerifyModel] Given model is invalid!\n");
     return (false);
+  }
 
   // Obtain the line point and direction
-  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0);
-  Eigen::Vector4f line_dir (model_coefficients[3] - model_coefficients[0], model_coefficients[4] - model_coefficients[1], model_coefficients[5] - model_coefficients[2], 0);
+  Eigen::Vector4f line_pt  (model_coefficients[0], model_coefficients[1], model_coefficients[2], 0.0f);
+  Eigen::Vector4f line_dir (model_coefficients[3] - model_coefficients[0], model_coefficients[4] - model_coefficients[1], model_coefficients[5] - model_coefficients[2], 0.0f);
   //Eigen::Vector4f line_dir (model_coefficients[3], model_coefficients[4], model_coefficients[5], 0);
   line_dir.normalize ();
 
   float sqr_threshold = static_cast<float> (threshold * threshold);
   // Iterate through the 3d points and calculate the distances from them to the line
-  for (const int &index : indices)
+  for (const auto &index : indices)
   {
     // Calculate the distance from the point to the line
     // D = ||(P2-P1) x (P1-P0)|| / ||P2-P1|| = norm (cross (p2-p1, p2-p0)) / norm(p2-p1)
     if ((line_pt - input_->points[index].getVector4fMap ()).cross3 (line_dir).squaredNorm () > sqr_threshold)
+    {
       return (false);
+    }
   }
 
   return (true);
index 4489a88add5ff2cd6d36c44c8be74ef5f10bc160..c42d369645dce2b9ca55040adcc1afa7b17291f6 100644 (file)
@@ -197,7 +197,7 @@ namespace pcl
         double sigma_sqr = sigma * sigma;
         unsigned int refine_iterations = 0;
         bool inlier_changed = false, oscillating = false;
-        std::vector<int> new_inliers, prev_inliers = inliers_;
+        Indices new_inliers, prev_inliers = inliers_;
         std::vector<std::size_t> inliers_sizes;
         Eigen::VectorXf new_model_coefficients = model_coefficients_;
         do
@@ -287,25 +287,25 @@ namespace pcl
       inline void
       getRandomSamples (const IndicesPtr &indices,
                         std::size_t nr_samples, 
-                        std::set<int> &indices_subset)
+                        std::set<index_t> &indices_subset)
       {
         indices_subset.clear ();
         while (indices_subset.size () < nr_samples)
-          //indices_subset.insert ((*indices)[(int) (indices->size () * (rand () / (RAND_MAX + 1.0)))]);
-          indices_subset.insert ((*indices)[static_cast<int> (static_cast<double>(indices->size ()) * rnd ())]);
+          //indices_subset.insert ((*indices)[(index_t) (indices->size () * (rand () / (RAND_MAX + 1.0)))]);
+          indices_subset.insert ((*indices)[static_cast<index_t> (static_cast<double>(indices->size ()) * rnd ())]);
       }
 
       /** \brief Return the best model found so far. 
         * \param[out] model the resultant model
         */
       inline void 
-      getModel (std::vector<int> &model) const { model = model_; }
+      getModel (Indices &model) const { model = model_; }
 
       /** \brief Return the best set of inliers found so far for this model. 
         * \param[out] inliers the resultant set of inliers
         */
       inline void 
-      getInliers (std::vector<int> &inliers) const { inliers = inliers_; }
+      getInliers (Indices &inliers) const { inliers = inliers_; }
 
       /** \brief Return the model coefficients of the best model found so far. 
         * \param[out] model_coefficients the resultant model coefficients, as documented in \ref sample_consensus
@@ -318,10 +318,10 @@ namespace pcl
       SampleConsensusModelPtr sac_model_;
 
       /** \brief The model found after the last computeModel () as point cloud indices. */
-      std::vector<int> model_;
+      Indices model_;
 
       /** \brief The indices of the points that were chosen as inliers after the last computeModel () call. */
-      std::vector<int> inliers_;
+      Indices inliers_;
 
       /** \brief The coefficients of our model computed directly from the model found. */
       Eigen::VectorXf model_coefficients_;
index edd752311190e362822258642933cdb28a018e81..655d93e7910ea6fb46d50f4f5480b02ee84a570c 100644 (file)
 #include <memory>
 #include <set>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/pcl_base.h>
 #include <pcl/console/print.h>
 #include <pcl/point_cloud.h>
+#include <pcl/types.h> // for index_t, Indices
 #include <pcl/sample_consensus/boost.h>
 #include <pcl/sample_consensus/model_types.h>
 
@@ -128,10 +130,10 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModel (const PointCloudConstPtr &cloud, 
-                            const std::vector<int> &indices, 
+                            const Indices &indices,
                             bool random = false) 
         : input_ (cloud)
-        , indices_ (new std::vector<int> (indices))
+        , indices_ (new Indices (indices))
         , radius_min_ (-std::numeric_limits<double>::max ())
         , radius_max_ (std::numeric_limits<double>::max ())
         , samples_radius_ (0.)
@@ -163,7 +165,7 @@ namespace pcl
         * \param[out] samples the resultant model samples
         */
       virtual void 
-      getSamples (int &iterations, std::vector<int> &samples)
+      getSamples (int &iterations, Indices &samples)
       {
         // We're assuming that indices_ have already been set in the constructor
         if (indices_->size () < getSampleSize ())
@@ -206,7 +208,7 @@ namespace pcl
         * \param[out] model_coefficients the computed model coefficients
         */
       virtual bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const = 0;
 
       /** \brief Recompute the model coefficients using the given inlier set
@@ -220,7 +222,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       virtual void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const = 0;
 
@@ -244,7 +246,7 @@ namespace pcl
       virtual void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold,
-                            std::vector<int> &inliers) = 0;
+                            Indices &inliers) = 0;
 
       /** \brief Count all the points which respect the given model
         * coefficients as inliers. Pure virtual.
@@ -268,7 +270,7 @@ namespace pcl
         * the point projections on the plane model
         */
       virtual void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const = 0;
@@ -282,7 +284,7 @@ namespace pcl
         * determining the inliers from the outliers
         */
       virtual bool 
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const = 0;
 
@@ -294,13 +296,13 @@ namespace pcl
       {
         input_ = cloud;
         if (!indices_)
-          indices_.reset (new std::vector<int> ());
+          indices_.reset (new Indices ());
         if (indices_->empty ())
         {
           // Prepare a set of indices to be used (entire cloud)
           indices_->resize (cloud->points.size ());
           for (std::size_t i = 0; i < cloud->points.size (); ++i) 
-            (*indices_)[i] = static_cast<int> (i);
+            (*indices_)[i] = static_cast<index_t> (i);
         }
         shuffled_indices_ = *indices_;
        }
@@ -323,9 +325,9 @@ namespace pcl
         * \param[out] indices the vector of indices that represents the input data.
         */
       inline void 
-      setIndices (const std::vector<int> &indices) 
+      setIndices (const Indices &indices)
       { 
-        indices_.reset (new std::vector<int> (indices));
+        indices_.reset (new Indices (indices));
         shuffled_indices_ = indices;
        }
 
@@ -441,7 +443,7 @@ namespace pcl
         * \param[out] sample the set of indices of target_ to analyze
         */
       inline void
-      drawIndexSample (std::vector<int> &sample)
+      drawIndexSample (Indices &sample)
       {
         std::size_t sample_size = sample.size ();
         std::size_t index_size = shuffled_indices_.size ();
@@ -458,7 +460,7 @@ namespace pcl
         * \param[out] sample the set of indices of target_ to analyze
         */
       inline void
-      drawIndexSampleRadius (std::vector<int> &sample)
+      drawIndexSampleRadius (Indices &sample)
       {
         std::size_t sample_size = sample.size ();
         std::size_t index_size = shuffled_indices_.size ();
@@ -466,7 +468,7 @@ namespace pcl
         std::swap (shuffled_indices_[0], shuffled_indices_[0 + (rnd () % (index_size - 0))]);
         //const PointT& pt0 = (*input_)[shuffled_indices_[0]];
 
-        std::vector<int> indices;
+        Indices indices;
         std::vector<float> sqr_dists;
 
         // If indices have been set when the search object was constructed,
@@ -506,7 +508,7 @@ namespace pcl
       {
         if (model_coefficients.size () != model_size_)
         {
-          PCL_ERROR ("[pcl::%s::isModelValid] Invalid number of model coefficients given (%lu)!\n", getClassName ().c_str (), model_coefficients.size ());
+          PCL_ERROR ("[pcl::%s::isModelValid] Invalid number of model coefficients given (is %lu, should be %lu)!\n", getClassName ().c_str (), model_coefficients.size (), model_size_);
           return (false);
         }
         return (true);
@@ -517,7 +519,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       virtual bool
-      isSampleGood (const std::vector<int> &samples) const = 0;
+      isSampleGood (const Indices &samples) const = 0;
 
       /** \brief The model name. */
       std::string model_name_;
@@ -543,7 +545,7 @@ namespace pcl
       SearchPtr samples_radius_search_;
 
       /** Data containing a shuffled version of the indices. This is used and modified when drawing samples. */
-      std::vector<int> shuffled_indices_;
+      Indices shuffled_indices_;
 
       /** \brief Boost-based random number generator algorithm. */
       boost::mt19937 rng_alg_;
index b1ef12b0c158ffd6b17c6c90a1bd56420d89f2f9..2f8410155650845a7c113eca60a05fb0307d296a 100644 (file)
@@ -91,7 +91,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelCircle2D (const PointCloudConstPtr &cloud, 
-                                    const std::vector<int> &indices,
+                                    const Indices &indices,
                                     bool random = false)
         : SampleConsensusModel<PointT> (cloud, indices, random)
       {
@@ -129,7 +129,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the cloud data to a given 2D circle model.
@@ -148,7 +148,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -167,7 +167,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -178,7 +178,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -189,7 +189,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -211,7 +211,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood(const std::vector<int> &samples) const override;
+      isSampleGood(const Indices &samples) const override;
 
     private:
       /** \brief Functor for the optimization function */
@@ -221,7 +221,7 @@ namespace pcl
           * \param[in] indices the indices of data points to evaluate
           * \param[in] estimator pointer to the estimator object
           */
-        OptimizationFunctor (const pcl::SampleConsensusModelCircle2D<PointT> *model, const std::vector<int>& indices) :
+        OptimizationFunctor (const pcl::SampleConsensusModelCircle2D<PointT> *model, const Indices& indices) :
           pcl::Functor<float> (indices.size ()), model_ (model), indices_ (indices) {}
 
         /** Cost function to be minimized
@@ -245,7 +245,7 @@ namespace pcl
         }
 
         const pcl::SampleConsensusModelCircle2D<PointT> *model_;
-        const std::vector<int> &indices_;
+        const Indices &indices_;
       };
   };
 }
index 28d8a335deda1dc02d3ab761e0ef91ad0aa1fc0c..966abd05c1643d8ba934211dad918e09a365e475 100644 (file)
@@ -92,7 +92,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelCircle3D (const PointCloudConstPtr &cloud, 
-                                    const std::vector<int> &indices,
+                                    const Indices &indices,
                                     bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
       {
@@ -130,7 +130,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the cloud data to a given 3D circle model.
@@ -149,7 +149,7 @@ namespace pcl
       void
       selectWithinDistance (const Eigen::VectorXf &model_coefficients,
                             const double threshold,
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers.
         *
@@ -168,7 +168,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -179,7 +179,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -190,7 +190,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -212,7 +212,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood(const std::vector<int> &samples) const override;
+      isSampleGood(const Indices &samples) const override;
 
     private:
       /** \brief Functor for the optimization function */
@@ -222,7 +222,7 @@ namespace pcl
           * \param[in] indices the indices of data points to evaluate
           * \param[in] estimator pointer to the estimator object
           */
-        OptimizationFunctor (const pcl::SampleConsensusModelCircle3D<PointT> *model, const std::vector<int>& indices) :
+        OptimizationFunctor (const pcl::SampleConsensusModelCircle3D<PointT> *model, const Indices& indices) :
           pcl::Functor<double> (indices.size ()), model_ (model), indices_ (indices) {}
 
        /** Cost function to be minimized
@@ -262,7 +262,7 @@ namespace pcl
         }
 
         const pcl::SampleConsensusModelCircle3D<PointT> *model_;
-        const std::vector<int> &indices_;
+        const Indices &indices_;
       };
   };
 }
index a607e0da0ae32239088cdbcefd165c861ad8d406..230da26a5963db5cc5940760d0cbec76f57dec93 100644 (file)
@@ -103,7 +103,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelCone (const PointCloudConstPtr &cloud, 
-                                const std::vector<int> &indices,
+                                const Indices &indices,
                                 bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
         , SampleConsensusModelFromNormals<PointT, PointNT> ()
@@ -197,7 +197,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the cloud data to a given cone model.
@@ -216,7 +216,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -236,7 +236,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -248,7 +248,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -259,7 +259,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -289,7 +289,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const override;
+      isSampleGood (const Indices &samples) const override;
 
     private:
       /** \brief The axis along which we need to search for a cone direction. */
@@ -309,7 +309,7 @@ namespace pcl
           * \param[in] indices the indices of data points to evaluate
           * \param[in] estimator pointer to the estimator object
           */
-        OptimizationFunctor (const pcl::SampleConsensusModelCone<PointT, PointNT> *model, const std::vector<int>& indices) :
+        OptimizationFunctor (const pcl::SampleConsensusModelCone<PointT, PointNT> *model, const Indices& indices) :
           pcl::Functor<float> (indices.size ()), model_ (model), indices_ (indices) {}
 
         /** Cost function to be minimized
@@ -348,7 +348,7 @@ namespace pcl
         }
 
         const pcl::SampleConsensusModelCone<PointT, PointNT> *model_;
-        const std::vector<int> &indices_;
+        const Indices &indices_;
       };
   };
 }
index eda0f89f4392de12ec008767d40ea17614b65e13..98800841de15f231d72e0c81a55be23a93ffbfe4 100644 (file)
@@ -101,7 +101,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelCylinder (const PointCloudConstPtr &cloud, 
-                                    const std::vector<int> &indices,
+                                    const Indices &indices,
                                     bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
         , SampleConsensusModelFromNormals<PointT, PointNT> ()
@@ -169,7 +169,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the cloud data to a given cylinder model.
@@ -188,7 +188,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -207,7 +207,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -219,7 +219,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -230,7 +230,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -288,7 +288,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const override;
+      isSampleGood (const Indices &samples) const override;
 
     private:
       /** \brief The axis along which we need to search for a cylinder direction. */
@@ -304,7 +304,7 @@ namespace pcl
           * \param[in] indices the indices of data points to evaluate
           * \param[in] estimator pointer to the estimator object
           */
-        OptimizationFunctor (const pcl::SampleConsensusModelCylinder<PointT, PointNT> *model, const std::vector<int>& indices) :
+        OptimizationFunctor (const pcl::SampleConsensusModelCylinder<PointT, PointNT> *model, const Indices& indices) :
           pcl::Functor<float> (indices.size ()), model_ (model), indices_ (indices) {}
 
         /** Cost function to be minimized
@@ -331,7 +331,7 @@ namespace pcl
         }
 
         const pcl::SampleConsensusModelCylinder<PointT, PointNT> *model_;
-        const std::vector<int> &indices_;
+        const Indices &indices_;
       };
   };
 }
index db66a67b4c0c99b577e9c9dbfdb79e2a5a85aa84..d948276af15e3a8b1688712b741cdaf5955d347f 100644 (file)
@@ -93,7 +93,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelLine (const PointCloudConstPtr &cloud, 
-                                const std::vector<int> &indices,
+                                const Indices &indices,
                                 bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
       {
@@ -112,7 +112,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all squared distances from the cloud data to a given line model.
@@ -131,7 +131,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -150,7 +150,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -161,7 +161,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -172,7 +172,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -189,7 +189,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const override;
+      isSampleGood (const Indices &samples) const override;
   };
 }
 
index e6944d95da472096efdb844ed3848e428a690ff2..d92cf870bce9318e965408b06cc8eefe1c1c67e1 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <pcl/sample_consensus/sac_model_normal_plane.h>
 #include <pcl/sample_consensus/model_types.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
@@ -126,7 +127,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelNormalParallelPlane (const PointCloudConstPtr &cloud, 
-                                               const std::vector<int> &indices,
+                                               const Indices &indices,
                                                bool random = false) 
         : SampleConsensusModelNormalPlane<PointT, PointNT> (cloud, indices, random)
         , axis_ (Eigen::Vector4f::Zero ())
index 6ae57f9e37866bc238393290cdbd4b7e7cf5e53a..fb532501185ef7b3bd0a1b63cb8cc393d85f6ea0 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/sample_consensus/sac_model.h>
 #include <pcl/sample_consensus/sac_model_plane.h>
@@ -114,7 +115,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelNormalPlane (const PointCloudConstPtr &cloud, 
-                                       const std::vector<int> &indices,
+                                       const Indices &indices,
                                        bool random = false) 
         : SampleConsensusModelPlane<PointT> (cloud, indices, random)
         , SampleConsensusModelFromNormals<PointT, PointNT> ()
@@ -135,7 +136,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
index 91bb0a1092f20fdb0ed248b0e39ef5c47f7fc485..7b149b82fa2a6698c90a10a862f9a65999bfb35a 100644 (file)
@@ -44,6 +44,7 @@
 #include <pcl/sample_consensus/sac_model_sphere.h>
 #include <pcl/sample_consensus/model_types.h>
 #include <pcl/common/common.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
@@ -108,7 +109,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelNormalSphere (const PointCloudConstPtr &cloud, 
-                                        const std::vector<int> &indices,
+                                        const Indices &indices,
                                         bool random = false) 
         : SampleConsensusModelSphere<PointT> (cloud, indices, random)
         , SampleConsensusModelFromNormals<PointT, PointNT> ()
@@ -129,7 +130,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * \param[in] model_coefficients the coefficients of a model that we need to compute distances to
@@ -157,13 +158,7 @@ namespace pcl
     protected:
       using SampleConsensusModel<PointT>::sample_size_;
       using SampleConsensusModel<PointT>::model_size_;
-
-      /** \brief Check whether a model is valid given the user constraints.
-        * \param[in] model_coefficients the set of model coefficients
-        */
-      bool
-      isModelValid (const Eigen::VectorXf &model_coefficients) const override;
-
+      using SampleConsensusModelSphere<PointT>::isModelValid;
   };
 }
 
index 6e0d18cc416bb767b88d3b9f763300b4cc30e078..c3cd3debedec8c1dd88b9f7395b40ce0a41a5054 100644 (file)
@@ -95,7 +95,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelParallelLine (const PointCloudConstPtr &cloud,
-                                        const std::vector<int> &indices,
+                                        const Indices &indices,
                                         bool random = false)
         : SampleConsensusModelLine<PointT> (cloud, indices, random)
         , axis_ (Eigen::Vector3f::Zero ())
@@ -136,7 +136,7 @@ namespace pcl
       void
       selectWithinDistance (const Eigen::VectorXf &model_coefficients,
                             const double threshold,
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers.
         *
index 3697adf0a66f3c8f013135289203c0a72f49d805..8d17ad2074a54a1c15f11e5f5a99896b59d0f434 100644 (file)
@@ -97,7 +97,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelParallelPlane (const PointCloudConstPtr &cloud, 
-                                         const std::vector<int> &indices,
+                                         const Indices &indices,
                                          bool random = false) 
         : SampleConsensusModelPlane<PointT> (cloud, indices, random)
         , axis_ (Eigen::Vector3f::Zero ())
@@ -141,7 +141,7 @@ namespace pcl
       void
       selectWithinDistance (const Eigen::VectorXf &model_coefficients,
                             const double threshold,
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers.
         *
index a449707278048f2c170c9234aaee0b30f04c67b0..ebf061b94f98c9d624f9940a82baa85ba35e1a3b 100644 (file)
@@ -101,7 +101,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelPerpendicularPlane (const PointCloudConstPtr &cloud, 
-                                              const std::vector<int> &indices,
+                                              const Indices &indices,
                                               bool random = false) 
         : SampleConsensusModelPlane<PointT> (cloud, indices, random)
         , axis_ (Eigen::Vector3f::Zero ())
@@ -144,7 +144,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
index bd447b8eb100cfe6f994f0fe11d53a1d838fbdf8..6bcfedd2248550097f006d7d8ab83ffe3190ec09 100644 (file)
@@ -166,7 +166,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelPlane (const PointCloudConstPtr &cloud, 
-                                 const std::vector<int> &indices,
+                                 const Indices &indices,
                                  bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
       {
@@ -185,7 +185,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the cloud data to a given plane model.
@@ -204,7 +204,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -223,7 +223,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -234,7 +234,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -245,7 +245,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -263,7 +263,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const override;
+      isSampleGood (const Indices &samples) const override;
   };
 }
 
index 04dae537a7d8559dfe3c793faf29bb901a0193f8..f649a726fea01bad3836f0a811e13d75609a47cc 100644 (file)
@@ -40,6 +40,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/pcl_base.h>
 #include <pcl/sample_consensus/eigen.h>
@@ -95,7 +96,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelRegistration (const PointCloudConstPtr &cloud,
-                                        const std::vector<int> &indices,
+                                        const Indices &indices,
                                         bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
         , target_ ()
@@ -129,7 +130,7 @@ namespace pcl
       setInputTarget (const PointCloudConstPtr &target)
       {
         target_ = target;
-        indices_tgt_.reset (new std::vector<int>);
+        indices_tgt_.reset (new Indices);
         // Cache the size and fill the target indices
         int target_size = static_cast<int> (target->size ());
         indices_tgt_->resize (target_size);
@@ -144,10 +145,10 @@ namespace pcl
         * \param[in] indices_tgt a vector of point indices to be used from \a target
         */
       inline void
-      setInputTarget (const PointCloudConstPtr &target, const std::vector<int> &indices_tgt)
+      setInputTarget (const PointCloudConstPtr &target, const Indices &indices_tgt)
       {
         target_ = target;
-        indices_tgt_.reset (new std::vector<int> (indices_tgt));
+        indices_tgt_.reset (new Indices (indices_tgt));
         computeOriginalIndexMapping ();
       }
 
@@ -156,7 +157,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the transformed points to their correspondences
@@ -175,7 +176,7 @@ namespace pcl
       void
       selectWithinDistance (const Eigen::VectorXf &model_coefficients,
                             const double threshold,
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers.
         *
@@ -193,19 +194,19 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed transformation
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
       void
-      projectPoints (const std::vector<int> &,
+      projectPoints (const Indices &,
                      const Eigen::VectorXf &,
                      PointCloud &, bool = true) const override
       {
       };
 
       bool
-      doSamplesVerifyModel (const std::set<int> &,
+      doSamplesVerifyModel (const std::set<index_t> &,
                             const Eigen::VectorXf &,
                             const double) const override
       {
@@ -225,7 +226,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const override;
+      isSampleGood (const Indices &samples) const override;
 
       /** \brief Computes an "optimal" sample distance threshold based on the
         * principal directions of the input cloud.
@@ -262,7 +263,7 @@ namespace pcl
         */
       inline void
       computeSampleDistanceThreshold (const PointCloudConstPtr &cloud,
-                                      const std::vector<int> &indices)
+                                      const Indices &indices)
       {
         // Compute the principal directions via PCA
         Eigen::Vector4f xyz_centroid;
@@ -297,9 +298,9 @@ namespace pcl
       */
       void
       estimateRigidTransformationSVD (const pcl::PointCloud<PointT> &cloud_src,
-                                      const std::vector<int> &indices_src,
+                                      const Indices &indices_src,
                                       const pcl::PointCloud<PointT> &cloud_tgt,
-                                      const std::vector<int> &indices_tgt,
+                                      const Indices &indices_tgt,
                                       Eigen::VectorXf &transform) const;
 
       /** \brief Compute mappings between original indices of the input_/target_ clouds. */
index 2f508d0b5973d41ef81624445d5214b0239d743e..82f16adef475619a28a6444b682058f1f87e0233 100644 (file)
@@ -39,6 +39,7 @@
 #pragma once
 
 #include <pcl/sample_consensus/sac_model_registration.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
@@ -91,7 +92,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelRegistration2D (const PointCloudConstPtr &cloud,
-                                          const std::vector<int> &indices,
+                                          const Indices &indices,
                                           bool random = false)
         : pcl::SampleConsensusModelRegistration<PointT> (cloud, indices, random)
         , projection_matrix_ (Eigen::Matrix3f::Identity ())
@@ -122,7 +123,7 @@ namespace pcl
       void
       selectWithinDistance (const Eigen::VectorXf &model_coefficients,
                             const double threshold,
-                            std::vector<int> &inliers);
+                            Indices &inliers);
 
       /** \brief Count all the points which respect the given model coefficients as inliers.
         *
@@ -155,7 +156,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const;
+      isSampleGood (const Indices &samples) const;
 
       /** \brief Computes an "optimal" sample distance threshold based on the
         * principal directions of the input cloud.
@@ -189,7 +190,7 @@ namespace pcl
         */
       inline void
       computeSampleDistanceThreshold (const PointCloudConstPtr&,
-                                      const std::vector<int>&)
+                                      const Indices&)
       {
         //// Compute the principal directions via PCA
         //Eigen::Vector4f xyz_centroid;
index ae00f8147b8c86785ce4307ba3ca6bed807d6277..c6f460a4bce58cd0b3b2bd9d8573cf71356eb645 100644 (file)
@@ -92,7 +92,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelSphere (const PointCloudConstPtr &cloud,
-                                  const std::vector<int> &indices,
+                                  const Indices &indices,
                                   bool random = false)
         : SampleConsensusModel<PointT> (cloud, indices, random)
       {
@@ -131,7 +131,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all distances from the cloud data to a given sphere model.
@@ -150,7 +150,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -169,7 +169,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -181,7 +181,7 @@ namespace pcl
         * \todo implement this.
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -192,7 +192,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -225,7 +225,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood(const std::vector<int> &samples) const override;
+      isSampleGood(const Indices &samples) const override;
 
     private:
       struct OptimizationFunctor : pcl::Functor<float>
@@ -234,7 +234,7 @@ namespace pcl
           * \param[in] indices the indices of data points to evaluate
           * \param[in] estimator pointer to the estimator object
           */
-        OptimizationFunctor (const pcl::SampleConsensusModelSphere<PointT> *model, const std::vector<int>& indices) :
+        OptimizationFunctor (const pcl::SampleConsensusModelSphere<PointT> *model, const Indices& indices) :
           pcl::Functor<float> (indices.size ()), model_ (model), indices_ (indices) {}
 
         /** Cost function to be minimized
@@ -261,7 +261,7 @@ namespace pcl
         }
 
         const pcl::SampleConsensusModelSphere<PointT> *model_;
-        const std::vector<int> &indices_;
+        const Indices &indices_;
       };
    };
 }
index 865997f9efcd6ef1b49b50814c33ebe4002d1bd7..e3821a25351698156351788d94e872a707fb945e 100644 (file)
@@ -98,7 +98,7 @@ namespace pcl
         * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
         */
       SampleConsensusModelStick (const PointCloudConstPtr &cloud, 
-                                 const std::vector<int> &indices,
+                                 const Indices &indices,
                                  bool random = false) 
         : SampleConsensusModel<PointT> (cloud, indices, random)
       {
@@ -117,7 +117,7 @@ namespace pcl
         * \param[out] model_coefficients the resultant model coefficients
         */
       bool
-      computeModelCoefficients (const std::vector<int> &samples,
+      computeModelCoefficients (const Indices &samples,
                                 Eigen::VectorXf &model_coefficients) const override;
 
       /** \brief Compute all squared distances from the cloud data to a given stick model.
@@ -136,7 +136,7 @@ namespace pcl
       void 
       selectWithinDistance (const Eigen::VectorXf &model_coefficients, 
                             const double threshold, 
-                            std::vector<int> &inliers) override;
+                            Indices &inliers) override;
 
       /** \brief Count all the points which respect the given model coefficients as inliers. 
         * 
@@ -155,7 +155,7 @@ namespace pcl
         * \param[out] optimized_coefficients the resultant recomputed coefficients after optimization
         */
       void
-      optimizeModelCoefficients (const std::vector<int> &inliers,
+      optimizeModelCoefficients (const Indices &inliers,
                                  const Eigen::VectorXf &model_coefficients,
                                  Eigen::VectorXf &optimized_coefficients) const override;
 
@@ -166,7 +166,7 @@ namespace pcl
         * \param[in] copy_data_fields set to true if we need to copy the other data fields
         */
       void
-      projectPoints (const std::vector<int> &inliers,
+      projectPoints (const Indices &inliers,
                      const Eigen::VectorXf &model_coefficients,
                      PointCloud &projected_points,
                      bool copy_data_fields = true) const override;
@@ -177,7 +177,7 @@ namespace pcl
         * \param[in] threshold a maximum admissible distance threshold for determining the inliers from the outliers
         */
       bool
-      doSamplesVerifyModel (const std::set<int> &indices,
+      doSamplesVerifyModel (const std::set<index_t> &indices,
                             const Eigen::VectorXf &model_coefficients,
                             const double threshold) const override;
 
@@ -194,7 +194,7 @@ namespace pcl
         * \param[in] samples the resultant index samples
         */
       bool
-      isSampleGood (const std::vector<int> &samples) const override;
+      isSampleGood (const Indices &samples) const override;
   };
 }
 
index ec97f4a642ade8b840344762f50a8d778a41fdbd..4104e1fc1217ff2d6e171dd4e16496562749422b 100644 (file)
@@ -53,8 +53,8 @@ namespace pcl
       using PointCloud = typename Search<PointT>::PointCloud;
       using PointCloudConstPtr = typename Search<PointT>::PointCloudConstPtr;
 
-      using IndicesPtr = shared_ptr<std::vector<int> >;
-      using IndicesConstPtr = shared_ptr<const std::vector<int> >;
+      using IndicesPtr = pcl::IndicesPtr;
+      using IndicesConstPtr = pcl::IndicesConstPtr;
 
       using pcl::search::Search<PointT>::input_;
       using pcl::search::Search<PointT>::indices_;
@@ -62,10 +62,10 @@ namespace pcl
 
       struct Entry
       {
-        Entry (int idx, float dist) : index (idx), distance (dist) {}
+        Entry (index_t idx, float dist) : index (idx), distance (dist) {}
 
         Entry () : index (0), distance (0) {}
-        unsigned index;
+        index_t index;
         float distance;
         
         inline bool 
@@ -104,7 +104,7 @@ namespace pcl
           * \return number of neighbors found
           */
         int
-        nearestKSearch (const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const override;
+        nearestKSearch (const PointT &point, int k, Indices &k_indices, std::vector<float> &k_distances) const override;
 
         /** \brief Search for all the nearest neighbors of the query point in a given radius.
           * \param[in] point the given query point
@@ -118,24 +118,24 @@ namespace pcl
           */
         int
         radiusSearch (const PointT& point, double radius,
-                      std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+                      Indices &k_indices, std::vector<float> &k_sqr_distances,
                       unsigned int max_nn = 0) const override;
 
       private:
         int
-        denseKSearch (const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const;
+        denseKSearch (const PointT &point, int k, Indices &k_indices, std::vector<float> &k_distances) const;
 
         int
-        sparseKSearch (const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const;
+        sparseKSearch (const PointT &point, int k, Indices &k_indices, std::vector<float> &k_distances) const;
 
         int
         denseRadiusSearch (const PointT& point, double radius,
-                           std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+                           Indices &k_indices, std::vector<float> &k_sqr_distances,
                            unsigned int max_nn = 0) const;
 
         int
         sparseRadiusSearch (const PointT& point, double radius,
-                            std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+                            Indices &k_indices, std::vector<float> &k_sqr_distances,
                             unsigned int max_nn = 0) const;
     };
   }
index 95f61056d6b2606a28d755c7420c9f022234efdb..80b448c47ba104a6408306ad4106281f65052906 100644 (file)
@@ -87,9 +87,9 @@ namespace pcl
       * search.setInputCloud (target);
       * 
       * // Do search
-      * std::vector<std::vector<int> > k_indices;
+      * std::vector<Indices> k_indices;
       * std::vector<std::vector<float> > k_sqr_distances;
-      * search.nearestKSearch (*query, std::vector<int> (), 2, k_indices, k_sqr_distances);
+      * search.nearestKSearch (*query, Indices (), 2, k_indices, k_sqr_distances);
       * \endcode
       *
       * \author Andreas Muetzel
@@ -110,9 +110,6 @@ namespace pcl
         using PointCloud = typename Search<PointT>::PointCloud;
         using PointCloudConstPtr = typename Search<PointT>::PointCloudConstPtr;
 
-        using typename Search<PointT>::IndicesPtr;
-        using typename Search<PointT>::IndicesConstPtr;
-
         using MatrixPtr = shared_ptr<flann::Matrix<float> >;
         using MatrixConstPtr = shared_ptr<const flann::Matrix<float> >;
 
@@ -260,6 +257,8 @@ namespace pcl
         void
         setInputCloud (const PointCloudConstPtr& cloud, const IndicesConstPtr& indices = IndicesConstPtr ()) override;
 
+        using Search<PointT>::nearestKSearch;
+
         /** \brief Search for the k-nearest neighbors for the given query point.
           * \param[in] point the given query point
           * \param[in] k the number of neighbors to search for
@@ -269,7 +268,7 @@ namespace pcl
           * \return number of neighbors found
           */
         int
-        nearestKSearch (const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances) const override;
+        nearestKSearch (const PointT &point, int k, Indices &k_indices, std::vector<float> &k_sqr_distances) const override;
 
 
         /** \brief Search for the k-nearest neighbors for the given query point.
@@ -280,8 +279,8 @@ namespace pcl
           * \param[out] k_sqr_distances the resultant squared distances to the neighboring points, k_sqr_distances[i] corresponds to the neighbors of the query point i
           */
         void
-        nearestKSearch (const PointCloud& cloud, const std::vector<int>& indices, int k, 
-                        std::vector< std::vector<int> >& k_indices, std::vector< std::vector<float> >& k_sqr_distances) const override;
+        nearestKSearch (const PointCloud& cloud, const Indices& indices, int k,
+                        std::vector<Indices>& k_indices, std::vector< std::vector<float> >& k_sqr_distances) const override;
 
         /** \brief Search for all the nearest neighbors of the query point in a given radius.
           * \param[in] point the given query point
@@ -295,7 +294,7 @@ namespace pcl
           */
         int
         radiusSearch (const PointT& point, double radius, 
-                      std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+                      Indices &k_indices, std::vector<float> &k_sqr_distances,
                       unsigned int max_nn = 0) const override;
 
         /** \brief Search for the k-nearest neighbors for the given query point.
@@ -307,7 +306,7 @@ namespace pcl
           * \param[in] max_nn if given, bounds the maximum returned neighbors to this value
           */
         void
-        radiusSearch (const PointCloud& cloud, const std::vector<int>& indices, double radius, std::vector< std::vector<int> >& k_indices,
+        radiusSearch (const PointCloud& cloud, const Indices& indices, double radius, std::vector<Indices>& k_indices,
                 std::vector< std::vector<float> >& k_sqr_distances, unsigned int max_nn=0) const override;
 
         /** \brief Provide a pointer to the point representation to use to convert points into k-D vectors.
@@ -361,7 +360,7 @@ namespace pcl
 
         int dim_;
 
-        std::vector<int> index_mapping_;
+        Indices index_mapping_;
         bool identity_mapping_;
 
     };
index 118d238c0aa93b4cdeba2778555d88b0f0d85724..8461e594628fa14a31407a6049cc584e3248d766 100644 (file)
@@ -35,9 +35,9 @@
  *
  */
 
-#ifndef PCL_SEARCH_IMPL_BRUTE_FORCE_SEARCH_H_
-#define PCL_SEARCH_IMPL_BRUTE_FORCE_SEARCH_H_
+#pragma once
 
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/search/brute_force.h>
 #include <queue>
 
@@ -52,7 +52,7 @@ pcl::search::BruteForce<PointT>::getDistSqr (
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::BruteForce<PointT>::nearestKSearch (
-    const PointT& point, int k, std::vector<int>& k_indices, std::vector<float>& k_distances) const
+    const PointT& point, int k, Indices& k_indices, std::vector<float>& k_distances) const
 {
   assert (isFinite (point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!");
   
@@ -69,7 +69,7 @@ pcl::search::BruteForce<PointT>::nearestKSearch (
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::BruteForce<PointT>::denseKSearch (
-    const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const
+    const PointT &point, int k, Indices &k_indices, std::vector<float> &k_distances) const
 {
   // container for first k elements -> O(1) for insertion, since order not required here
   std::vector<Entry> result;
@@ -77,8 +77,8 @@ pcl::search::BruteForce<PointT>::denseKSearch (
   std::priority_queue<Entry> queue;
   if (indices_)
   {
-    std::vector<int>::const_iterator iIt =indices_->begin ();
-    std::vector<int>::const_iterator iEnd = indices_->begin () + std::min (static_cast<unsigned> (k), static_cast<unsigned> (indices_->size ()));
+    auto iIt = indices_->cbegin ();
+    auto iEnd = indices_->cbegin () + std::min (static_cast<unsigned> (k), static_cast<unsigned> (indices_->size ()));
     for (; iIt != iEnd; ++iIt)
       result.push_back (Entry (*iIt, getDistSqr (input_->points[*iIt], point)));
 
@@ -86,7 +86,7 @@ pcl::search::BruteForce<PointT>::denseKSearch (
 
     // add the rest
     Entry entry;
-    for (; iIt != indices_->end (); ++iIt)
+    for (; iIt != indices_->cend (); ++iIt)
     {
       entry.distance = getDistSqr (input_->points[*iIt], point);
       if (queue.top ().distance > entry.distance)
@@ -100,7 +100,7 @@ pcl::search::BruteForce<PointT>::denseKSearch (
   else
   {
     Entry entry;
-    for (entry.index = 0; entry.index < std::min (static_cast<unsigned> (k), static_cast<unsigned> (input_->size ())); ++entry.index)
+    for (entry.index = 0; entry.index < std::min<pcl::index_t> (k, input_->size ()); ++entry.index)
     {
       entry.distance = getDistSqr (input_->points[entry.index], point);
       result.push_back (entry);
@@ -109,7 +109,7 @@ pcl::search::BruteForce<PointT>::denseKSearch (
     queue = std::priority_queue<Entry> (result.begin (), result.end ());
 
     // add the rest
-    for (; entry.index < input_->size (); ++entry.index)
+    for (; entry.index < static_cast<pcl::index_t>(input_->size ()); ++entry.index)
     {
       entry.distance = getDistSqr (input_->points[entry.index], point);
       if (queue.top ().distance > entry.distance)
@@ -137,7 +137,7 @@ pcl::search::BruteForce<PointT>::denseKSearch (
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::BruteForce<PointT>::sparseKSearch (
-    const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const
+    const PointT &point, int k, Indices &k_indices, std::vector<float> &k_distances) const
 {
   // result used to collect the first k neighbors -> unordered
   std::vector<Entry> result;
@@ -146,8 +146,8 @@ pcl::search::BruteForce<PointT>::sparseKSearch (
   std::priority_queue<Entry> queue;
   if (indices_)
   {
-    std::vector<int>::const_iterator iIt =indices_->begin ();
-    for (; iIt != indices_->end () && result.size () < static_cast<unsigned> (k); ++iIt)
+    auto iIt =indices_->cbegin ();
+    for (; iIt != indices_->cend () && result.size () < static_cast<unsigned> (k); ++iIt)
     {
       if (std::isfinite (input_->points[*iIt].x))
         result.push_back (Entry (*iIt, getDistSqr (input_->points[*iIt], point)));
@@ -158,7 +158,7 @@ pcl::search::BruteForce<PointT>::sparseKSearch (
     // either we have k elements, or there are none left to iterate >in either case we're fine
     // add the rest
     Entry entry;
-    for (; iIt != indices_->end (); ++iIt)
+    for (; iIt != indices_->cend (); ++iIt)
     {
       if (!std::isfinite (input_->points[*iIt].x))
         continue;
@@ -175,7 +175,7 @@ pcl::search::BruteForce<PointT>::sparseKSearch (
   else
   {
     Entry entry;
-    for (entry.index = 0; entry.index < input_->size () && result.size () < static_cast<unsigned> (k); ++entry.index)
+    for (entry.index = 0; (entry.index < static_cast<pcl::index_t>(input_->size ())) && (result.size () < static_cast<std::size_t> (k)); ++entry.index)
     {
       if (std::isfinite (input_->points[entry.index].x))
       {
@@ -186,7 +186,7 @@ pcl::search::BruteForce<PointT>::sparseKSearch (
     queue = std::priority_queue<Entry> (result.begin (), result.end ());
     
     // add the rest
-    for (; entry.index < input_->size (); ++entry.index)
+    for (; entry.index < static_cast<pcl::index_t>(input_->size ()); ++entry.index)
     {
       if (!std::isfinite (input_->points[entry.index].x))
         continue;
@@ -217,7 +217,7 @@ pcl::search::BruteForce<PointT>::sparseKSearch (
 template <typename PointT> int
 pcl::search::BruteForce<PointT>::denseRadiusSearch (
     const PointT& point, double radius,
-    std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+    Indices &k_indices, std::vector<float> &k_sqr_distances,
     unsigned int max_nn) const
 {  
   radius *= radius;
@@ -235,12 +235,12 @@ pcl::search::BruteForce<PointT>::denseRadiusSearch (
   float distance;
   if (indices_)
   {
-    for (std::vector<int>::const_iterator iIt =indices_->begin (); iIt != indices_->end (); ++iIt)
+    for (const auto& idx : *indices_)
     {
-      distance = getDistSqr (input_->points[*iIt], point);
+      distance = getDistSqr (input_->points[idx], point);
       if (distance <= radius)
       {
-        k_indices.push_back (*iIt);
+        k_indices.push_back (idx);
         k_sqr_distances.push_back (distance);
         if (k_indices.size () == max_nn) // max_nn = 0 -> never true
           break;
@@ -272,7 +272,7 @@ pcl::search::BruteForce<PointT>::denseRadiusSearch (
 template <typename PointT> int
 pcl::search::BruteForce<PointT>::sparseRadiusSearch (
     const PointT& point, double radius,
-    std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+    Indices &k_indices, std::vector<float> &k_sqr_distances,
     unsigned int max_nn) const
 {
   radius *= radius;
@@ -291,15 +291,15 @@ pcl::search::BruteForce<PointT>::sparseRadiusSearch (
   float distance;
   if (indices_)
   {
-    for (std::vector<int>::const_iterator iIt =indices_->begin (); iIt != indices_->end (); ++iIt)
+    for (const auto& idx : *indices_)
     {
-      if (!std::isfinite (input_->points[*iIt].x))
+      if (!std::isfinite (input_->points[idx].x))
         continue;
 
-      distance = getDistSqr (input_->points[*iIt], point);
+      distance = getDistSqr (input_->points[idx], point);
       if (distance <= radius)
       {
-        k_indices.push_back (*iIt);
+        k_indices.push_back (idx);
         k_sqr_distances.push_back (distance);
         if (k_indices.size () == max_nn) // never true if max_nn = 0
           break;
@@ -332,7 +332,7 @@ pcl::search::BruteForce<PointT>::sparseRadiusSearch (
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::BruteForce<PointT>::radiusSearch (
-    const PointT& point, double radius, std::vector<int> &k_indices,
+    const PointT& point, double radius, Indices &k_indices,
     std::vector<float> &k_sqr_distances, unsigned int max_nn) const
 {
   assert (isFinite (point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!");
@@ -348,5 +348,3 @@ pcl::search::BruteForce<PointT>::radiusSearch (
 }
 
 #define PCL_INSTANTIATE_BruteForce(T) template class PCL_EXPORTS pcl::search::BruteForce<T>;
-
-#endif //PCL_SEARCH_IMPL_BRUTE_FORCE_SEARCH_H_
index baf01e1e8157a51f0430ae6f8f48ef47110282ba..1b38f6cfeee717c488fc92027dd48ac653599b16 100644 (file)
@@ -100,7 +100,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::setInputCloud (const PointCloud
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename FlannDistance> int
-pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (const PointT &point, int k, std::vector<int> &indices, std::vector<float> &dists) const
+pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (const PointT &point, int k, Indices &indices, std::vector<float> &dists) const
 {
   assert (point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); // remove this check as soon as FLANN does NaN checks internally
   bool can_cast = point_representation_->isTrivial ();
@@ -123,7 +123,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (const PointT &p
     indices.resize (k,-1);
   if (dists.size() != static_cast<unsigned int> (k))
     dists.resize (k);
-  flann::Matrix<int> i (&indices[0],1,k);
+  flann::Matrix<index_t> i (&indices[0],1,k);
   flann::Matrix<float> d (&dists[0],1,k);
   int result = index_->knnSearch (m,i,d,k, p);
 
@@ -133,7 +133,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (const PointT &p
   {
     for (std::size_t i = 0; i < static_cast<unsigned int> (k); ++i)
     {
-      int& neighbor_index = indices[i];
+      auto& neighbor_index = indices[i];
       neighbor_index = index_mapping_[neighbor_index];
     }
   }
@@ -143,7 +143,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (const PointT &p
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename FlannDistance> void
 pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (
-    const PointCloud& cloud, const std::vector<int>& indices, int k, std::vector< std::vector<int> >& k_indices,
+    const PointCloud& cloud, const Indices& indices, int k, std::vector<Indices>& k_indices,
     std::vector< std::vector<float> >& k_sqr_distances) const
 {
   if (indices.empty ())
@@ -219,7 +219,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (
   {
     for (auto &k_index : k_indices)
     {
-      for (int &neighbor_index : k_index)
+      for (auto &neighbor_index : k_index)
       {
         neighbor_index = index_mapping_[neighbor_index];
       }
@@ -230,7 +230,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::nearestKSearch (
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename FlannDistance> int
 pcl::search::FlannSearch<PointT, FlannDistance>::radiusSearch (const PointT& point, double radius,
-    std::vector<int> &indices, std::vector<float> &distances,
+    Indices &indices, std::vector<float> &distances,
     unsigned int max_nn) const
 {
   assert (point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to radiusSearch!"); // remove this check as soon as FLANN does NaN checks internally
@@ -251,7 +251,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::radiusSearch (const PointT& poi
   p.eps = eps_;
   p.max_neighbors = max_nn > 0 ? max_nn : -1;
   p.checks = checks_;
-  std::vector<std::vector<int> > i (1);
+  std::vector<Indices> i (1);
   std::vector<std::vector<float> > d (1);
   int result = index_->radiusSearch (m,i,d,static_cast<float> (radius * radius), p);
 
@@ -261,7 +261,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::radiusSearch (const PointT& poi
 
   if (!identity_mapping_)
   {
-    for (int &neighbor_index : indices)
+    for (auto &neighbor_index : indices)
     {
       neighbor_index = index_mapping_ [neighbor_index];
     }
@@ -272,7 +272,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::radiusSearch (const PointT& poi
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, typename FlannDistance> void
 pcl::search::FlannSearch<PointT, FlannDistance>::radiusSearch (
-    const PointCloud& cloud, const std::vector<int>& indices, double radius, std::vector< std::vector<int> >& k_indices,
+    const PointCloud& cloud, const Indices& indices, double radius, std::vector<Indices>& k_indices,
     std::vector< std::vector<float> >& k_sqr_distances, unsigned int max_nn) const
 {
   if (indices.empty ()) // full point cloud + trivial copy operation = no need to do any conversion/copying to the flann matrix!
@@ -349,7 +349,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::radiusSearch (
   {
     for (auto &k_index : k_indices)
     {
-      for (int &neighbor_index : k_index)
+      for (auto &neighbor_index : k_index)
       {
         neighbor_index = index_mapping_[neighbor_index];
       }
@@ -396,7 +396,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::convertInputToFlannMatrix ()
           continue;
         }
 
-        index_mapping_.push_back (static_cast<int> (i));  // If the returned index should be for the indices vector
+        index_mapping_.push_back (static_cast<index_t> (i));  // If the returned index should be for the indices vector
 
         point_representation_->vectorize (point, cloud_ptr);
         cloud_ptr += dim_;
@@ -410,7 +410,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::convertInputToFlannMatrix ()
     float* cloud_ptr = input_flann_->ptr();
     for (std::size_t indices_index = 0; indices_index < original_no_of_points; ++indices_index)
     {
-      int cloud_index = (*indices_)[indices_index];
+      index_t cloud_index = (*indices_)[indices_index];
       const PointT&  point = (*input_)[cloud_index];
       // Check if the point is invalid
       if (!point_representation_->isValid (point))
@@ -419,7 +419,7 @@ pcl::search::FlannSearch<PointT, FlannDistance>::convertInputToFlannMatrix ()
         continue;
       }
 
-      index_mapping_.push_back (static_cast<int> (indices_index));  // If the returned index should be for the indices vector
+      index_mapping_.push_back (static_cast<index_t> (indices_index));  // If the returned index should be for the indices vector
 
       point_representation_->vectorize (point, cloud_ptr);
       cloud_ptr += dim_;
index a6d7fb22fd601c9f4e401362e7a3336a950ae8ea..1b79c67dcf6ebcf33459a156c45fbc7c7082cf71 100644 (file)
@@ -86,7 +86,7 @@ pcl::search::KdTree<PointT,Tree>::setInputCloud (
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT, class Tree> int
 pcl::search::KdTree<PointT,Tree>::nearestKSearch (
-    const PointT &point, int k, std::vector<int> &k_indices, 
+    const PointT &point, int k, Indices &k_indices,
     std::vector<float> &k_sqr_distances) const
 {
   return (tree_->nearestKSearch (point, k, k_indices, k_sqr_distances));
@@ -96,7 +96,7 @@ pcl::search::KdTree<PointT,Tree>::nearestKSearch (
 template <typename PointT, class Tree> int
 pcl::search::KdTree<PointT,Tree>::radiusSearch (
     const PointT& point, double radius, 
-    std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+    Indices &k_indices, std::vector<float> &k_sqr_distances,
     unsigned int max_nn) const
 {
   return (tree_->radiusSearch (point, radius, k_indices, k_sqr_distances, max_nn));
index 85438a3063bcb8866aa0c46c0121bef7cb0b9c53..173d7f1eab95110976848809aeff40231adb5197 100644 (file)
  *
  */
 
-#ifndef PCL_SEARCH_IMPL_ORGANIZED_NEIGHBOR_SEARCH_H_
-#define PCL_SEARCH_IMPL_ORGANIZED_NEIGHBOR_SEARCH_H_
+#pragma once
 
 #include <pcl/search/organized.h>
 #include <pcl/common/eigen.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/common/time.h>
 #include <Eigen/Eigenvalues>
 
@@ -49,7 +49,7 @@
 template<typename PointT> int
 pcl::search::OrganizedNeighbor<PointT>::radiusSearch (const               PointT &query,
                                                       const double        radius,
-                                                      std::vector<int>    &k_indices,
+                                                      Indices             &k_indices,
                                                       std::vector<float>  &k_sqr_distances,
                                                       unsigned int        max_nn) const
 {
@@ -116,7 +116,7 @@ pcl::search::OrganizedNeighbor<PointT>::radiusSearch (const               PointT
 template<typename PointT> int
 pcl::search::OrganizedNeighbor<PointT>::nearestKSearch (const PointT &query,
                                                         int k,
-                                                        std::vector<int> &k_indices,
+                                                        Indices &k_indices,
                                                         std::vector<float> &k_sqr_distances) const
 {
   assert (isFinite (query) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!");
@@ -195,8 +195,8 @@ pcl::search::OrganizedNeighbor<PointT>::nearestKSearch (const PointT &query,
       // if upper line of the rectangle is visible and x-extend is not 0
       if (yBegin >= 0 && yBegin < static_cast<int> (input_->height))
       {
-        int idx   = yBegin * input_->width + xFrom;
-        int idxTo = idx + xTo - xFrom;
+        index_t idx   = yBegin * input_->width + xFrom;
+        index_t idxTo = idx + xTo - xFrom;
         for (; idx < idxTo; ++idx)
           stop = testPoint (query, k, results, idx) || stop;
       }
@@ -206,8 +206,8 @@ pcl::search::OrganizedNeighbor<PointT>::nearestKSearch (const PointT &query,
       // if lower line of the rectangle is visible
       if (yEnd > 0 && yEnd <= static_cast<int> (input_->height))
       {
-        int idx   = (yEnd - 1) * input_->width + xFrom;
-        int idxTo = idx + xTo - xFrom;
+        index_t idx   = (yEnd - 1) * input_->width + xFrom;
+        index_t idxTo = idx + xTo - xFrom;
 
         for (; idx < idxTo; ++idx)
           stop = testPoint (query, k, results, idx) || stop;
@@ -223,8 +223,8 @@ pcl::search::OrganizedNeighbor<PointT>::nearestKSearch (const PointT &query,
       {
         if (xBegin >= 0 && xBegin < static_cast<int> (input_->width))
         {
-          int idx   = yFrom * input_->width + xBegin;
-          int idxTo = yTo * input_->width + xBegin;
+          index_t idx   = yFrom * input_->width + xBegin;
+          index_t idxTo = yTo * input_->width + xBegin;
 
           for (; idx < idxTo; idx += input_->width)
             stop = testPoint (query, k, results, idx) || stop;
@@ -232,8 +232,8 @@ pcl::search::OrganizedNeighbor<PointT>::nearestKSearch (const PointT &query,
         
         if (xEnd > 0 && xEnd <= static_cast<int> (input_->width))
         {
-          int idx   = yFrom * input_->width + xEnd - 1;
-          int idxTo = yTo * input_->width + xEnd - 1;
+          index_t idx   = yFrom * input_->width + xEnd - 1;
+          index_t idxTo = yTo * input_->width + xEnd - 1;
 
           for (; idx < idxTo; idx += input_->width)
             stop = testPoint (query, k, results, idx) || stop;
@@ -347,7 +347,7 @@ pcl::search::OrganizedNeighbor<PointT>::estimateProjectionMatrix ()
   const unsigned ySkip = (std::max) (input_->height >> pyramid_level_, unsigned (1));
   const unsigned xSkip = (std::max) (input_->width >> pyramid_level_, unsigned (1));
 
-  std::vector<int> indices;
+  Indices indices;
   indices.reserve (input_->size () >> (pyramid_level_ << 1));
   
   for (unsigned yIdx = 0, idx = 0; yIdx < input_->height; yIdx += ySkip, idx += input_->width * ySkip)
@@ -365,7 +365,7 @@ pcl::search::OrganizedNeighbor<PointT>::estimateProjectionMatrix ()
   
   if (std::abs (residual_sqr) > eps_ * float (indices.size ()))
   {
-    PCL_ERROR ("[pcl::%s::radiusSearch] Input dataset is not from a projective device!\nResidual (MSE) %f, using %d valid points\n", this->getName ().c_str (), residual_sqr / double (indices.size()), indices.size ());
+    PCL_ERROR ("[pcl::%s::estimateProjectionMatrix] Input dataset is not from a projective device!\nResidual (MSE) %f, using %d valid points\n", this->getName ().c_str (), residual_sqr / double (indices.size()), indices.size ());
     return;
   }
 
@@ -388,4 +388,3 @@ pcl::search::OrganizedNeighbor<PointT>::projectPoint (const PointT& point, pcl::
 }
 #define PCL_INSTANTIATE_OrganizedNeighbor(T) template class PCL_EXPORTS pcl::search::OrganizedNeighbor<T>;
 
-#endif
index dbb68804ed572de6e2fc735dbe0f45e27af9342f..600accf5859a4d89eaa8900787024f6ef51d021c 100644 (file)
@@ -83,27 +83,27 @@ pcl::search::Search<PointT>::setInputCloud (
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::Search<PointT>::nearestKSearch (
-    const PointCloud &cloud, int index, int k,
-    std::vector<int> &k_indices, std::vector<float> &k_sqr_distances) const
+    const PointCloud &cloud, index_t index, int k,
+    Indices &k_indices, std::vector<float> &k_sqr_distances) const
 {
-  assert (index >= 0 && index < static_cast<int> (cloud.points.size ()) && "Out-of-bounds error in nearestKSearch!");
+  assert (index >= 0 && index < static_cast<index_t> (cloud.points.size ()) && "Out-of-bounds error in nearestKSearch!");
   return (nearestKSearch (cloud.points[index], k, k_indices, k_sqr_distances));
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::Search<PointT>::nearestKSearch (
-    int index, int k, 
-    std::vector<int> &k_indices, 
+    index_t index, int k,
+    Indices &k_indices,
     std::vector<float> &k_sqr_distances) const
 {
   if (!indices_)
   {
-    assert (index >= 0 && index < static_cast<int> (input_->points.size ()) && "Out-of-bounds error in nearestKSearch!");
+    assert (index >= 0 && index < static_cast<index_t> (input_->points.size ()) && "Out-of-bounds error in nearestKSearch!");
     return (nearestKSearch (input_->points[index], k, k_indices, k_sqr_distances));
   }
-  assert (index >= 0 && index < static_cast<int> (indices_->size ()) && "Out-of-bounds error in nearestKSearch!");
-  if (index >= static_cast<int> (indices_->size ()) || index < 0)
+  assert (index >= 0 && index < static_cast<index_t> (indices_->size ()) && "Out-of-bounds error in nearestKSearch!");
+  if (index >= static_cast<index_t> (indices_->size ()) || index < 0)
     return (0);
   return (nearestKSearch (input_->points[(*indices_)[index]], k, k_indices, k_sqr_distances));
 }
@@ -111,8 +111,8 @@ pcl::search::Search<PointT>::nearestKSearch (
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::search::Search<PointT>::nearestKSearch (
-    const PointCloud& cloud, const std::vector<int>& indices, 
-    int k, std::vector< std::vector<int> >& k_indices,
+    const PointCloud& cloud, const Indices& indices,
+    int k, std::vector<Indices>& k_indices,
     std::vector< std::vector<float> >& k_sqr_distances) const
 {
   if (indices.empty ())
@@ -120,7 +120,7 @@ pcl::search::Search<PointT>::nearestKSearch (
     k_indices.resize (cloud.size ());
     k_sqr_distances.resize (cloud.size ());
     for (std::size_t i = 0; i < cloud.size (); i++)
-      nearestKSearch (cloud, static_cast<int> (i), k, k_indices[i], k_sqr_distances[i]);
+      nearestKSearch (cloud, static_cast<index_t> (i), k, k_indices[i], k_sqr_distances[i]);
   }
   else
   {
@@ -134,26 +134,26 @@ pcl::search::Search<PointT>::nearestKSearch (
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::Search<PointT>::radiusSearch (
-    const PointCloud &cloud, int index, double radius,
-    std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+    const PointCloud &cloud, index_t index, double radius,
+    Indices &k_indices, std::vector<float> &k_sqr_distances,
     unsigned int max_nn) const
 {
-  assert (index >= 0 && index < static_cast<int> (cloud.points.size ()) && "Out-of-bounds error in radiusSearch!");
+  assert (index >= 0 && index < static_cast<index_t> (cloud.points.size ()) && "Out-of-bounds error in radiusSearch!");
   return (radiusSearch(cloud.points[index], radius, k_indices, k_sqr_distances, max_nn));
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> int
 pcl::search::Search<PointT>::radiusSearch (
-    int index, double radius, std::vector<int> &k_indices,
+    index_t index, double radius, Indices &k_indices,
     std::vector<float> &k_sqr_distances, unsigned int max_nn ) const
 {
   if (!indices_)
   {
-    assert (index >= 0 && index < static_cast<int> (input_->points.size ()) && "Out-of-bounds error in radiusSearch!");
+    assert (index >= 0 && index < static_cast<index_t> (input_->points.size ()) && "Out-of-bounds error in radiusSearch!");
     return (radiusSearch (input_->points[index], radius, k_indices, k_sqr_distances, max_nn));
   }
-  assert (index >= 0 && index < static_cast<int> (indices_->size ()) && "Out-of-bounds error in radiusSearch!");
+  assert (index >= 0 && index < static_cast<index_t> (indices_->size ()) && "Out-of-bounds error in radiusSearch!");
   return (radiusSearch (input_->points[(*indices_)[index]], radius, k_indices, k_sqr_distances, max_nn));
 }
 
@@ -161,9 +161,9 @@ pcl::search::Search<PointT>::radiusSearch (
 template <typename PointT> void
 pcl::search::Search<PointT>::radiusSearch (
     const PointCloud& cloud,
-    const std::vector<int>& indices,
+    const Indices& indices,
     double radius,
-    std::vector< std::vector<int> >& k_indices,
+    std::vector<Indices>& k_indices,
     std::vector< std::vector<float> > &k_sqr_distances,
     unsigned int max_nn) const
 {
@@ -172,7 +172,7 @@ pcl::search::Search<PointT>::radiusSearch (
     k_indices.resize (cloud.size ());
     k_sqr_distances.resize (cloud.size ());
     for (std::size_t i = 0; i < cloud.size (); i++)
-      radiusSearch (cloud, static_cast<int> (i), radius,k_indices[i], k_sqr_distances[i], max_nn);
+      radiusSearch (cloud, static_cast<index_t> (i), radius,k_indices[i], k_sqr_distances[i], max_nn);
   }
   else
   {
@@ -186,16 +186,16 @@ pcl::search::Search<PointT>::radiusSearch (
 ///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::search::Search<PointT>::sortResults (
-    std::vector<int>& indices, std::vector<float>& distances) const
+    Indices& indices, std::vector<float>& distances) const
 {
-  std::vector<int> order (indices.size ());
+  Indices order (indices.size ());
   for (std::size_t idx = 0; idx < order.size (); ++idx)
-    order [idx] = static_cast<int> (idx);
+    order [idx] = static_cast<index_t> (idx);
 
   Compare compare (distances);
   sort (order.begin (), order.end (), compare);
 
-  std::vector<int> sorted (indices.size ());
+  Indices sorted (indices.size ());
   for (std::size_t idx = 0; idx < order.size (); ++idx)
     sorted [idx] = indices[order [idx]];
 
index 25d4e864eb239850b98f919c17716d589b49cde8..b0e48a088b44f91d015df43952e98ab91a0ec5b8 100644 (file)
@@ -64,9 +64,6 @@ namespace pcl
         using PointCloud = typename Search<PointT>::PointCloud;
         using PointCloudConstPtr = typename Search<PointT>::PointCloudConstPtr;
 
-        using typename Search<PointT>::IndicesPtr;
-        using typename Search<PointT>::IndicesConstPtr;
-
         using pcl::search::Search<PointT>::indices_;
         using pcl::search::Search<PointT>::input_;
         using pcl::search::Search<PointT>::getIndices;
@@ -147,7 +144,7 @@ namespace pcl
           */
         int
         nearestKSearch (const PointT &point, int k, 
-                        std::vector<int> &k_indices, 
+                        Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const override;
 
         /** \brief Search for all the nearest neighbors of the query point in a given radius.
@@ -162,7 +159,7 @@ namespace pcl
           */
         int
         radiusSearch (const PointT& point, double radius, 
-                      std::vector<int> &k_indices, 
+                      Indices &k_indices,
                       std::vector<float> &k_sqr_distances,
                       unsigned int max_nn = 0) const override;
       protected:
index 0b0a312bb3ca84f3e9fd6c13667ca4c264c02164..ad160be1354110f3f662dc3d68971b7621e2a3b3 100644 (file)
@@ -72,9 +72,6 @@ namespace pcl
         using Ptr = shared_ptr<pcl::search::Octree<PointT,LeafTWrap,BranchTWrap,OctreeT> >;
         using ConstPtr = shared_ptr<const pcl::search::Octree<PointT,LeafTWrap,BranchTWrap,OctreeT> >;
 
-        using typename Search<PointT>::IndicesPtr;
-        using typename Search<PointT>::IndicesConstPtr;
-
         using PointCloud = pcl::PointCloud<PointT>;
         using PointCloudPtr = typename PointCloud::Ptr;
         using PointCloudConstPtr = typename PointCloud::ConstPtr;
@@ -139,7 +136,7 @@ namespace pcl
           * \return number of neighbors found
           */
         inline int
-        nearestKSearch (const PointCloud &cloud, int index, int k, std::vector<int> &k_indices,
+        nearestKSearch (const PointCloud &cloud, index_t index, int k, Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const override
         {
           return (tree_->nearestKSearch (cloud, index, k, k_indices, k_sqr_distances));
@@ -154,7 +151,7 @@ namespace pcl
           * \return number of neighbors found
           */
         inline int
-        nearestKSearch (const PointT &point, int k, std::vector<int> &k_indices,
+        nearestKSearch (const PointT &point, int k, Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const override
         {
           return (tree_->nearestKSearch (point, k, k_indices, k_sqr_distances));
@@ -172,7 +169,7 @@ namespace pcl
           * \return number of neighbors found
           */
         inline int
-        nearestKSearch (int index, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances) const override
+        nearestKSearch (index_t index, int k, Indices &k_indices, std::vector<float> &k_sqr_distances) const override
         {
           return (tree_->nearestKSearch (index, k, k_indices, k_sqr_distances));
         }
@@ -188,9 +185,9 @@ namespace pcl
          */
         inline int
         radiusSearch (const PointCloud &cloud, 
-                      int index, 
+                      index_t index,
                       double radius,
-                      std::vector<int> &k_indices, 
+                      Indices &k_indices,
                       std::vector<float> &k_sqr_distances, 
                       unsigned int max_nn = 0) const override
         {
@@ -211,7 +208,7 @@ namespace pcl
         inline int
         radiusSearch (const PointT &p_q, 
                       double radius, 
-                      std::vector<int> &k_indices,
+                      Indices &k_indices,
                       std::vector<float> &k_sqr_distances, 
                       unsigned int max_nn = 0) const override
         {
@@ -231,7 +228,7 @@ namespace pcl
          * \return number of neighbors found in radius
          */
         inline int
-        radiusSearch (int index, double radius, std::vector<int> &k_indices,
+        radiusSearch (index_t index, double radius, Indices &k_indices,
                       std::vector<float> &k_sqr_distances, unsigned int max_nn = 0) const override
         {
           tree_->radiusSearch (index, radius, k_indices, k_sqr_distances, max_nn);
@@ -249,7 +246,7 @@ namespace pcl
           * \return number of neighbors found
           */
         inline void
-        approxNearestSearch (const PointCloudConstPtr &cloud, int query_index, int &result_index,
+        approxNearestSearch (const PointCloudConstPtr &cloud, index_t query_index, index_t &result_index,
                              float &sqr_distance)
         {
           return (tree_->approxNearestSearch (cloud->points[query_index], result_index, sqr_distance));
@@ -261,7 +258,7 @@ namespace pcl
           * \param[out] sqr_distance the resultant squared distance to the neighboring point
           */
         inline void
-        approxNearestSearch (const PointT &p_q, int &result_index, float &sqr_distance)
+        approxNearestSearch (const PointT &p_q, index_t &result_index, float &sqr_distance)
         {
           return (tree_->approxNearestSearch (p_q, result_index, sqr_distance));
         }
@@ -274,7 +271,7 @@ namespace pcl
           * \return number of neighbors found
           */
         inline void
-        approxNearestSearch (int query_index, int &result_index, float &sqr_distance)
+        approxNearestSearch (index_t query_index, index_t &result_index, float &sqr_distance)
         {
           return (tree_->approxNearestSearch (query_index, result_index, sqr_distance));
         }
index d819a1acd9e021097168847c1496996053e57940..a6d40bbf2203999053b4e355ef96ac2ee6efd9cf 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
@@ -68,7 +69,6 @@ namespace pcl
         using PointCloudPtr = typename PointCloud::Ptr;
 
         using PointCloudConstPtr = typename PointCloud::ConstPtr;
-        using typename Search<PointT>::IndicesConstPtr;
 
         using Ptr = shared_ptr<pcl::search::OrganizedNeighbor<PointT> >;
         using ConstPtr = shared_ptr<const pcl::search::OrganizedNeighbor<PointT> >;
@@ -136,8 +136,8 @@ namespace pcl
           if (indices_ && !indices_->empty())
           {
             mask_.assign (input_->size (), 0);
-            for (std::vector<int>::const_iterator iIt = indices_->begin (); iIt != indices_->end (); ++iIt)
-              mask_[*iIt] = 1;
+            for (const auto& idx : *indices_)
+              mask_[idx] = 1;
           }
           else
             mask_.assign (input_->size (), 1);
@@ -158,7 +158,7 @@ namespace pcl
         int
         radiusSearch (const PointT &p_q,
                       double radius,
-                      std::vector<int> &k_indices,
+                      Indices &k_indices,
                       std::vector<float> &k_sqr_distances,
                       unsigned int max_nn = 0) const override;
 
@@ -178,7 +178,7 @@ namespace pcl
         int
         nearestKSearch (const PointT &p_q,
                         int k,
-                        std::vector<int> &k_indices,
+                        Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const override;
 
         /** \brief projects a point into the image
@@ -192,9 +192,9 @@ namespace pcl
 
         struct Entry
         {
-          Entry (int idx, float dist) : index (idx), distance (dist) {}
+          Entry (index_t idx, float dist) : index (idx), distance (dist) {}
           Entry () : index (0), distance (0) {}
-          unsigned index;
+          index_t index;
           float distance;
           
           inline bool 
@@ -212,7 +212,7 @@ namespace pcl
           * \return whether the top element changed or not.
           */
         inline bool 
-        testPoint (const PointT& query, unsigned k, std::priority_queue<Entry>& queue, unsigned index) const
+        testPoint (const PointT& query, unsigned k, std::priority_queue<Entry>& queue, index_t index) const
         {
           const PointT& point = input_->points [index];
           if (mask_ [index] && std::isfinite (point.x))
index f90c64adb1d09caa98a60c82343b17bdf350227d..afa4f456e50e37485e1d153759043b5b3f0f9e69 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/pcl_base.h> // for IndicesConstPtr
 #include <pcl/point_cloud.h>
 #include <pcl/for_each_type.h>
 #include <pcl/common/concatenate.h>
@@ -80,8 +81,8 @@ namespace pcl
         using Ptr = shared_ptr<pcl::search::Search<PointT> >;
         using ConstPtr = shared_ptr<const pcl::search::Search<PointT> >;
 
-        using IndicesPtr = shared_ptr<std::vector<int> >;
-        using IndicesConstPtr = shared_ptr<const std::vector<int> >;
+        using IndicesPtr = pcl::IndicesPtr;
+        using IndicesConstPtr = pcl::IndicesConstPtr;
 
         /** Constructor. */
         Search (const std::string& name = "", bool sorted = false);
@@ -142,7 +143,7 @@ namespace pcl
           * \return number of neighbors found
           */
         virtual int
-        nearestKSearch (const PointT &point, int k, std::vector<int> &k_indices,
+        nearestKSearch (const PointT &point, int k, Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const = 0;
 
         /** \brief Search for k-nearest neighbors for the given query point.
@@ -156,7 +157,7 @@ namespace pcl
           */
         template <typename PointTDiff> inline int
         nearestKSearchT (const PointTDiff &point, int k,
-                         std::vector<int> &k_indices, std::vector<float> &k_sqr_distances) const
+                         Indices &k_indices, std::vector<float> &k_sqr_distances) const
         {
           PointT p;
           copyPoint (point, p);
@@ -180,8 +181,8 @@ namespace pcl
           * \exception asserts in debug mode if the index is not between 0 and the maximum number of points
           */
         virtual int
-        nearestKSearch (const PointCloud &cloud, int index, int k,
-                        std::vector<int> &k_indices, 
+        nearestKSearch (const PointCloud &cloud, index_t index, int k,
+                        Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const;
 
         /** \brief Search for k-nearest neighbors for the given query point (zero-copy).
@@ -202,8 +203,8 @@ namespace pcl
           * \exception asserts in debug mode if the index is not between 0 and the maximum number of points
           */
         virtual int
-        nearestKSearch (int index, int k,
-                        std::vector<int> &k_indices, 
+        nearestKSearch (index_t index, int k,
+                        Indices &k_indices,
                         std::vector<float> &k_sqr_distances) const;
 
         /** \brief Search for the k-nearest neighbors for the given query point.
@@ -214,8 +215,8 @@ namespace pcl
           * \param[out] k_sqr_distances the resultant squared distances to the neighboring points, k_sqr_distances[i] corresponds to the neighbors of the query point i
           */
         virtual void
-        nearestKSearch (const PointCloud& cloud, const std::vector<int>& indices, 
-                        int k, std::vector< std::vector<int> >& k_indices,
+        nearestKSearch (const PointCloud& cloud, const Indices& indices,
+                        int k, std::vector<Indices>& k_indices,
                         std::vector< std::vector<float> >& k_sqr_distances) const;
 
         /** \brief Search for the k-nearest neighbors for the given query point. Use this method if the query points are of a different type than the points in the data set (e.g. PointXYZRGBA instead of PointXYZ).
@@ -227,7 +228,7 @@ namespace pcl
           * \note This method copies the input point cloud of type PointTDiff to a temporary cloud of type PointT and performs the batch search on the new cloud. You should prefer the single-point search if you don't use a search algorithm that accelerates batch NN search.
           */
         template <typename PointTDiff> void
-        nearestKSearchT (const pcl::PointCloud<PointTDiff> &cloud, const std::vector<int>& indices, int k, std::vector< std::vector<int> > &k_indices,
+        nearestKSearchT (const pcl::PointCloud<PointTDiff> &cloud, const Indices& indices, int k, std::vector<Indices> &k_indices,
                          std::vector< std::vector<float> > &k_sqr_distances) const
         {
           // Copy all the data fields from the input cloud to the output one
@@ -244,7 +245,7 @@ namespace pcl
               pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointTDiff, PointT> (
                                               cloud[i], pc[i]));
             }
-            nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
+            nearestKSearch (pc,Indices(),k,k_indices,k_sqr_distances);
           }
           else
           {
@@ -254,7 +255,7 @@ namespace pcl
               pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointTDiff, PointT> (
                                               cloud[indices[i]], pc[i]));
             }
-            nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
+            nearestKSearch (pc,Indices(),k,k_indices,k_sqr_distances);
           }
         }
 
@@ -269,7 +270,7 @@ namespace pcl
           * \return number of neighbors found in radius
           */
         virtual int
-        radiusSearch (const PointT& point, double radius, std::vector<int>& k_indices,
+        radiusSearch (const PointT& point, double radius, Indices& k_indices,
                       std::vector<float>& k_sqr_distances, unsigned int max_nn = 0) const = 0;
 
         /** \brief Search for all the nearest neighbors of the query point in a given radius.
@@ -283,7 +284,7 @@ namespace pcl
           * \return number of neighbors found in radius
           */
         template <typename PointTDiff> inline int
-        radiusSearchT (const PointTDiff &point, double radius, std::vector<int> &k_indices,
+        radiusSearchT (const PointTDiff &point, double radius, Indices &k_indices,
                        std::vector<float> &k_sqr_distances, unsigned int max_nn = 0) const
         {
           PointT p;
@@ -309,8 +310,8 @@ namespace pcl
           * \exception asserts in debug mode if the index is not between 0 and the maximum number of points
           */
         virtual int
-        radiusSearch (const PointCloud &cloud, int index, double radius,
-                      std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
+        radiusSearch (const PointCloud &cloud, index_t index, double radius,
+                      Indices &k_indices, std::vector<float> &k_sqr_distances,
                       unsigned int max_nn = 0) const;
 
         /** \brief Search for all the nearest neighbors of the query point in a given radius (zero-copy).
@@ -333,7 +334,7 @@ namespace pcl
           * \exception asserts in debug mode if the index is not between 0 and the maximum number of points
           */
         virtual int
-        radiusSearch (int index, double radius, std::vector<int> &k_indices,
+        radiusSearch (index_t index, double radius, Indices &k_indices,
                       std::vector<float> &k_sqr_distances, unsigned int max_nn = 0) const;
 
         /** \brief Search for all the nearest neighbors of the query point in a given radius.
@@ -348,9 +349,9 @@ namespace pcl
           */
         virtual void
         radiusSearch (const PointCloud& cloud,
-                      const std::vector<int>& indices,
+                      const Indices& indices,
                       double radius,
-                      std::vector< std::vector<int> >& k_indices,
+                      std::vector<Indices>& k_indices,
                       std::vector< std::vector<float> > &k_sqr_distances,
                       unsigned int max_nn = 0) const;
 
@@ -367,9 +368,9 @@ namespace pcl
           */
         template <typename PointTDiff> void
         radiusSearchT (const pcl::PointCloud<PointTDiff> &cloud,
-                       const std::vector<int>& indices,
+                       const Indices& indices,
                        double radius,
-                       std::vector< std::vector<int> > &k_indices,
+                       std::vector<Indices> &k_indices,
                        std::vector< std::vector<float> > &k_sqr_distances,
                        unsigned int max_nn = 0) const
         {
@@ -384,20 +385,20 @@ namespace pcl
             pc.resize (cloud.size ());
             for (std::size_t i = 0; i < cloud.size (); ++i)
               pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointTDiff, PointT> (cloud[i], pc[i]));
-            radiusSearch (pc, std::vector<int> (), radius, k_indices, k_sqr_distances, max_nn);
+            radiusSearch (pc, Indices (), radius, k_indices, k_sqr_distances, max_nn);
           }
           else
           {
             pc.resize (indices.size ());
             for (std::size_t i = 0; i < indices.size (); ++i)
               pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointTDiff, PointT> (cloud[indices[i]], pc[i]));
-            radiusSearch (pc, std::vector<int>(), radius, k_indices, k_sqr_distances, max_nn);
+            radiusSearch (pc, Indices(), radius, k_indices, k_sqr_distances, max_nn);
           }
         }
 
       protected:
         void 
-        sortResults (std::vector<int>& indices, std::vector<float>& distances) const;
+        sortResults (Indices& indices, std::vector<float>& distances) const;
 
         PointCloudConstPtr input_;
         IndicesConstPtr indices_;
@@ -413,7 +414,7 @@ namespace pcl
           }
           
           bool 
-          operator () (int first, int second) const
+          operator () (index_t first, index_t second) const
           {
             return (distances_ [first] < distances_[second]);
           }
index 19e75080d9b24f55068de476423daf20075eeb6f..40c3aac5f77d957b116eb401b3a617c9708db746 100644 (file)
@@ -47,7 +47,6 @@
 #ifndef Q_MOC_RUN
 // Marking all Boost headers as system headers to remove warnings
 #include <boost/version.hpp>
-#include <boost/make_shared.hpp>
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/multi_array.hpp>
 #include <boost/ptr_container/ptr_list.hpp>
index 122745a055b604866db55fb1a626f92faf90c7db..a08c4857dad73493543fefe8e00518234f90f33d 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 
index 387f12370f73b5f1e73560c32114e7410f6414db..55d96b2c010cce758cc440794f3c9123e7e30bff 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/search/pcl_search.h>
@@ -109,18 +110,18 @@ namespace pcl
       /** \brief Provide a pointer to the search object.
         * \param[in] tree a pointer to the spatial search object.
         */
-      inline void 
-      setSearchMethod (const SearcherPtr &tree) 
-      { 
-        searcher_ = tree; 
+      inline void
+      setSearchMethod (const SearcherPtr &tree)
+      {
+        searcher_ = tree;
       }
 
-      /** \brief Get a pointer to the search method used. 
+      /** \brief Get a pointer to the search method used.
        */
-      inline const SearcherPtr& 
-      getSearchMethod () const 
-      { 
-        return searcher_; 
+      inline const SearcherPtr&
+      getSearchMethod () const
+      {
+        return searcher_;
       }
 
       /** \brief Set the condition that needs to hold for neighboring points to be considered part of the same cluster.
@@ -141,7 +142,7 @@ namespace pcl
         * \param[in] condition_function The condition function that needs to hold for clustering
         */
       inline void
-      setConditionFunction (bool (*condition_function) (const PointT&, const PointT&, float)) 
+      setConditionFunction (bool (*condition_function) (const PointT&, const PointT&, float))
       {
         condition_function_ = condition_function;
       }
index e7f76abc71a2635021a284c0139a71b419a85a2e..de38bd269c09787414d15ec09bcf901e2b170c70 100644 (file)
@@ -53,7 +53,7 @@
 #define PCL_INSTANTIATE_CPCSegmentation(T) template class PCL_EXPORTS pcl::CPCSegmentation<T>;
 
 namespace pcl
-{  
+{
   /** \brief A segmentation algorithm partitioning a supervoxel graph. It uses planar cuts induced by local concavities for the recursive segmentation. Cuts are estimated using locally constrained directed RANSAC.
    *  \note If you use this in a scientific work please cite the following paper:
    *  M. Schoeler, J. Papon, F. Woergoetter
@@ -88,11 +88,11 @@ namespace pcl
 
     public:
       CPCSegmentation ();
-      
+
       ~CPCSegmentation ();
 
       /** \brief Merge supervoxels using cuts through local convexities. The input parameters are generated by using the \ref SupervoxelClustering class. To retrieve the output use the \ref relabelCloud method.
-       *  \note There are three ways to retrieve the segmentation afterwards (inherited from \ref LCCPSegmentation): \ref relabelCloud, \ref getSegmentSupervoxelMap and \ref getSupervoxelSegmentMap*/
+       *  \note There are three ways to retrieve the segmentation afterwards (inherited from \ref LCCPSegmentation): \ref relabelCloud, \ref getSupervoxelToSegmentMap and \ref getSupervoxelToSegmentMap */
       void
       segment ();
 
@@ -122,13 +122,13 @@ namespace pcl
 
       /** \brief Set the number of iterations for the weighted RANSAC step (best cut estimations)
        *  \param[in] ransac_iterations The number of iterations */
-      inline void 
+      inline void
       setRANSACIterations (const std::uint32_t ransac_iterations)
       {
         ransac_itrs_ = ransac_iterations;
       }
 
-    private:      
+    private:
 
       /** \brief Used in for CPC to find and fit cutting planes to the pointcloud.
        *  \note Is used recursively
@@ -155,12 +155,12 @@ namespace pcl
 
       /** \brief Use clean cutting */
       bool use_clean_cutting_;
-      
+
       /** \brief Iterations for RANSAC */
       std::uint32_t ransac_itrs_;
-     
-      
-/******************************************* Directional weighted RANSAC declarations ******************************************************************/      
+
+
+/******************************************* Directional weighted RANSAC declarations ******************************************************************/
       /** \brief @b WeightedRandomSampleConsensus represents an implementation of the Directionally Weighted RANSAC algorithm, as described in: "Constrained Planar Cuts - Part Segmentation for Point Clouds", CVPR 2015, M. Schoeler, J. Papon, F. Wörgötter.
         *  \note It only uses points with a weight > 0 for the model calculation, but uses all points for the evaluation (scoring of the model)
         *  Only use in conjunction with sac_model_plane
@@ -171,7 +171,7 @@ namespace pcl
         *  \author Markus Schoeler (mschoeler@web.de)
         *  \ingroup segmentation
         */
-      
+
       class WeightedRandomSampleConsensus : public SampleConsensus<WeightSACPointType>
       {
           using SampleConsensusModelPtr = SampleConsensusModel<WeightSACPointType>::Ptr;
@@ -184,7 +184,7 @@ namespace pcl
             * \param[in] model a Sample Consensus model
             * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
             */
-          WeightedRandomSampleConsensus (const SampleConsensusModelPtr &model, 
+          WeightedRandomSampleConsensus (const SampleConsensusModelPtr &model,
                                         bool random = false)
             : SampleConsensus<WeightSACPointType> (model, random)
           {
@@ -253,26 +253,26 @@ namespace pcl
             full_cloud_pt_indices_.reset (new std::vector<int> (* (sac_model_->getIndices ())));
             point_cloud_ptr_ = sac_model_->getInputCloud ();
           }
-          
+
           /** \brief  weight each positive weight point by the inner product between the normal and the plane normal */
           bool use_directed_weights_;
-          
+
           /** \brief  vector of weights assigned to points. Set by the setWeights-method */
           std::vector<double> weights_;
-          
+
           /** \brief  The indices used for estimating the RANSAC model. Only those whose weight is > 0 */
           pcl::IndicesPtr model_pt_indices_;
-          
+
           /** \brief  The complete list of indices used for the model evaluation */
           pcl::IndicesPtr full_cloud_pt_indices_;
-          
+
           /** \brief  Pointer to the input PointCloud */
           pcl::PointCloud<WeightSACPointType>::ConstPtr point_cloud_ptr_;
-          
+
           /** \brief  Highest score found so far */
           double best_score_;
       };
-      
+
   };
 }
 
@@ -281,5 +281,5 @@ namespace pcl
 #elif defined(PCL_ONLY_CORE_POINT_TYPES)
   //pcl::PointXYZINormal is not a core point type (so we cannot use the precompiled classes here)
   #include <pcl/sample_consensus/impl/sac_model_plane.hpp>
-  #include <pcl/segmentation/impl/extract_clusters.hpp>  
+  #include <pcl/segmentation/impl/extract_clusters.hpp>
 #endif // PCL_NO_PRECOMPILE / PCL_ONLY_CORE_POINT_TYPES
index 71be7ce22302ec0a9a1aa7316a494400cdb8767e..6eb2663c1ba5acfa926aa9c8b8bd65462b4714b8 100644 (file)
@@ -36,6 +36,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 
index f06434df86af296729d8ffd29e4d595591212256..c97018407277458d9400579fcc05c955e699198f 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
index acb483cf9248350e8be7fc869a799e711470c4c1..98f3bde3163f4188b098c05d2fce2c62318efdb7 100644 (file)
@@ -44,7 +44,7 @@
 
 namespace pcl
 {
-  /** \brief EdgeAwarePlaneComparator is a Comparator that operates on plane coefficients, 
+  /** \brief EdgeAwarePlaneComparator is a Comparator that operates on plane coefficients,
     * for use in planar segmentation.
     * In conjunction with OrganizedConnectedComponentSegmentation, this allows planes to be segmented from organized data.
     *
@@ -56,11 +56,11 @@ namespace pcl
     public:
       using PointCloud = typename Comparator<PointT>::PointCloud;
       using PointCloudConstPtr = typename Comparator<PointT>::PointCloudConstPtr;
-      
+
       using PointCloudN = pcl::PointCloud<PointNT>;
       using PointCloudNPtr = typename PointCloudN::Ptr;
       using PointCloudNConstPtr = typename PointCloudN::ConstPtr;
-      
+
       using Ptr = shared_ptr<EdgeAwarePlaneComparator<PointT, PointNT> >;
       using ConstPtr = shared_ptr<const EdgeAwarePlaneComparator<PointT, PointNT> >;
 
@@ -80,10 +80,10 @@ namespace pcl
       {
       }
 
-      /** \brief Empty constructor for PlaneCoefficientComparator. 
+      /** \brief Empty constructor for PlaneCoefficientComparator.
         * \param[in] distance_map the distance map to use
         */
-      EdgeAwarePlaneComparator (const float *distance_map) : 
+      EdgeAwarePlaneComparator (const float *distance_map) :
         distance_map_ (distance_map),
         distance_map_threshold_ (5),
         curvature_threshold_ (0.04f),
@@ -92,13 +92,13 @@ namespace pcl
       }
 
       /** \brief Destructor for PlaneCoefficientComparator. */
-      
+
       ~EdgeAwarePlaneComparator ()
       {
       }
 
-      /** \brief Set a distance map to use. For an example of a valid distance map see 
-        * \ref OrganizedIntegralImageNormalEstimation
+      /** \brief Set a distance map to use. For an example of a valid distance map see
+        * IntegralImageNormalEstimation::getDistanceMap
         * \param[in] distance_map the distance map to use
         */
       inline void
@@ -161,7 +161,7 @@ namespace pcl
       {
         return (euclidean_distance_threshold_);
       }
-      
+
     protected:
       /** \brief Compare two neighboring points, by using normal information, curvature, and euclidean distance information.
         * \param[in] idx1 The index of the first point.
@@ -184,7 +184,7 @@ namespace pcl
           dist_threshold *= z * z;
           euclidean_dist_threshold *= z * z;
         }
-        
+
         float dx = input_->points[idx1].x - input_->points[idx2].x;
         float dy = input_->points[idx1].y - input_->points[idx2].y;
         float dz = input_->points[idx1].z - input_->points[idx2].z;
@@ -195,10 +195,10 @@ namespace pcl
 
         bool curvature_ok = normals_->points[idx1].curvature < curvature_threshold_;
         bool plane_d_ok = std::abs ((*plane_coeff_d_)[idx1] - (*plane_coeff_d_)[idx2]) < dist_threshold;
-        
-        if (distance_map_[idx1] < distance_map_threshold_)    
+
+        if (distance_map_[idx1] < distance_map_threshold_)
           curvature_ok = false;
-        
+
         return (dist_ok && normal_ok && curvature_ok && plane_d_ok);
       }
 
index 7295978e8238540d49acf29a99180b1a4dfa4702..a924d218b908cc3549b9a70b08a7dcd07403905e 100644 (file)
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
+#include <pcl/point_types.h>
 #include <pcl/segmentation/boost.h>
 #include <pcl/segmentation/comparator.h>
-#include <pcl/point_types.h>
+
 
 namespace pcl
 {
@@ -211,7 +213,7 @@ namespace pcl
       using experimental::EuclideanClusterComparator<PointT, PointLT>::setExcludeLabels;
 
       /** \brief Default constructor for EuclideanClusterComparator. */
-      PCL_DEPRECATED("remove PointNT from template parameters")
+      PCL_DEPRECATED(1, 12, "remove PointNT from template parameters")
       EuclideanClusterComparator ()
         : normals_ ()
         , angular_threshold_ (0.0f)
@@ -220,19 +222,19 @@ namespace pcl
       /** \brief Provide a pointer to the input normals.
        * \param[in] normals the input normal cloud
        */
-      PCL_DEPRECATED("EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
+      PCL_DEPRECATED(1, 12, "EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
       inline void
       setInputNormals (const PointCloudNConstPtr& normals) { normals_ = normals; }
 
       /** \brief Get the input normals. */
-      PCL_DEPRECATED("EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
+      PCL_DEPRECATED(1, 12, "EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
       inline PointCloudNConstPtr
       getInputNormals () const { return (normals_); }
 
       /** \brief Set the tolerance in radians for difference in normal direction between neighboring points, to be considered part of the same plane.
         * \param[in] angular_threshold the tolerance in radians
         */
-      PCL_DEPRECATED("EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
+      PCL_DEPRECATED(1, 12, "EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
       inline void
       setAngularThreshold (float angular_threshold)
       {
@@ -240,18 +242,18 @@ namespace pcl
       }
 
       /** \brief Get the angular threshold in radians for difference in normal direction between neighboring points, to be considered part of the same plane. */
-      PCL_DEPRECATED("EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
+      PCL_DEPRECATED(1, 12, "EuclideadClusterComparator never actually used normals and angular threshold, this function has no effect on the behavior of the comparator. It is deprecated and will be removed in future releases.")
       inline float
       getAngularThreshold () const { return (std::acos (angular_threshold_) ); }
 
       /** \brief Set labels in the label cloud to exclude.
         * \param[in] exclude_labels a vector of bools corresponding to whether or not a given label should be considered
         */
-      PCL_DEPRECATED("use setExcludeLabels(const ExcludeLabelSetConstPtr &) instead")
+      PCL_DEPRECATED(1, 12, "use setExcludeLabels(const ExcludeLabelSetConstPtr &) instead")
       void
       setExcludeLabels (const std::vector<bool>& exclude_labels)
       {
-        exclude_labels_ = boost::make_shared<std::set<std::uint32_t> > ();
+        exclude_labels_ = pcl::make_shared<std::set<std::uint32_t> > ();
         for (std::size_t i = 0; i < exclude_labels.size (); ++i)
           if (exclude_labels[i])
             exclude_labels_->insert (i);
index d8ecbf5b6376c39a904043d4c94bd596992d12f5..f31580d994bea8e2a805e0c4abaef081d7e2fd37 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/point_cloud.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
index 3ca912b4eb052c9a686827fe4cf7ef490446d412..2f3cbee4bce3d7a7abbaf13be447fbc008781529 100644 (file)
 
 #pragma once
 
-#include <pcl/common/angles.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
+#include <pcl/common/angles.h>
 #include <pcl/segmentation/comparator.h>
-#include <boost/make_shared.hpp>
+
 
 namespace pcl
 {
@@ -139,7 +140,7 @@ namespace pcl
       void
       setPlaneCoeffD (std::vector<float>& plane_coeff_d)
       {
-        plane_coeff_d_ = boost::make_shared<std::vector<float> >(plane_coeff_d);
+        plane_coeff_d_ = pcl::make_shared<std::vector<float> >(plane_coeff_d);
       }
       
       /** \brief Get a pointer to the vector of the d-coefficient of the planes' hessian normal form. */
index 47335f745e8f7afef17d87b3cb356ff9b5937578..9ac78328372d85429eedcff635277e7388d422b2 100644 (file)
@@ -83,25 +83,17 @@ pcl::ApproximateProgressiveMorphologicalFilter<PointT>::extract (std::vector<int
   std::vector<float> window_sizes;
   std::vector<int> half_sizes;
   int iteration = 0;
-  int half_size = 0.0f;
-  float window_size = 0.0f;
-  float height_threshold = 0.0f;
+  float window_size = 0.0f;    
 
   while (window_size < max_window_size_)
   {
     // Determine the initial window size.
-    if (exponential_)
-      half_size = static_cast<int> (std::pow (static_cast<float> (base_), iteration));
-    else
-      half_size = (iteration+1) * base_;
+    int half_size = (exponential_) ? (static_cast<int> (std::pow (static_cast<float> (base_), iteration))) : ((iteration+1) * base_);
 
     window_size = 2 * half_size + 1;
 
     // Calculate the height threshold to be used in the next iteration.
-    if (iteration == 0)
-      height_threshold = initial_distance_;
-    else
-      height_threshold = slope_ * (window_size - window_sizes[iteration-1]) * cell_size_ + initial_distance_;
+    float height_threshold = (iteration == 0) ? (initial_distance_) : (slope_ * (window_size - window_sizes[iteration-1]) * cell_size_ + initial_distance_);
 
     // Enforce max distance on height threshold
     if (height_threshold > max_distance_)
@@ -133,9 +125,10 @@ pcl::ApproximateProgressiveMorphologicalFilter<PointT>::extract (std::vector<int
   Eigen::MatrixXf Zf (rows, cols);
   Zf.setConstant (std::numeric_limits<float>::quiet_NaN ());
 
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(A, global_min) \
+  num_threads(threads_)
   for (int i = 0; i < (int)input_->points.size (); ++i)
   {
     // ...then test for lower points within the cell
@@ -164,9 +157,10 @@ pcl::ApproximateProgressiveMorphologicalFilter<PointT>::extract (std::vector<int
     pcl::copyPointCloud<PointT> (*input_, ground, *cloud);
 
     // Apply the morphological opening operation at the current window size.
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(A, cols, half_sizes, i, rows, Z) \
+  num_threads(threads_)
     for (int row = 0; row < rows; ++row)
     {
       int rs, re;
@@ -198,9 +192,10 @@ pcl::ApproximateProgressiveMorphologicalFilter<PointT>::extract (std::vector<int
       }
     }
 
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(cols, half_sizes, i, rows, Z, Zf) \
+  num_threads(threads_)
     for (int row = 0; row < rows; ++row)
     {
       int rs, re;
index 41ec799609cbc318988b07187dd5bd4cc11feac9..3898e091914cddbd8655ca2883e595d6bb830046 100644 (file)
@@ -480,9 +480,6 @@ pcl::CrfSegmentation<PointT>::segmentPoints (pcl::PointCloud<pcl::PointXYZRGBL>
   // ----------------------------------//
   // --------      -------------------//
 
-  pcl::PointCloud<pcl::PointXYZRGBL> tmp_cloud;
-  tmp_cloud = *filtered_anno_;
-
   // create dense CRF
   DenseCrf crf (N, n_labels);
 
@@ -549,6 +546,9 @@ pcl::CrfSegmentation<PointT>::segmentPoints (pcl::PointCloud<pcl::PointXYZRGBL>
 
 
 /*
+  pcl::PointCloud<pcl::PointXYZRGBL> tmp_cloud;        
+  tmp_cloud = *filtered_anno_;
+
   bool c = true;
   for (std::size_t i = 0; i < tmp_cloud.points.size (); i++)
   {
index e87d883b0f0aadee143f99649c5dc9ab338d35f7..72fbe5e56c19d08f42110f97ca918271b293364a 100644 (file)
  *
  */
 
-#ifndef PCL_SEGMENTATION_IMPL_GRABCUT_HPP
-#define PCL_SEGMENTATION_IMPL_GRABCUT_HPP
+#pragma once
 
+#include <pcl/common/distances.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/search/organized.h>
 #include <pcl/search/kdtree.h>
-#include <pcl/common/distances.h>
+
 
 namespace pcl
 {
-  template <>
-  float squaredEuclideanDistance (const pcl::segmentation::grabcut::Color &c1,
-                                  const pcl::segmentation::grabcut::Color &c2)
-  {
-    return ((c1.r-c2.r)*(c1.r-c2.r)+(c1.g-c2.g)*(c1.g-c2.g)+(c1.b-c2.b)*(c1.b-c2.b));
-  }
+
+template <>
+float squaredEuclideanDistance (const pcl::segmentation::grabcut::Color &c1,
+                                const pcl::segmentation::grabcut::Color &c2)
+{
+  return ((c1.r-c2.r)*(c1.r-c2.r)+(c1.g-c2.g)*(c1.g-c2.g)+(c1.b-c2.b)*(c1.b-c2.b));
 }
 
+namespace segmentation
+{
+
 template <typename PointT>
-pcl::segmentation::grabcut::Color::Color (const PointT& p)
+grabcut::Color::Color (const PointT& p)
 {
   r = static_cast<float> (p.r) / 255.0;
   g = static_cast<float> (p.g) / 255.0;
@@ -61,7 +65,7 @@ pcl::segmentation::grabcut::Color::Color (const PointT& p)
 }
 
 template <typename PointT>
-pcl::segmentation::grabcut::Color::operator PointT () const
+grabcut::Color::operator PointT () const
 {
   PointT p;
   p.r = static_cast<std::uint32_t> (r * 255);
@@ -70,14 +74,16 @@ pcl::segmentation::grabcut::Color::operator PointT () const
   return (p);
 }
 
+} // namespace segmentation
+
 template <typename PointT> void
-pcl::GrabCut<PointT>::setInputCloud (const PointCloudConstPtr &cloud)
+GrabCut<PointT>::setInputCloud (const PointCloudConstPtr &cloud)
 {
   input_ = cloud;
 }
 
 template <typename PointT> bool
-pcl::GrabCut<PointT>::initCompute ()
+GrabCut<PointT>::initCompute ()
 {
   using namespace pcl::segmentation::grabcut;
   if (!pcl::PCLBase<PointT>::initCompute ())
@@ -140,20 +146,20 @@ pcl::GrabCut<PointT>::initCompute ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::addEdge (vertex_descriptor v1, vertex_descriptor v2, float capacity, float rev_capacity)
+GrabCut<PointT>::addEdge (vertex_descriptor v1, vertex_descriptor v2, float capacity, float rev_capacity)
 {
   graph_.addEdge (v1, v2, capacity, rev_capacity);
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::setTerminalWeights (vertex_descriptor v, float source_capacity, float sink_capacity)
+GrabCut<PointT>::setTerminalWeights (vertex_descriptor v, float source_capacity, float sink_capacity)
 {
   graph_.addSourceEdge (v, source_capacity);
   graph_.addTargetEdge (v, sink_capacity);
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::setBackgroundPointsIndices (const PointIndicesConstPtr &indices)
+GrabCut<PointT>::setBackgroundPointsIndices (const PointIndicesConstPtr &indices)
 {
   using namespace pcl::segmentation::grabcut;
   if (!initCompute ())
@@ -175,7 +181,7 @@ pcl::GrabCut<PointT>::setBackgroundPointsIndices (const PointIndicesConstPtr &in
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::fitGMMs ()
+GrabCut<PointT>::fitGMMs ()
 {
   // Step 3: Build GMMs using Orchard-Bouman clustering algorithm
   buildGMMs (*image_, *indices_, hard_segmentation_, GMM_component_, background_GMM_, foreground_GMM_);
@@ -185,7 +191,7 @@ pcl::GrabCut<PointT>::fitGMMs ()
 }
 
 template <typename PointT> int
-pcl::GrabCut<PointT>::refineOnce ()
+GrabCut<PointT>::refineOnce ()
 {
   // Steps 4 and 5: Learn new GMMs from current segmentation
   learnGMMs (*image_, *indices_, hard_segmentation_, GMM_component_, background_GMM_, foreground_GMM_);
@@ -202,7 +208,7 @@ pcl::GrabCut<PointT>::refineOnce ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::refine ()
+GrabCut<PointT>::refine ()
 {
   std::size_t changed = indices_->size ();
 
@@ -211,7 +217,7 @@ pcl::GrabCut<PointT>::refine ()
 }
 
 template <typename PointT> int
-pcl::GrabCut<PointT>::updateHardSegmentation ()
+GrabCut<PointT>::updateHardSegmentation ()
 {
   using namespace pcl::segmentation::grabcut;
 
@@ -242,7 +248,7 @@ pcl::GrabCut<PointT>::updateHardSegmentation ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::setTrimap (const PointIndicesConstPtr &indices, segmentation::grabcut::TrimapValue t)
+GrabCut<PointT>::setTrimap (const PointIndicesConstPtr &indices, segmentation::grabcut::TrimapValue t)
 {
   using namespace pcl::segmentation::grabcut;
   for (const int &index : indices->indices)
@@ -259,7 +265,7 @@ pcl::GrabCut<PointT>::setTrimap (const PointIndicesConstPtr &indices, segmentati
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::initGraph ()
+GrabCut<PointT>::initGraph ()
 {
   using namespace pcl::segmentation::grabcut;
   const int number_of_indices = static_cast<int> (indices_->size ());
@@ -324,7 +330,7 @@ pcl::GrabCut<PointT>::initGraph ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::computeNLinksNonOrganized ()
+GrabCut<PointT>::computeNLinksNonOrganized ()
 {
   const int number_of_indices = static_cast<int> (indices_->size ());
   for (int i_point = 0; i_point < number_of_indices; ++i_point)
@@ -350,7 +356,7 @@ pcl::GrabCut<PointT>::computeNLinksNonOrganized ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::computeNLinksOrganized ()
+GrabCut<PointT>::computeNLinksOrganized ()
 {
        for( unsigned int y = 0; y < image_->height; ++y )
        {
@@ -377,7 +383,7 @@ pcl::GrabCut<PointT>::computeNLinksOrganized ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::computeBetaNonOrganized ()
+GrabCut<PointT>::computeBetaNonOrganized ()
 {
   float result = 0;
   std::size_t edges = 0;
@@ -416,7 +422,7 @@ pcl::GrabCut<PointT>::computeBetaNonOrganized ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::computeBetaOrganized ()
+GrabCut<PointT>::computeBetaOrganized ()
 {
   float result = 0;
   std::size_t edges = 0;
@@ -486,13 +492,13 @@ pcl::GrabCut<PointT>::computeBetaOrganized ()
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::computeL ()
+GrabCut<PointT>::computeL ()
 {
   L_ = 8*lambda_ + 1;
 }
 
 template <typename PointT> void
-pcl::GrabCut<PointT>::extract (std::vector<pcl::PointIndices>& clusters)
+GrabCut<PointT>::extract (std::vector<pcl::PointIndices>& clusters)
 {
   using namespace pcl::segmentation::grabcut;
   clusters.clear ();
@@ -509,4 +515,5 @@ pcl::GrabCut<PointT>::extract (std::vector<pcl::PointIndices>& clusters)
       clusters[0].indices.push_back (i);
 }
 
-#endif
+} // namespace pcl
+
index a43243f9b3a738083cb2cf75c223d1b54850716f..f2a8730b00807c9e21fde6e17b636244fdce3552 100644 (file)
@@ -138,22 +138,20 @@ pcl::LCCPSegmentation<PointT>::computeSegmentAdjacency ()
 {  
   seg_label_to_neighbor_set_map_.clear ();
 
-  //The vertices in the supervoxel adjacency list are the supervoxel centroids
-  std::pair<VertexIterator, VertexIterator> vertex_iterator_range;
-  vertex_iterator_range = boost::vertices (sv_adjacency_list_);
-
   std::uint32_t current_segLabel;
   std::uint32_t neigh_segLabel;
 
+  VertexIterator sv_itr, sv_itr_end;
+  //The vertices in the supervoxel adjacency list are the supervoxel centroids
   // For every Supervoxel..
-  for (VertexIterator sv_itr = vertex_iterator_range.first; sv_itr != vertex_iterator_range.second; ++sv_itr)  // For all supervoxels
+  for(std::tie(sv_itr, sv_itr_end) = boost::vertices(sv_adjacency_list_); sv_itr != sv_itr_end; ++sv_itr)  // For all supervoxels
   {
     const std::uint32_t& sv_label = sv_adjacency_list_[*sv_itr];
     current_segLabel = sv_label_to_seg_label_map_[sv_label];
 
+    AdjacencyIterator itr_neighbor, itr_neighbor_end;
     // ..look at all neighbors and insert their labels into the neighbor set
-    std::pair<AdjacencyIterator, AdjacencyIterator> neighbors = boost::adjacent_vertices (*sv_itr, sv_adjacency_list_);
-    for (AdjacencyIterator itr_neighbor = neighbors.first; itr_neighbor != neighbors.second; ++itr_neighbor)
+    for (std::tie(itr_neighbor, itr_neighbor_end) = boost::adjacent_vertices (*sv_itr, sv_adjacency_list_); itr_neighbor != itr_neighbor_end; ++itr_neighbor)
     {
       const std::uint32_t& neigh_label = sv_adjacency_list_[*itr_neighbor];
       neigh_segLabel = sv_label_to_seg_label_map_[neigh_label];
@@ -176,13 +174,6 @@ pcl::LCCPSegmentation<PointT>::mergeSmallSegments ()
 
   std::set<std::uint32_t> filteredSegLabels;
 
-  std::uint32_t largest_neigh_size = 0;
-  std::uint32_t largest_neigh_seg_label = 0;
-  std::uint32_t current_seg_label;
-
-  std::pair<VertexIterator, VertexIterator> vertex_iterator_range;
-  vertex_iterator_range = boost::vertices (sv_adjacency_list_);
-
   bool continue_filtering = true;
 
   while (continue_filtering)
@@ -190,13 +181,14 @@ pcl::LCCPSegmentation<PointT>::mergeSmallSegments ()
     continue_filtering = false;
     unsigned int nr_filtered = 0;
 
+    VertexIterator sv_itr, sv_itr_end;
     // Iterate through all supervoxels, check if they are in a "small" segment -> change label to largest neighborID
-    for (VertexIterator sv_itr = vertex_iterator_range.first; sv_itr != vertex_iterator_range.second; ++sv_itr)  // For all supervoxels
+    for (std::tie(sv_itr, sv_itr_end) = boost::vertices (sv_adjacency_list_); sv_itr != sv_itr_end; ++sv_itr)  // For all supervoxels
     {
       const std::uint32_t& sv_label = sv_adjacency_list_[*sv_itr];
-      current_seg_label = sv_label_to_seg_label_map_[sv_label];
-      largest_neigh_seg_label = current_seg_label;
-      largest_neigh_size = seg_label_to_sv_list_map_[current_seg_label].size ();
+      std::uint32_t current_seg_label = sv_label_to_seg_label_map_[sv_label];
+      std::uint32_t largest_neigh_seg_label = current_seg_label;
+      std::uint32_t largest_neigh_size = seg_label_to_sv_list_map_[current_seg_label].size ();
 
       const std::uint32_t& nr_neighbors = seg_label_to_neighbor_set_map_[current_seg_label].size ();
       if (nr_neighbors == 0)
@@ -311,14 +303,12 @@ pcl::LCCPSegmentation<PointT>::doGrouping ()
     sv_label_to_seg_label_map_[sv_label] = 0;
   }
   
+  VertexIterator sv_itr, sv_itr_end;
   // Perform depth search on the graph and recursively group all supervoxels with convex connections
   //The vertices in the supervoxel adjacency list are the supervoxel centroids
-  std::pair< VertexIterator, VertexIterator> vertex_iterator_range;
-  vertex_iterator_range = boost::vertices (sv_adjacency_list_);
-
   // Note: *sv_itr is of type " boost::graph_traits<VoxelAdjacencyList>::vertex_descriptor " which it nothing but a typedef of std::size_t..
   unsigned int segment_label = 1;  // This starts at 1, because 0 is reserved for errors
-  for (VertexIterator sv_itr = vertex_iterator_range.first; sv_itr != vertex_iterator_range.second; ++sv_itr)  // For all supervoxels
+  for (std::tie(sv_itr, sv_itr_end) = boost::vertices (sv_adjacency_list_); sv_itr != sv_itr_end; ++sv_itr)  // For all supervoxels
   {
     const VertexID sv_vertex_id = *sv_itr;
     const std::uint32_t& sv_label = sv_adjacency_list_[sv_vertex_id];
@@ -343,10 +333,10 @@ pcl::LCCPSegmentation<PointT>::recursiveSegmentGrowing (const VertexID &query_po
   sv_label_to_seg_label_map_[sv_label] = segment_label;
   seg_label_to_sv_list_map_[segment_label].insert (sv_label);
 
+  OutEdgeIterator out_Edge_itr, out_Edge_itr_end;
   // Iterate through all neighbors of this supervoxel and check whether they should be merged with the current supervoxel
-  std::pair<OutEdgeIterator, OutEdgeIterator> out_edge_iterator_range;
-  out_edge_iterator_range = boost::out_edges (query_point_id, sv_adjacency_list_);  // adjacent vertices to node (*itr) in graph sv_adjacency_list_
-  for (OutEdgeIterator out_Edge_itr = out_edge_iterator_range.first; out_Edge_itr != out_edge_iterator_range.second; ++out_Edge_itr)
+  // boost::out_edges (query_point_id, sv_adjacency_list_): adjacent vertices to node (*itr) in graph sv_adjacency_list_
+  for (std::tie(out_Edge_itr, out_Edge_itr_end) = boost::out_edges (query_point_id, sv_adjacency_list_); out_Edge_itr != out_Edge_itr_end; ++out_Edge_itr)
   {
     const VertexID neighbor_ID = boost::target (*out_Edge_itr, sv_adjacency_list_);
     const std::uint32_t& neighbor_label = sv_adjacency_list_[neighbor_ID];
@@ -367,37 +357,29 @@ pcl::LCCPSegmentation<PointT>::applyKconvexity (const unsigned int k_arg)
   if (k_arg == 0)
     return;
 
-  unsigned int kcount = 0;
-
   EdgeIterator edge_itr, edge_itr_end, next_edge;
-  boost::tie (edge_itr, edge_itr_end) = boost::edges (sv_adjacency_list_);
-
-  std::pair<OutEdgeIterator, OutEdgeIterator> source_neighbors_range;
-  std::pair<OutEdgeIterator, OutEdgeIterator> target_neighbors_range;
-
   // Check all edges in the graph for k-convexity
-  for (next_edge = edge_itr; edge_itr != edge_itr_end; edge_itr = next_edge)
+  for (std::tie (edge_itr, edge_itr_end) = boost::edges (sv_adjacency_list_), next_edge = edge_itr; edge_itr != edge_itr_end; edge_itr = next_edge)
   {
-    next_edge++;  // next_edge iterator is necessary, because removing an edge invalidates the iterator to the current edge
+    ++next_edge;  // next_edge iterator is necessary, because removing an edge invalidates the iterator to the current edge
 
     bool is_convex = sv_adjacency_list_[*edge_itr].is_convex;
 
     if (is_convex)  // If edge is (0-)convex
     {
-      kcount = 0;
+      unsigned int kcount = 0;
 
       const VertexID source = boost::source (*edge_itr, sv_adjacency_list_);
       const VertexID target = boost::target (*edge_itr, sv_adjacency_list_);
 
-      source_neighbors_range = boost::out_edges (source, sv_adjacency_list_);
-      target_neighbors_range = boost::out_edges (target, sv_adjacency_list_);
-
+      OutEdgeIterator source_neighbors_itr, source_neighbors_itr_end;
       // Find common neighbors, check their connection
-      for (OutEdgeIterator source_neighbors_itr = source_neighbors_range.first; source_neighbors_itr != source_neighbors_range.second; ++source_neighbors_itr)  // For all supervoxels
+      for (std::tie(source_neighbors_itr, source_neighbors_itr_end) = boost::out_edges (source, sv_adjacency_list_); source_neighbors_itr != source_neighbors_itr_end; ++source_neighbors_itr)  // For all supervoxels
       {
         VertexID source_neighbor_ID = boost::target (*source_neighbors_itr, sv_adjacency_list_);
 
-        for (OutEdgeIterator target_neighbors_itr = target_neighbors_range.first; target_neighbors_itr != target_neighbors_range.second; ++target_neighbors_itr)  // For all supervoxels
+        OutEdgeIterator target_neighbors_itr, target_neighbors_itr_end;
+        for (std::tie(target_neighbors_itr, target_neighbors_itr_end) = boost::out_edges (target, sv_adjacency_list_); target_neighbors_itr != target_neighbors_itr_end; ++target_neighbors_itr)  // For all supervoxels
         {
           VertexID target_neighbor_ID = boost::target (*target_neighbors_itr, sv_adjacency_list_);
           if (source_neighbor_ID == target_neighbor_ID)  // Common neighbor
@@ -431,11 +413,9 @@ pcl::LCCPSegmentation<PointT>::calculateConvexConnections (SupervoxelAdjacencyLi
 {
 
   EdgeIterator edge_itr, edge_itr_end, next_edge;
-  boost::tie (edge_itr, edge_itr_end) = boost::edges (adjacency_list_arg);
-
-  for (next_edge = edge_itr; edge_itr != edge_itr_end; edge_itr = next_edge)
+  for (std::tie(edge_itr, edge_itr_end) = boost::edges (adjacency_list_arg), next_edge = edge_itr; edge_itr != edge_itr_end; edge_itr = next_edge)
   {
-    next_edge++;  // next_edge iterator is necessary, because removing an edge invalidates the iterator to the current edge
+    ++next_edge;  // next_edge iterator is necessary, because removing an edge invalidates the iterator to the current edge
 
     std::uint32_t source_sv_label = adjacency_list_arg[boost::source (*edge_itr, adjacency_list_arg)];
     std::uint32_t target_sv_label = adjacency_list_arg[boost::target (*edge_itr, adjacency_list_arg)];
index c95aa40daa7a66eed92532f98f5c6e04f34f40b1..34abc08a7cc28a380d8274147b243d614f292a01 100644 (file)
@@ -238,11 +238,10 @@ pcl::MinCutSegmentation<PointT>::extract (std::vector <pcl::PointIndices>& clust
   }
 
   clusters_.clear ();
-  bool success = true;
 
   if ( !graph_is_valid_ )
   {
-    success = buildGraph ();
+    bool success = buildGraph ();
     if (!success)
     {
       deinitCompute ();
@@ -255,7 +254,7 @@ pcl::MinCutSegmentation<PointT>::extract (std::vector <pcl::PointIndices>& clust
 
   if ( !unary_potentials_are_valid_ )
   {
-    success = recalculateUnaryPotentials ();
+    bool success = recalculateUnaryPotentials ();
     if (!success)
     {
       deinitCompute ();
@@ -266,7 +265,7 @@ pcl::MinCutSegmentation<PointT>::extract (std::vector <pcl::PointIndices>& clust
 
   if ( !binary_potentials_are_valid_ )
   {
-    success = recalculateBinaryPotentials ();
+    bool success = recalculateBinaryPotentials ();
     if (!success)
     {
       deinitCompute ();
@@ -339,7 +338,7 @@ pcl::MinCutSegmentation<PointT>::buildGraph ()
 
   for (int i_point = 0; i_point < number_of_indices; i_point++)
   {
-    int point_index = (*indices_)[i_point];
+    index_t point_index = (*indices_)[i_point];
     double source_weight = 0.0;
     double sink_weight = 0.0;
     calculateUnaryPotential (point_index, source_weight, sink_weight);
@@ -352,7 +351,7 @@ pcl::MinCutSegmentation<PointT>::buildGraph ()
   search_->setInputCloud (input_, indices_);
   for (int i_point = 0; i_point < number_of_indices; i_point++)
   {
-    int point_index = (*indices_)[i_point];
+    index_t point_index = (*indices_)[i_point];
     search_->nearestKSearch (i_point, number_of_neighbours_, neighbours, distances);
     for (std::size_t i_nghbr = 1; i_nghbr < neighbours.size (); i_nghbr++)
     {
@@ -373,8 +372,6 @@ pcl::MinCutSegmentation<PointT>::calculateUnaryPotential (int point, double& sou
 {
   double min_dist_to_foreground = std::numeric_limits<double>::max ();
   //double min_dist_to_background = std::numeric_limits<double>::max ();
-  double closest_foreground_point[2];
-  closest_foreground_point[0] = closest_foreground_point[1] = 0;
   //double closest_background_point[] = {0.0, 0.0};
   double initial_point[] = {0.0, 0.0};
 
@@ -389,8 +386,6 @@ pcl::MinCutSegmentation<PointT>::calculateUnaryPotential (int point, double& sou
     if (min_dist_to_foreground > dist)
     {
       min_dist_to_foreground = dist;
-      closest_foreground_point[0] = foreground_points_[i_point].x;
-      closest_foreground_point[1] = foreground_points_[i_point].y;
     }
   }
 
@@ -587,10 +582,9 @@ pcl::MinCutSegmentation<PointT>::getColoredCloud ()
     colored_cloud->is_dense = input_->is_dense;
 
     pcl::PointXYZRGB point;
-    int point_index = 0;
     for (int i_point = 0; i_point < num_of_pts_in_first_cluster; i_point++)
     {
-      point_index = clusters_[0].indices[i_point];
+      index_t point_index = clusters_[0].indices[i_point];
       point.x = *(input_->points[point_index].data);
       point.y = *(input_->points[point_index].data + 1);
       point.z = *(input_->points[point_index].data + 2);
@@ -602,7 +596,7 @@ pcl::MinCutSegmentation<PointT>::getColoredCloud ()
 
     for (int i_point = 0; i_point < num_of_pts_in_second_cluster; i_point++)
     {
-      point_index = clusters_[1].indices[i_point];
+      index_t point_index = clusters_[1].indices[i_point];
       point.x = *(input_->points[point_index].data);
       point.y = *(input_->points[point_index].data + 1);
       point.z = *(input_->points[point_index].data + 2);
index 5928e92cbc77ae45dfa7b37869b899e877920ffa..be0a6a7ba4f88b8328c715bfed074e64a9142ea5 100644 (file)
@@ -91,6 +91,13 @@ pcl::OrganizedMultiPlaneSegmentation<PointT, PointNT, PointLT>::segment (std::ve
   if (!initCompute ())
     return;
 
+  // Check that the normals are present
+  if (!normals_)
+  {
+    PCL_ERROR( "[pcl::%s::segment] Must specify normals.\n", getClassName().c_str());
+    return;
+  }
+
   // Check that we got the same number of points and normals
   if (static_cast<int> (normals_->points.size ()) != static_cast<int> (input_->points.size ()))
   {
index f65ad66cdb1603d185ebd37af2b4a58f3adc7235..f1e22d375a26f8699ed3b618624aa389881d19bf 100644 (file)
  *
  */
 
-#ifndef PCL_SEGMENTATION_REGION_GROWING_HPP_
-#define PCL_SEGMENTATION_REGION_GROWING_HPP_
+#pragma once
 
 #include <pcl/segmentation/region_growing.h>
 
-#include <pcl/search/search.h>
-#include <pcl/search/kdtree.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+#include <pcl/search/search.h>
+#include <pcl/search/kdtree.h>
 
 #include <queue>
 #include <list>
@@ -741,4 +741,3 @@ pcl::RegionGrowing<PointT, NormalT>::getColoredCloudRGBA ()
 
 #define PCL_INSTANTIATE_RegionGrowing(T) template class pcl::RegionGrowing<T, pcl::Normal>;
 
-#endif    // PCL_SEGMENTATION_REGION_GROWING_HPP_
index 0b36c56ce7bec900a2e84d9305538e034d610e04..ac77f22d81d40c107c405cba689b35bcd5aa145e 100644 (file)
@@ -70,6 +70,8 @@
 #include <pcl/sample_consensus/sac_model_normal_sphere.h>
 #include <pcl/sample_consensus/sac_model_stick.h>
 
+#include <pcl/memory.h>  // for static_pointer_cast
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
 pcl::SACSegmentation<PointT>::segment (PointIndices &inliers, ModelCoefficients &model_coefficients)
@@ -167,7 +169,7 @@ pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CIRCLE2D\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelCircle2D<PointT> (input_, *indices_, random_));
-      typename SampleConsensusModelCircle2D<PointT>::Ptr model_circle = boost::static_pointer_cast<SampleConsensusModelCircle2D<PointT> > (model_);
+      typename SampleConsensusModelCircle2D<PointT>::Ptr model_circle = static_pointer_cast<SampleConsensusModelCircle2D<PointT> > (model_);
       double min_radius, max_radius;
       model_circle->getRadiusLimits (min_radius, max_radius);
       if (radius_min_ != min_radius && radius_max_ != max_radius)
@@ -181,7 +183,7 @@ pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CIRCLE3D\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelCircle3D<PointT> (input_, *indices_));
-      typename SampleConsensusModelCircle3D<PointT>::Ptr model_circle3d = boost::static_pointer_cast<SampleConsensusModelCircle3D<PointT> > (model_);
+      typename SampleConsensusModelCircle3D<PointT>::Ptr model_circle3d = static_pointer_cast<SampleConsensusModelCircle3D<PointT> > (model_);
       double min_radius, max_radius;
       model_circle3d->getRadiusLimits (min_radius, max_radius);
       if (radius_min_ != min_radius && radius_max_ != max_radius)
@@ -195,7 +197,7 @@ pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_SPHERE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelSphere<PointT> (input_, *indices_, random_));
-      typename SampleConsensusModelSphere<PointT>::Ptr model_sphere = boost::static_pointer_cast<SampleConsensusModelSphere<PointT> > (model_);
+      typename SampleConsensusModelSphere<PointT>::Ptr model_sphere = static_pointer_cast<SampleConsensusModelSphere<PointT> > (model_);
       double min_radius, max_radius;
       model_sphere->getRadiusLimits (min_radius, max_radius);
       if (radius_min_ != min_radius && radius_max_ != max_radius)
@@ -209,7 +211,7 @@ pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PARALLEL_LINE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelParallelLine<PointT> (input_, *indices_, random_));
-      typename SampleConsensusModelParallelLine<PointT>::Ptr model_parallel = boost::static_pointer_cast<SampleConsensusModelParallelLine<PointT> > (model_);
+      typename SampleConsensusModelParallelLine<PointT>::Ptr model_parallel = static_pointer_cast<SampleConsensusModelParallelLine<PointT> > (model_);
       if (axis_ != Eigen::Vector3f::Zero () && model_parallel->getAxis () != axis_)
       {
         PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
@@ -226,7 +228,7 @@ pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PERPENDICULAR_PLANE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelPerpendicularPlane<PointT> (input_, *indices_, random_));
-      typename SampleConsensusModelPerpendicularPlane<PointT>::Ptr model_perpendicular = boost::static_pointer_cast<SampleConsensusModelPerpendicularPlane<PointT> > (model_);
+      typename SampleConsensusModelPerpendicularPlane<PointT>::Ptr model_perpendicular = static_pointer_cast<SampleConsensusModelPerpendicularPlane<PointT> > (model_);
       if (axis_ != Eigen::Vector3f::Zero () && model_perpendicular->getAxis () != axis_)
       {
         PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
@@ -243,7 +245,7 @@ pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PARALLEL_PLANE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelParallelPlane<PointT> (input_, *indices_, random_));
-      typename SampleConsensusModelParallelPlane<PointT>::Ptr model_parallel = boost::static_pointer_cast<SampleConsensusModelParallelPlane<PointT> > (model_);
+      typename SampleConsensusModelParallelPlane<PointT>::Ptr model_parallel = static_pointer_cast<SampleConsensusModelParallelPlane<PointT> > (model_);
       if (axis_ != Eigen::Vector3f::Zero () && model_parallel->getAxis () != axis_)
       {
         PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
@@ -368,7 +370,7 @@ pcl::SACSegmentationFromNormals<PointT, PointNT>::initSACModel (const int model_
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CYLINDER\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelCylinder<PointT, PointNT > (input_, *indices_, random_));
-      typename SampleConsensusModelCylinder<PointT, PointNT>::Ptr model_cylinder = boost::static_pointer_cast<SampleConsensusModelCylinder<PointT, PointNT> > (model_);
+      typename SampleConsensusModelCylinder<PointT, PointNT>::Ptr model_cylinder = static_pointer_cast<SampleConsensusModelCylinder<PointT, PointNT> > (model_);
 
       // Set the input normals
       model_cylinder->setInputNormals (normals_);
@@ -400,7 +402,7 @@ pcl::SACSegmentationFromNormals<PointT, PointNT>::initSACModel (const int model_
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_NORMAL_PLANE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelNormalPlane<PointT, PointNT> (input_, *indices_, random_));
-      typename SampleConsensusModelNormalPlane<PointT, PointNT>::Ptr model_normals = boost::static_pointer_cast<SampleConsensusModelNormalPlane<PointT, PointNT> > (model_);
+      typename SampleConsensusModelNormalPlane<PointT, PointNT>::Ptr model_normals = static_pointer_cast<SampleConsensusModelNormalPlane<PointT, PointNT> > (model_);
       // Set the input normals
       model_normals->setInputNormals (normals_);
       if (distance_weight_ != model_normals->getNormalDistanceWeight ())
@@ -414,7 +416,7 @@ pcl::SACSegmentationFromNormals<PointT, PointNT>::initSACModel (const int model_
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_NORMAL_PARALLEL_PLANE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelNormalParallelPlane<PointT, PointNT> (input_, *indices_, random_));
-      typename SampleConsensusModelNormalParallelPlane<PointT, PointNT>::Ptr model_normals = boost::static_pointer_cast<SampleConsensusModelNormalParallelPlane<PointT, PointNT> > (model_);
+      typename SampleConsensusModelNormalParallelPlane<PointT, PointNT>::Ptr model_normals = static_pointer_cast<SampleConsensusModelNormalParallelPlane<PointT, PointNT> > (model_);
       // Set the input normals
       model_normals->setInputNormals (normals_);
       if (distance_weight_ != model_normals->getNormalDistanceWeight ())
@@ -443,7 +445,7 @@ pcl::SACSegmentationFromNormals<PointT, PointNT>::initSACModel (const int model_
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CONE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelCone<PointT, PointNT> (input_, *indices_, random_));
-      typename SampleConsensusModelCone<PointT, PointNT>::Ptr model_cone = boost::static_pointer_cast<SampleConsensusModelCone<PointT, PointNT> > (model_);
+      typename SampleConsensusModelCone<PointT, PointNT>::Ptr model_cone = static_pointer_cast<SampleConsensusModelCone<PointT, PointNT> > (model_);
 
       // Set the input normals
       model_cone->setInputNormals (normals_);
@@ -476,7 +478,7 @@ pcl::SACSegmentationFromNormals<PointT, PointNT>::initSACModel (const int model_
     {
       PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_NORMAL_SPHERE\n", getClassName ().c_str ());
       model_.reset (new SampleConsensusModelNormalSphere<PointT, PointNT> (input_, *indices_, random_));
-      typename SampleConsensusModelNormalSphere<PointT, PointNT>::Ptr model_normals_sphere = boost::static_pointer_cast<SampleConsensusModelNormalSphere<PointT, PointNT> > (model_);
+      typename SampleConsensusModelNormalSphere<PointT, PointNT>::Ptr model_normals_sphere = static_pointer_cast<SampleConsensusModelNormalSphere<PointT, PointNT> > (model_);
       // Set the input normals
       model_normals_sphere->setInputNormals (normals_);
       double min_radius, max_radius;
index 32c27bf7bc82ed13062afa05d3aa8440445f411f..7c499593d406347f6a43072149328301ad121ee3 100755 (executable)
  *
  */
 
-#ifndef PCL_SEGMENTATION_IMPL_SEGMENT_DIFFERENCES_H_
-#define PCL_SEGMENTATION_IMPL_SEGMENT_DIFFERENCES_H_
+#pragma once
 
 #include <pcl/segmentation/segment_differences.h>
+
 #include <pcl/common/io.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
 
 //////////////////////////////////////////////////////////////////////////
 template <typename PointT> void
@@ -121,4 +123,3 @@ pcl::SegmentDifferences<PointT>::segment (PointCloud &output)
 #define PCL_INSTANTIATE_SegmentDifferences(T) template class PCL_EXPORTS pcl::SegmentDifferences<T>;
 #define PCL_INSTANTIATE_getPointCloudDifference(T) template PCL_EXPORTS void pcl::getPointCloudDifference<T>(const pcl::PointCloud<T> &, double, const typename pcl::search::Search<T>::Ptr &, pcl::PointCloud<T> &);
 
-#endif        // PCL_SEGMENTATION_IMPL_SEGMENT_DIFFERENCES_H_
index 5c66eb459e68724aa645b715d5bbbd05b5a0dda6..ad7a2cc75e93f33112039f57ac628689ce490e8b 100644 (file)
@@ -62,18 +62,18 @@ namespace pcl
     {
       /** \brief Describes the difference of normals of the two supervoxels being connected*/
       float normal_difference;
-      
+
       /** \brief Describes if a connection is convex or concave*/
       bool is_convex;
-      
+
       /** \brief Describes if a connection is valid for the segment growing. Usually convex connections are and concave connection are not. Due to k-concavity a convex connection can be invalidated*/
       bool is_valid;
-      
+
       /** \brief Additional member used for the CPC algorithm. If edge has already induced a cut, it should be ignored for further cutting.*/
       bool used_for_cutting;
-      
+
       EdgeProperties () :
-      normal_difference (0), is_convex (false), is_valid (false), used_for_cutting (false) 
+      normal_difference (0), is_convex (false), is_valid (false), used_for_cutting (false)
       {
       }
     };
@@ -98,10 +98,10 @@ namespace pcl
       void
       reset ();
 
-      
+
       /** \brief Set the supervoxel clusters as well as the adjacency graph for the segmentation.Those parameters are generated by using the \ref SupervoxelClustering class. To retrieve the output use the \ref segment method.
        *  \param[in] supervoxel_clusters_arg Map of < supervoxel labels, supervoxels >
-       *  \param[in] label_adjacency_arg The graph defining the supervoxel adjacency relations  
+       *  \param[in] label_adjacency_arg The graph defining the supervoxel adjacency relations
        *  \note Implicitly calls \ref reset */
       inline void
       setInputSupervoxels (const std::map<std::uint32_t, typename pcl::Supervoxel<PointT>::Ptr> &supervoxel_clusters_arg,
@@ -111,17 +111,17 @@ namespace pcl
         prepareSegmentation (supervoxel_clusters_arg, label_adjacency_arg);  // after this, sv_adjacency_list_ can be used to access adjacency list
         supervoxels_set_ = true;
       }
-      
+
       /** \brief Merge supervoxels using local convexity. The input parameters are generated by using the \ref SupervoxelClustering class. To retrieve the output use the \ref relabelCloud method.
-       *  \note There are three ways to retrieve the segmentation afterwards: \ref relabelCloud, \ref getSegmentSupervoxelMap and \ref getSupervoxelSegmentMap*/
+       *  \note There are three ways to retrieve the segmentation afterwards: \ref relabelCloud, \ref getSegmentToSupervoxelMap and \ref getSupervoxelToSegmentMap. */
       void
       segment ();
 
-      /** \brief Relabels cloud with supervoxel labels with the computed segment labels. labeled_cloud_arg should be created using the \ref getLabeledCloud method of the \ref SupervoxelClustering class.
+      /** \brief Relabels cloud with supervoxel labels with the computed segment labels. labeled_cloud_arg should be created using SupervoxelClustering::getLabeledCloud.
        *  \param[in,out] labeled_cloud_arg Cloud to relabel  */
       void
       relabelCloud (pcl::PointCloud<pcl::PointXYZL> &labeled_cloud_arg);
-      
+
       /** \brief Get map<SegmentID, std::set<SuperVoxel IDs> >
        *  \param[out] segment_supervoxel_map_arg The output container. On error the map is empty. */
       inline void
@@ -137,7 +137,7 @@ namespace pcl
           segment_supervoxel_map_arg = std::map<std::uint32_t, std::set<std::uint32_t> > ();
         }
       }
-      
+
       /** \brief Get map<Supervoxel_ID, Segment_ID>
        *  \param[out] supervoxel_segment_map_arg The output container. On error the map is empty. */
       inline void
@@ -153,7 +153,7 @@ namespace pcl
           supervoxel_segment_map_arg = std::map<std::uint32_t, std::uint32_t> ();
         }
       }
-      
+
       /** \brief Get map <SegmentID, std::set<Neighboring SegmentIDs> >
        * \param[out] segment_adjacency_map_arg map < SegmentID, std::set< Neighboring SegmentIDs> >. On error the map is empty.  */
       inline void
@@ -171,7 +171,7 @@ namespace pcl
           segment_adjacency_map_arg = std::map<std::uint32_t, std::set<std::uint32_t> > ();
         }
       }
-      
+
       /** \brief Get normal threshold
        *  \return The concavity tolerance angle in [deg] that is currently set */
       inline float
@@ -179,7 +179,7 @@ namespace pcl
       {
         return (concavity_tolerance_threshold_);
       }
-      
+
       /** \brief Get the supervoxel adjacency graph with classified edges (boost::adjacency_list).
        * \param[out] adjacency_list_arg The supervoxel adjacency list with classified (convex/concave) edges. On error the list is empty.  */
       inline void
@@ -195,7 +195,7 @@ namespace pcl
           adjacency_list_arg = pcl::LCCPSegmentation<PointT>::SupervoxelAdjacencyList ();
         }
       }
-      
+
       /** \brief Set normal threshold
        *  \param[in] concavity_tolerance_threshold_arg the concavity tolerance angle in [deg] to set */
       inline void
@@ -236,7 +236,7 @@ namespace pcl
       {
         k_factor_ = k_factor_arg;
       }
-      
+
       /** \brief Set the value \ref min_segment_size_ used in \ref mergeSmallSegments
        *  \param[in] min_segment_size_arg Segments smaller than this size will be merged */
       inline void
@@ -267,7 +267,7 @@ namespace pcl
        *  \note The vertices in the supervoxel adjacency list are the supervoxel centroids */
       void
       doGrouping ();
-      
+
       /** \brief Assigns neighbors of the query point to the same group as the query point. Recursive part of \ref doGrouping. Grouping is done by a depth-search of nodes in the adjacency-graph.
        *  \param[in] queryPointID ID of point whose neighbors will be considered for grouping
        *  \param[in] group_label ID of the group/segment the queried point belongs to  */
@@ -302,7 +302,7 @@ namespace pcl
 
       /** \brief Marks if valid grouping data (\ref sv_adjacency_list_, \ref sv_label_to_seg_label_map_, \ref processed_) is available */
       bool grouping_data_valid_;
-      
+
       /** \brief Marks if supervoxels have been set by calling \ref setInputSupervoxels */
       bool supervoxels_set_;
 
@@ -314,7 +314,7 @@ namespace pcl
 
       /** \brief Determines if we use the sanity check which tries to find and invalidate singular connected patches*/
       bool use_sanity_check_;
-      
+
       /** \brief Seed resolution of the supervoxels (used only for smoothness check) */
       float seed_resolution_;
 
@@ -323,11 +323,11 @@ namespace pcl
 
       /** \brief Factor used for k-convexity */
       std::uint32_t k_factor_;
-      
+
       /** \brief Minimum segment size */
       std::uint32_t min_segment_size_;
 
-      /** \brief Stores which supervoxel labels were already visited during recursive grouping.    
+      /** \brief Stores which supervoxel labels were already visited during recursive grouping.
        *  \note processed_[sv_Label] = false (default)/true (already processed) */
       std::map<std::uint32_t, bool> processed_;
 
@@ -337,11 +337,11 @@ namespace pcl
       /** \brief map from the supervoxel labels to the supervoxel objects  */
       std::map<std::uint32_t, typename pcl::Supervoxel<PointT>::Ptr> sv_label_to_supervoxel_map_;
 
-      /** \brief Storing relation between original SuperVoxel Labels and new segmantion labels. 
+      /** \brief Storing relation between original SuperVoxel Labels and new segmantion labels.
        *  \note sv_label_to_seg_label_map_[old_labelID] = new_labelID */
       std::map<std::uint32_t, std::uint32_t> sv_label_to_seg_label_map_;
 
-      /** \brief map <Segment Label, std::set <SuperVoxel Labels> > */
+      /** \brief map Segment Label to a set of Supervoxel Labels */
       std::map<std::uint32_t, std::set<std::uint32_t> > seg_label_to_sv_list_map_;
 
       /** \brief map < SegmentID, std::set< Neighboring segment labels> > */
index 5307e32fa7086d537694c93a1e9c68ca1439f2f8..f2a268977902046b28def6af950c5a53e0f6ef17 100644 (file)
@@ -39,6 +39,7 @@
 #pragma once
 
 #include <pcl/segmentation/boost.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
@@ -156,7 +157,7 @@ namespace pcl
 
       /** \brief Allows to set search method for finding KNN.
         * The graph is build such way that it contains the edges that connect point and its KNN.
-        * \param[in] search search method that will be used for finding KNN.
+        * \param[in] tree search method that will be used for finding KNN.
         */
       void
       setSearchMethod (const KdTreePtr& tree);
@@ -166,7 +167,7 @@ namespace pcl
       getNumberOfNeighbours () const;
 
       /** \brief Allows to set the number of neighbours to find.
-        * \param[in] number_of_neighbours new number of neighbours
+        * \param[in] neighbour_number new number of neighbours
         */
       void
       setNumberOfNeighbours (unsigned int neighbour_number);
index e73b7a24c68ba5152678311880bb02cbfa9740ae..26edba5c33c6a154f09b84ae569b1fea7e8f4294 100644 (file)
@@ -43,6 +43,7 @@
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/common/angles.h>
+#include <pcl/common/utils.h>
 #include <pcl/PointIndices.h>
 #include <pcl/ModelCoefficients.h>
 #include <pcl/segmentation/plane_coefficient_comparator.h>
@@ -285,15 +286,17 @@ namespace pcl
         * \param [in] labels The labels produced by the initial segmentation
         * \param [in] label_indices The list of indices corresponding to each label
         */
-      PCL_DEPRECATED("centroids and covariances parameters are not used; they are deprecated and will be removed in future releases")
+      PCL_DEPRECATED(1, 12, "centroids and covariances parameters are not used; they are deprecated and will be removed in future releases")
       void
       refine (std::vector<ModelCoefficients>& model_coefficients, 
               std::vector<PointIndices>& inlier_indices,
-              std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >& /*centroids*/,
-              std::vector <Eigen::Matrix3f, Eigen::aligned_allocator<Eigen::Matrix3f> >& /*covariances*/,
+              std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >& centroids,
+              std::vector <Eigen::Matrix3f, Eigen::aligned_allocator<Eigen::Matrix3f> >& covariances,
               PointCloudLPtr& labels,
               std::vector<pcl::PointIndices>& label_indices)
       {
+        pcl::utils::ignore(centroids);
+        pcl::utils::ignore(covariances);
         refine(model_coefficients, inlier_indices, labels, label_indices);
       }
 
index 69f1ec290928d878e033da75733b97d66712606d..5897ce2783121e13a0f06929260253a05735565c 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/segmentation/region_3d.h>
 #include <pcl/geometry/planar_polygon.h>
index d7933974903bf9956b3366e2b1be2c8053a05e15..a7f6ba9d327b417d046d7f88571db0530520ee6c 100644 (file)
@@ -40,8 +40,8 @@
 #pragma once
 
 #include <pcl/common/angles.h>
+#include <pcl/memory.h> // for pcl::make_shared, pcl::shared_ptr
 #include <pcl/pcl_macros.h>
-#include <pcl/segmentation/boost.h>
 #include <pcl/segmentation/comparator.h>
 
 namespace pcl
@@ -57,16 +57,16 @@ namespace pcl
     public:
       using PointCloud = typename Comparator<PointT>::PointCloud;
       using PointCloudConstPtr = typename Comparator<PointT>::PointCloudConstPtr;
-      
+
       using PointCloudN = pcl::PointCloud<PointNT>;
       using PointCloudNPtr = typename PointCloudN::Ptr;
       using PointCloudNConstPtr = typename PointCloudN::ConstPtr;
-      
+
       using Ptr = shared_ptr<PlaneCoefficientComparator<PointT, PointNT> >;
       using ConstPtr = shared_ptr<const PlaneCoefficientComparator<PointT, PointNT> >;
 
       using pcl::Comparator<PointT>::input_;
-      
+
       /** \brief Empty constructor for PlaneCoefficientComparator. */
       PlaneCoefficientComparator ()
         : normals_ ()
@@ -80,7 +80,7 @@ namespace pcl
       /** \brief Constructor for PlaneCoefficientComparator.
         * \param[in] plane_coeff_d a reference to a vector of d coefficients of plane equations.  Must be the same size as the input cloud and input normals.  a, b, and c coefficients are in the input normals.
         */
-      PlaneCoefficientComparator (shared_ptr<std::vector<float> >& plane_coeff_d) 
+      PlaneCoefficientComparator (shared_ptr<std::vector<float> >& plane_coeff_d)
         : normals_ ()
         , plane_coeff_d_ (plane_coeff_d)
         , angular_threshold_ (pcl::deg2rad (2.0f))
@@ -89,19 +89,19 @@ namespace pcl
         , z_axis_ (Eigen::Vector3f (0.0f, 0.0f, 1.0f) )
       {
       }
-      
+
       /** \brief Destructor for PlaneCoefficientComparator. */
-      
+
       ~PlaneCoefficientComparator ()
       {
       }
 
-      void 
+      void
       setInputCloud (const PointCloudConstPtr& cloud) override
       {
         input_ = cloud;
       }
-      
+
       /** \brief Provide a pointer to the input normals.
         * \param[in] normals the input normal cloud
         */
@@ -133,9 +133,9 @@ namespace pcl
       void
       setPlaneCoeffD (std::vector<float>& plane_coeff_d)
       {
-        plane_coeff_d_ = boost::make_shared<std::vector<float> >(plane_coeff_d);
+        plane_coeff_d_ = pcl::make_shared<std::vector<float> >(plane_coeff_d);
       }
-      
+
       /** \brief Get a pointer to the vector of the d-coefficient of the planes' hessian normal form. */
       const std::vector<float>&
       getPlaneCoeffD () const
@@ -151,7 +151,7 @@ namespace pcl
       {
         angular_threshold_ = std::cos (angular_threshold);
       }
-      
+
       /** \brief Get the angular threshold in radians for difference in normal direction between neighboring points, to be considered part of the same plane. */
       inline float
       getAngularThreshold () const
@@ -164,7 +164,7 @@ namespace pcl
         * \param[in] depth_dependent whether to scale the threshold based on range from the sensor (default: false)
         */
       void
-      setDistanceThreshold (float distance_threshold, 
+      setDistanceThreshold (float distance_threshold,
                             bool depth_dependent = false)
       {
         distance_threshold_ = distance_threshold;
@@ -177,7 +177,7 @@ namespace pcl
       {
         return (distance_threshold_);
       }
-      
+
       /** \brief Compare points at two indices by their plane equations.  True if the angle between the normals is less than the angular threshold,
         * and the difference between the d component of the normals is less than distance threshold, else false
         * \param idx1 The first index for the comparison
@@ -190,14 +190,14 @@ namespace pcl
         if (depth_dependent_)
         {
           Eigen::Vector3f vec = input_->points[idx1].getVector3fMap ();
-          
+
           float z = vec.dot (z_axis_);
           threshold *= z * z;
         }
         return ( (std::fabs ((*plane_coeff_d_)[idx1] - (*plane_coeff_d_)[idx2]) < threshold)
                  && (normals_->points[idx1].getNormalVector3fMap ().dot (normals_->points[idx2].getNormalVector3fMap () ) > angular_threshold_ ) );
       }
-      
+
     protected:
       PointCloudNConstPtr normals_;
       shared_ptr<std::vector<float> > plane_coeff_d_;
index 7c4bb0ecd5e9187a2e04b24e9dfe7af7ec3e780a..735e152a48a6ee375a3320f2c4e1cea41f0141d9 100644 (file)
 
 #pragma once
 
-#include <pcl/segmentation/boost.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/segmentation/plane_coefficient_comparator.h>
 
 namespace pcl
 {
-  /** \brief PlaneRefinementComparator is a Comparator that operates on plane coefficients, 
+  /** \brief PlaneRefinementComparator is a Comparator that operates on plane coefficients,
     * for use in planar segmentation.
     * In conjunction with OrganizedConnectedComponentSegmentation, this allows planes to be segmented from organized data.
     *
@@ -56,7 +56,7 @@ namespace pcl
     public:
       using PointCloud = typename Comparator<PointT>::PointCloud;
       using PointCloudConstPtr = typename Comparator<PointT>::PointCloudConstPtr;
-      
+
       using PointCloudN = pcl::PointCloud<PointNT>;
       using PointCloudNPtr = typename PointCloudN::Ptr;
       using PointCloudNConstPtr = typename PointCloudN::ConstPtr;
@@ -81,7 +81,7 @@ namespace pcl
       {
       }
 
-      /** \brief Empty constructor for PlaneCoefficientComparator. 
+      /** \brief Empty constructor for PlaneCoefficientComparator.
         * \param[in] models
         * \param[in] refine_labels
         */
@@ -95,7 +95,6 @@ namespace pcl
       }
 
       /** \brief Destructor for PlaneCoefficientComparator. */
-      
       ~PlaneRefinementComparator ()
       {
       }
@@ -115,7 +114,7 @@ namespace pcl
       void
       setModelCoefficients (std::vector<pcl::ModelCoefficients>& models)
       {
-        models_ = boost::make_shared<std::vector<pcl::ModelCoefficients> >(models);
+        models_ = pcl::make_shared<std::vector<pcl::ModelCoefficients> >(models);
       }
 
       /** \brief Set which labels should be refined.  This is a vector of bools 0-max_label, true if the label should be refined.
@@ -126,14 +125,14 @@ namespace pcl
       {
         refine_labels_ = refine_labels;
       }
-      
+
       /** \brief Set which labels should be refined.  This is a vector of bools 0-max_label, true if the label should be refined.
         * \param[in] refine_labels A vector of bools 0-max_label, true if the label should be refined.
         */
       void
       setRefineLabels (std::vector<bool>& refine_labels)
       {
-        refine_labels_ = boost::make_shared<std::vector<bool> >(refine_labels);
+        refine_labels_ = pcl::make_shared<std::vector<bool> >(refine_labels);
       }
 
       /** \brief A mapping from label to index in the vector of models, allowing the model coefficients of a label to be accessed.
@@ -144,14 +143,14 @@ namespace pcl
       {
         label_to_model_ = label_to_model;
       }
-      
+
       /** \brief A mapping from label to index in the vector of models, allowing the model coefficients of a label to be accessed.
         * \param[in] label_to_model A vector of size max_label, with the index of each corresponding model in models
         */
       inline void
       setLabelToModel (std::vector<int>& label_to_model)
       {
-        label_to_model_ = boost::make_shared<std::vector<int> >(label_to_model);
+        label_to_model_ = pcl::make_shared<std::vector<int> >(label_to_model);
       }
 
       /** \brief Get the vector of model coefficients to which we will compare. */
@@ -182,26 +181,26 @@ namespace pcl
 
         if (!((*refine_labels_)[current_label] && !(*refine_labels_)[next_label]))
           return (false);
-        
+
         const pcl::ModelCoefficients& model_coeff = (*models_)[(*label_to_model_)[current_label]];
-        
+
         PointT pt = input_->points[idx2];
-        double ptp_dist = std::fabs (model_coeff.values[0] * pt.x + 
-                                model_coeff.values[1] * pt.y + 
+        double ptp_dist = std::fabs (model_coeff.values[0] * pt.x +
+                                model_coeff.values[1] * pt.y +
                                 model_coeff.values[2] * pt.z +
                                 model_coeff.values[3]);
-        
+
         // depth dependent
         float threshold = distance_threshold_;
         if (depth_dependent_)
         {
           //Eigen::Vector4f origin = input_->sensor_origin_;
           Eigen::Vector3f vec = input_->points[idx1].getVector3fMap ();// - origin.head<3> ();
-          
+
           float z = vec.dot (z_axis_);
           threshold *= z * z;
         }
-        
+
         return (ptp_dist < threshold);
       }
 
index 99a7439b9abf77cc60bbbd95873eac830a9ed85d..d68b093e03e3c07ae1b27aef1820729d0a354141 100644 (file)
@@ -40,6 +40,7 @@
 #include <Eigen/Core>
 #include <vector>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
index c61e2f31685f330075ef2e8b41530ef0bd3aeb00..445842c7ca01d242cbc3ce478e75ad6f1358601b 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/search/search.h>
@@ -81,7 +82,7 @@ namespace pcl
       /** \brief This destructor destroys the cloud, normals and search method used for
         * finding KNN. In other words it frees memory.
         */
-      
+
       ~RegionGrowing ();
 
       /** \brief Get the minimum number of points that a cluster needs to contain in order to be considered valid. */
index 03f06656dcec9eec45c9a353108ed9ecdf03c38e..f1799599d6bd6b54079ddab8bf035f82be1f0736 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/segmentation/region_growing.h>
 
index 754f7af64944f2927b29f6a3fbb837710f13bc41..2add3f735e0a70307f22230d18355fd5c0c8dcb0 100644 (file)
@@ -358,7 +358,7 @@ namespace pcl
 
       /** \brief Provide a pointer to the input dataset that contains the point normals of 
         * the XYZ dataset.
-        * \param[in] normals the const boost shared pointer to a PointCloud message
+        * \param[in] normals the const shared pointer to a PointCloud message
         */
       inline void 
       setInputNormals (const PointCloudNConstPtr &normals) { normals_ = normals; }
index ecd181b84a7a840da8a80359b0c0c963780fca88..2428a61d5dcc89033cac3c76318819c5ea45484b 100755 (executable)
@@ -60,7 +60,7 @@ namespace pcl
       pcl::PointCloud<PointT> &output);
 
   template <typename PointT>
-  PCL_DEPRECATED("tgt parameter is not used; it is deprecated and will be removed in future releases")
+  PCL_DEPRECATED(1, 12, "tgt parameter is not used; it is deprecated and will be removed in future releases")
   inline void getPointCloudDifference (
       const pcl::PointCloud<PointT> &src,
       const pcl::PointCloud<PointT> & /* tgt */,
index 5ce354c1cb20a5d474062f3777510d96b0ea3aed..1c43f406809490584b645540df8be7ec107793f9 100644 (file)
@@ -43,6 +43,7 @@
 #include <boost/version.hpp>
 
 #include <pcl/features/normal_3d.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
@@ -69,7 +70,7 @@ namespace pcl
       Supervoxel () :
         voxels_ (new pcl::PointCloud<PointT> ()),
         normals_ (new pcl::PointCloud<Normal> ())
-        {  } 
+        {  }
 
       using Ptr = shared_ptr<Supervoxel<PointT> >;
       using ConstPtr = shared_ptr<const Supervoxel<PointT> >;
@@ -194,7 +195,7 @@ namespace pcl
        */
       SupervoxelClustering (float voxel_resolution, float seed_resolution);
 
-      PCL_DEPRECATED("constructor with flag for using the single camera transform is deprecated. Default behavior is now to use the transform for organized clouds, and not use it for unorganized. Use setUseSingleCameraTransform() to override the defaults.")
+      PCL_DEPRECATED(1, 12, "constructor with flag for using the single camera transform is deprecated. Default behavior is now to use the transform for organized clouds, and not use it for unorganized. Use setUseSingleCameraTransform() to override the defaults.")
       SupervoxelClustering (float voxel_resolution, float seed_resolution, bool) : SupervoxelClustering (voxel_resolution, seed_resolution) { }
 
       /** \brief This destructor destroys the cloud, normals and search method used for
@@ -278,10 +279,10 @@ namespace pcl
         * color(it's random). Points that are unlabeled will be black
         * \note This will expand the label_colors_ vector so that it can accommodate all labels
         */
-      PCL_DEPRECATED("use getLabeledCloud() instead. An example of how to display and save with colorized labels can be found in examples/segmentation/example_supervoxels.cpp")
+      PCL_DEPRECATED(1, 12, "use getLabeledCloud() instead. An example of how to display and save with colorized labels can be found in examples/segmentation/example_supervoxels.cpp")
       typename pcl::PointCloud<PointXYZRGBA>::Ptr
       getColoredCloud () const
-      { 
+      {
         return pcl::PointCloud<PointXYZRGBA>::Ptr (new pcl::PointCloud<PointXYZRGBA>);
       }
 
index 2aa4bf438696b6f83dedbdb8f3c6a8be51d6d366..25086923ebbfc82ca24750cd862d455ab2f97824 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
index e9c854bdbf1d59bdcd300d624d3e4eea80a055f4..c680219c06cf5c299c3933a1eb017d63fab9704e 100644 (file)
@@ -1,10 +1,10 @@
 #pragma once
 
+#include <pcl/memory.h>
+#include <pcl/pcl_macros.h>
+
 #include <Eigen/Dense>
 #include <Eigen/StdVector>
-#include <boost/shared_ptr.hpp>
-
-#include <pcl/pcl_macros.h>
 
 namespace pcl {
 namespace simulation {
@@ -138,7 +138,7 @@ public:
 
   // Return the pose of the camera:
   Eigen::Vector3d
-  getYPR()
+  getYPR() const
   {
     return Eigen::Vector3d(yaw_, pitch_, roll_);
   }
index ea334c2fa1dbb048c2614641f4c3d3a1497c521c..655db3ced1e743a9633cd56ba5f2a01c5fe130d6 100644 (file)
@@ -7,11 +7,12 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_exports.h>
 
 #include <Eigen/Core>
+
 #include <GL/glew.h>
-#include <pcl/make_shared.h>
 
 namespace pcl {
 namespace simulation {
@@ -39,7 +40,7 @@ public:
 
   /** Add a new shader object to the program.  */
   bool
-  addShaderText(const std::string& text, ShaderType shader_type);
+  addShaderText(const std::string& text, ShaderType shader_type) const;
 
   /** Add a new shader object to the program.  */
   bool
@@ -47,7 +48,7 @@ public:
 
   /** Link the program.  */
   bool
-  link();
+  link() const;
 
   /** Return true if the program is linked.  */
   bool
@@ -55,7 +56,7 @@ public:
 
   /** Use the program.  */
   void
-  use();
+  use() const;
 
   // Set uniforms
   void
@@ -86,7 +87,7 @@ public:
   setUniform(const std::string& name, bool v);
 
   int
-  getUniformLocation(const std::string& name);
+  getUniformLocation(const std::string& name) const;
 
   void
   printActiveUniforms();
@@ -94,7 +95,7 @@ public:
   printActiveAttribs();
 
   GLuint
-  programId()
+  programId() const
   {
     return program_id_;
   }
index 5128d8d1da0e63ca064d6f76fbfe211fcec3adc4..8b592f941265c0d1c6ddb8981887ddb0f04f96d3 100644 (file)
@@ -1,5 +1,13 @@
 #pragma once
 
+#include <pcl/io/pcd_io.h>
+#include <pcl/simulation/glsl_shader.h>
+#include <pcl/PolygonMesh.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_config.h>
+#include <pcl/pcl_macros.h>
+#include <pcl/point_types.h>
+
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
 #define WIN32_LEAN_AND_MEAN 1
 #include <windows.h>
@@ -7,7 +15,6 @@
 
 #include <GL/glew.h>
 
-#include <pcl/pcl_config.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
 #include <GL/glu.h>
 #endif
 
-#include <boost/shared_ptr.hpp>
-#include <pcl/PolygonMesh.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/pcl_macros.h>
-#include <pcl/point_types.h>
-#include <pcl/simulation/glsl_shader.h>
-
 namespace pcl {
 namespace simulation {
 
@@ -161,7 +161,7 @@ public:
 
   /** Render the quad. */
   void
-  render();
+  render() const;
 
 private:
   GLuint quad_vbo_;
@@ -176,7 +176,7 @@ public:
   ~TexturedQuad();
 
   void
-  setTexture(const std::uint8_t* data);
+  setTexture(const std::uint8_t* data) const;
 
   void
   render();
index 6539924d9dd17bbd7c1d24ae955da8abc5396b25..6b0d7e6e8c20efffbd0046d78931346a19b16d1f 100644 (file)
@@ -1,8 +1,18 @@
 #pragma once
 
-#include <GL/glew.h>
-
+#include <pcl/common/transforms.h>
+#include <pcl/range_image/range_image_planar.h>
+#include <pcl/simulation/camera.h>
+#include <pcl/simulation/glsl_shader.h>
+#include <pcl/simulation/scene.h>
+#include <pcl/simulation/sum_reduce.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_config.h>
+#include <pcl/pcl_macros.h>
+
+#include <Eigen/StdVector>
+
+#include <GL/glew.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
 #include <GL/glu.h>
 #endif
 
-//#include <math.h>
-#include <Eigen/StdVector>
-
-#include <pcl/pcl_macros.h>
-//#include <pcl/win32_macros.h>
-#include <pcl/common/transforms.h>
-#include <pcl/range_image/range_image_planar.h>
-#include <pcl/simulation/camera.h>
-#include <pcl/simulation/glsl_shader.h>
-#include <pcl/simulation/scene.h>
-#include <pcl/simulation/sum_reduce.h>
-
 namespace pcl {
 namespace simulation {
+
 class PCL_EXPORTS RangeLikelihood {
 public:
   using Ptr = shared_ptr<RangeLikelihood>;
@@ -252,7 +251,7 @@ private:
   applyCameraTransform(const Camera& camera);
 
   void
-  setupProjectionMatrix();
+  setupProjectionMatrix() const;
 
   Scene::Ptr scene_;
   int rows_;
index 287f8792d648aa75fe29bb48f61a5dda9dfc0993..9fd7ad408f2d051a0647c3253e9d0fc8a4491ada 100644 (file)
@@ -7,11 +7,9 @@
 
 #pragma once
 
-#include <boost/shared_ptr.hpp>
-
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 //#include <pcl/win32_macros.h>
-
 #include <pcl/simulation/camera.h>
 #include <pcl/simulation/model.h>
 
index 4424c92518f42d49186be0f1a6fed7962899e2dd..098ecd052a4a8e17b8616e43f67256f36d906de4 100644 (file)
@@ -7,18 +7,17 @@
 
 #pragma once
 
-#include <GL/glew.h>
-
+#include <pcl/simulation/glsl_shader.h>
+#include <pcl/simulation/model.h>
 #include <pcl/pcl_config.h>
+
+#include <GL/glew.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #else
 #include <GL/gl.h>
 #endif
 
-#include <pcl/simulation/glsl_shader.h>
-#include <pcl/simulation/model.h>
-
 namespace pcl {
 namespace simulation {
 
index f0244281e07ae5f7c310c52a0d751e060b805d2b..1e343c060e16383ecccd5d725eb220e81a5ad654 100644 (file)
@@ -1,6 +1,7 @@
-#include <iostream>
 #include <pcl/simulation/camera.h>
 
+#include <iostream>
+
 using namespace Eigen;
 using namespace pcl::simulation;
 
index 18cd8b0473743c18526771aff5f28a86bed02c57..3eb2c20b5db00366b9796844c4beb2c96b99967b 100644 (file)
@@ -5,9 +5,10 @@
  *      Author: hordurj
  */
 
+#include <pcl/simulation/glsl_shader.h>
+
 #include <fstream>
 #include <iostream>
-#include <pcl/simulation/glsl_shader.h>
 
 using namespace pcl::simulation::gllib;
 
@@ -35,7 +36,7 @@ pcl::simulation::gllib::Program::Program() { program_id_ = glCreateProgram(); }
 pcl::simulation::gllib::Program::~Program() {}
 
 int
-pcl::simulation::gllib::Program::getUniformLocation(const std::string& name)
+pcl::simulation::gllib::Program::getUniformLocation(const std::string& name) const
 {
   return glGetUniformLocation(program_id_, name.c_str());
 }
@@ -103,7 +104,7 @@ pcl::simulation::gllib::Program::setUniform(const std::string& name, bool v)
 
 bool
 pcl::simulation::gllib::Program::addShaderText(const std::string& text,
-                                               ShaderType shader_type)
+                                               ShaderType shader_type) const
 {
   GLuint id;
   GLint compile_status;
@@ -139,7 +140,7 @@ pcl::simulation::gllib::Program::addShaderFile(const std::string& filename,
 }
 
 bool
-pcl::simulation::gllib::Program::link()
+pcl::simulation::gllib::Program::link() const
 {
   glLinkProgram(program_id_);
   printProgramInfoLog(program_id_);
@@ -148,7 +149,7 @@ pcl::simulation::gllib::Program::link()
 }
 
 void
-pcl::simulation::gllib::Program::use()
+pcl::simulation::gllib::Program::use() const
 {
   glUseProgram(program_id_);
 }
index 165f0b35a5988b13f91476f145019ac139418882..a154d6ce4cd59bae60294900ed469a0927a7f1be 100644 (file)
@@ -271,7 +271,7 @@ pcl::simulation::Quad::Quad()
 pcl::simulation::Quad::~Quad() { glDeleteBuffers(1, &quad_vbo_); }
 
 void
-pcl::simulation::Quad::render()
+pcl::simulation::Quad::render() const
 {
   glBindBuffer(GL_ARRAY_BUFFER, quad_vbo_);
   glEnableVertexAttribArray(0);
@@ -313,7 +313,7 @@ pcl::simulation::TexturedQuad::TexturedQuad(int width, int height)
 pcl::simulation::TexturedQuad::~TexturedQuad() { glDeleteTextures(1, &texture_); }
 
 void
-pcl::simulation::TexturedQuad::setTexture(const std::uint8_t* data)
+pcl::simulation::TexturedQuad::setTexture(const std::uint8_t* data) const
 {
   glBindTexture(GL_TEXTURE_2D, texture_);
   glTexImage2D(
index d722655d6c55f45eba3968d8f3efea577f8cf20f..01d42ec9f1bcd51ef8d3c9b7ae20aea0f0228478 100644 (file)
@@ -1,11 +1,10 @@
-#include <ctime>
-#include <random>
+#include <pcl/common/time.h>
+#include <pcl/simulation/range_likelihood.h>
+#include <pcl/pcl_config.h>
 
 #include <boost/math/distributions/normal.hpp>
 
 #include <GL/glew.h>
-
-#include <pcl/pcl_config.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
@@ -14,8 +13,8 @@
 #include <GL/glu.h>
 #endif
 
-#include <pcl/common/time.h>
-#include <pcl/simulation/range_likelihood.h>
+#include <ctime>
+#include <random>
 
 // For adding noise:
 static std::minstd_rand rng(std::random_device{}());
@@ -512,7 +511,7 @@ pcl::simulation::RangeLikelihood::sampleNormal(double sigma)
 }
 
 void
-pcl::simulation::RangeLikelihood::setupProjectionMatrix()
+pcl::simulation::RangeLikelihood::setupProjectionMatrix() const
 {
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
index cd98bb8ba5f7fc166373ed64f938622d6c64d716..74ab0de33730e36963f2dc8da1e02d8f724158c2 100644 (file)
  * pcl_sim_terminal_demo 2 ../../../../kmcl/models/table_models/meta_model.ply
  */
 
+#include <pcl/memory.h>
+
 #include <Eigen/Dense>
-#include <boost/shared_ptr.hpp>
+
+#include "simulation_io.hpp"
+
 #include <cmath>
 #include <iostream>
 #ifdef _WIN32
@@ -19,8 +23,6 @@
 #include <windows.h>
 #endif
 
-#include "simulation_io.hpp"
-
 using namespace Eigen;
 using namespace pcl;
 using namespace pcl::console;
index 5e8ab6d65dede8ee835182a4a91de8a07696ca2c..c756c9b7c59764b892e7ec3a29560b30463260be 100644 (file)
@@ -5,17 +5,27 @@
  *
  */
 
+#include <pcl/common/common.h>
+#include <pcl/common/transforms.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/console/time.h>
+#include <pcl/features/normal_3d.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/io/vtk_lib_io.h>
+#include <pcl/simulation/camera.h>
+#include <pcl/simulation/model.h>
+#include <pcl/simulation/range_likelihood.h>
+#include <pcl/simulation/scene.h>
+#include <pcl/surface/gp3.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_config.h>
+#include <pcl/point_types.h>
+
 #include <Eigen/Dense>
-#include <boost/shared_ptr.hpp>
-#include <cmath>
-#include <iostream>
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
+
 #include <GL/glew.h>
 
-#include <pcl/pcl_config.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
 #include <GL/glut.h>
 #endif
 
-#include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-
-#include <pcl/common/common.h>
-#include <pcl/common/transforms.h>
-
-#include <pcl/features/normal_3d.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/surface/gp3.h>
-
-// define the following in order to eliminate the deprecated headers warning
-#define VTK_EXCLUDE_STRSTREAM_HEADERS
-#include <pcl/io/vtk_lib_io.h>
-
-#include <pcl/simulation/camera.h>
-#include <pcl/simulation/model.h>
-#include <pcl/simulation/range_likelihood.h>
-#include <pcl/simulation/scene.h>
-
-#include <pcl/console/parse.h>
-#include <pcl/console/print.h>
-#include <pcl/console/time.h>
+#include <cmath>
+#include <iostream>
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
 
 using namespace Eigen;
 using namespace pcl;
index 47388cf5899c08e0878da8b2e988046586093c13..6c7c43276374de26bd9872f1506b84d936410a98 100644 (file)
  *
  */
 
+#include <pcl/common/common.h>
+#include <pcl/common/transforms.h>
+#include <pcl/console/parse.h>
+#include <pcl/console/print.h>
+#include <pcl/features/normal_3d.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/io/vtk_lib_io.h>
+#include <pcl/range_image/range_image_planar.h> // RangeImage
+#include <pcl/simulation/camera.h>
+#include <pcl/simulation/model.h>
+#include <pcl/simulation/range_likelihood.h>
+#include <pcl/simulation/scene.h>
+#include <pcl/surface/gp3.h>
+#include <pcl/visualization/cloud_viewer.h> // Pop-up viewer
+#include <pcl/memory.h>
+#include <pcl/pcl_config.h>
+#include <pcl/point_types.h>
+
 #include <Eigen/Dense>
-#include <boost/shared_ptr.hpp>
-#include <cmath>
-#include <iostream>
-#include <thread>
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
+
 #include <GL/glew.h>
 
-#include <pcl/pcl_config.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
 #include <GL/glut.h>
 #endif
 
-#include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-
-#include "pcl/common/common.h"
-#include "pcl/common/transforms.h"
-
-#include <pcl/features/normal_3d.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/surface/gp3.h>
-
-// define the following in order to eliminate the deprecated headers warning
-#define VTK_EXCLUDE_STRSTREAM_HEADERS
-#include <pcl/io/vtk_lib_io.h>
-
-#include "pcl/simulation/camera.h"
-#include "pcl/simulation/model.h"
-#include "pcl/simulation/range_likelihood.h"
-#include "pcl/simulation/scene.h"
-
-#include <pcl/console/parse.h>
-#include <pcl/console/print.h>
-
-// RangeImage:
-#include <pcl/range_image/range_image_planar.h>
-
-// Pop-up viewer
-#include <pcl/visualization/cloud_viewer.h>
+#include <cmath>
+#include <iostream>
+#include <thread>
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
 
 using namespace Eigen;
 using namespace pcl;
index 02186372f1251588ef2be65178aa7a232395155c..a0e30f38e39bb79352081d3a0c7e83ea44380955 100644 (file)
  * $Id: pcd_viewer.cpp 5094 2012-03-15 01:03:51Z rusu $
  *
  */
-#include <Eigen/Dense>
-#include <Eigen/Geometry>
-#include <boost/shared_ptr.hpp>
-#include <cmath>
-#include <iostream>
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
 
-#include <GL/glew.h>
-
-#include <pcl/pcl_config.h>
-#ifdef OPENGL_IS_A_FRAMEWORK
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
-
-#include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-
-#include "pcl/common/common.h"
-#include "pcl/common/transforms.h"
-
-#include <pcl/features/normal_3d.h>
-#include <pcl/io/pcd_io.h>
-#include <pcl/point_types.h>
-#include <pcl/surface/gp3.h>
-
-// define the following in order to eliminate the deprecated headers warning
-#define VTK_EXCLUDE_STRSTREAM_HEADERS
-#include <pcl/io/vtk_lib_io.h>
-
-#include "pcl/simulation/camera.h"
-#include "pcl/simulation/model.h"
-#include "pcl/simulation/range_likelihood.h"
-#include "pcl/simulation/scene.h"
-
-#include <pcl/console/parse.h>
-#include <pcl/console/print.h>
-#include <pcl/console/time.h>
-
-// RangeImage:
-#include <pcl/range_image/range_image_planar.h>
-
-// Pop-up viewer
-#include <pcl/visualization/cloud_viewer.h>
-
-#include <cfloat>
 #include <pcl/common/common.h>
+#include <pcl/common/transforms.h>
 #include <pcl/console/parse.h>
 #include <pcl/console/print.h>
 #include <pcl/console/time.h>
+#include <pcl/features/normal_3d.h>
 #include <pcl/io/pcd_io.h>
+#include <pcl/io/vtk_lib_io.h>
+#include <pcl/range_image/range_image_planar.h> // RangeImage
+#include <pcl/simulation/camera.h>
+#include <pcl/simulation/model.h>
+#include <pcl/simulation/range_likelihood.h>
+#include <pcl/simulation/scene.h>
+#include <pcl/surface/gp3.h>
+#include <pcl/visualization/cloud_viewer.h> // Pop-up viewer
 #include <pcl/visualization/histogram_visualizer.h>
 #include <pcl/visualization/keyboard_event.h>
 #include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/point_cloud_handlers.h>
 #include <pcl/visualization/point_picking_event.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_config.h>
+#include <pcl/point_types.h>
+
+#include <Eigen/Dense>
+#include <Eigen/Geometry>
+
 #include <vtkPolyDataReader.h>
 
+#include <GL/glew.h>
+
+#ifdef OPENGL_IS_A_FRAMEWORK
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
+
+#include <cfloat>
+#include <cmath>
+#include <iostream>
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
 using namespace Eigen;
 using namespace pcl;
 using namespace pcl::console;
index 5bf95b3ad017018a833dae9ba1fe79856cae91cd..15c85740d114cb5383bc4f43bd0cd2815897d238 100644 (file)
@@ -1,4 +1,5 @@
 #include "simulation_io.hpp"
+
 #include <pcl/io/png_io.h>
 
 pcl::simulation::SimExample::SimExample(int argc, char** argv, int height, int width)
index 3ecc6bdd53ce70d0fac2f4b2fc163ea63dff577a..c74e22116eccc862040f02209a3619f656403450 100644 (file)
@@ -1,10 +1,16 @@
 #pragma once
 
-#include <boost/shared_ptr.hpp>
+#include <pcl/io/pcd_io.h>
+#include <pcl/io/vtk_lib_io.h>
+#include <pcl/simulation/camera.h>
+#include <pcl/simulation/range_likelihood.h>
+#include <pcl/simulation/scene.h>
+#include <pcl/memory.h>
+#include <pcl/pcl_config.h>
+#include <pcl/point_types.h>
 
 #include <GL/glew.h>
 
-#include <pcl/pcl_config.h>
 #ifdef OPENGL_IS_A_FRAMEWORK
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
 #include <GL/glut.h>
 #endif
 
-// define the following in order to eliminate the deprecated headers warning
-#define VTK_EXCLUDE_STRSTREAM_HEADERS
-#include <pcl/io/pcd_io.h>
-#include <pcl/io/vtk_lib_io.h>
-#include <pcl/point_types.h>
-
-#include <pcl/simulation/camera.h>
-#include <pcl/simulation/range_likelihood.h>
-#include <pcl/simulation/scene.h>
-
 namespace pcl {
 namespace simulation {
 
index bf3d3975f275c2226ba831ceb972ab738bab34a0..21f7824fc0b5674e2186b3f5d7e9975183e9eb0a 100644 (file)
@@ -36,8 +36,8 @@
 
 #pragma once
 
-#include <pcl/point_types.h>
 #include <pcl/stereo/disparity_map_converter.h>
+#include <pcl/point_types.h>
 
 namespace pcl {
 
index a25e9eb3f7e9ded6cbe6e2c87e73d68229b90e2e..0fb59953241d0f84293b859649c03b3a8ee30d63 100644 (file)
 
 #pragma once
 
-#include <cstring>
-#include <vector>
-
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
 
+#include <cstring>
+#include <vector>
+
 namespace pcl {
 
 /** \brief Compute point cloud from the disparity map.
index b9e3af6425e18c881bb0a32ccb69869dfac20449..d0e72fd844cceca966bc4e292b151047aa487c12 100644 (file)
 #ifndef PCL_DISPARITY_MAP_CONVERTER_IMPL_H_
 #define PCL_DISPARITY_MAP_CONVERTER_IMPL_H_
 
+#include <pcl/common/intensity.h>
+#include <pcl/console/print.h>
 #include <pcl/stereo/disparity_map_converter.h>
+#include <pcl/point_types.h>
 
 #include <fstream>
 #include <limits>
 
-#include <pcl/common/intensity.h>
-#include <pcl/console/print.h>
-#include <pcl/point_types.h>
-
 template <typename PointT>
 pcl::DisparityMapConverter<PointT>::DisparityMapConverter()
 : center_x_(0.0f)
index 02263d9882e79dcb8da3f2e4fe3a9d9f24329fd7..dcad8bd6670734830ede443f5efa4e18e359a157 100644 (file)
 #pragma once
 
 #include <pcl/common/time_trigger.h>
-#include <pcl/conversions.h>
 #include <pcl/io/grabber.h>
-#include <pcl/point_cloud.h>
 #include <pcl/stereo/stereo_matching.h>
+#include <pcl/conversions.h>
+#include <pcl/point_cloud.h>
 
 namespace pcl {
 
@@ -72,21 +72,6 @@ public:
                     float frames_per_second,
                     bool repeat);
 
-  /** \brief Copy constructor.
-   * \param[in] src the Stereo Grabber base object to copy into this
-   */
-  StereoGrabberBase(const StereoGrabberBase& src) : impl_() { *this = src; }
-
-  /** \brief Copy operator.
-   * \param[in] src the Stereo Grabber base object to copy into this
-   */
-  StereoGrabberBase&
-  operator=(const StereoGrabberBase& src)
-  {
-    impl_ = src.impl_;
-    return (*this);
-  }
-
   /** \brief Virtual destructor. */
   ~StereoGrabberBase() noexcept;
 
index 20d85ae8d36bc0f63511876959c218eaa6ba0850..117d304f8e4914e1652d48f69592615ff3613205 100644 (file)
 
 #pragma once
 
-#include <algorithm>
-
 #include <pcl/conversions.h>
 #include <pcl/point_types.h>
 
+#include <algorithm>
+
 namespace pcl {
 template <class T>
 short int
index 088ae62ef4e2abc73f057b6b012ffa044b18a17a..3efcb00b28ca44c5888c7393de8eb37892a1aefe 100644 (file)
  *  POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <pcl/stereo/digital_elevation_map.h>
-
 #include <pcl/common/feature_histogram.h>
 #include <pcl/console/print.h>
+#include <pcl/stereo/digital_elevation_map.h>
 
 pcl::DigitalElevationMapBuilder::DigitalElevationMapBuilder()
 : resolution_column_(64), resolution_disparity_(32), min_points_in_cell_(1)
index 1729a72e33da93ed54330f2a79e2cb098143500d..45f5eed63a1c3fe392b25b6e2737d4d5c275bea1 100644 (file)
@@ -35,9 +35,9 @@
  *
  */
 
+#include <pcl/stereo/stereo_grabber.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
-#include <pcl/stereo/stereo_grabber.h>
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////// GrabberImplementation //////////////////////
index a70eedb6fa07e8d6e979a9033aa9ec199254b0d2..e5e4231138909a9bdf74a01cb6e4a37dc14d7794 100644 (file)
@@ -82,6 +82,7 @@ set(POISSON_INCLUDES
 )
 
 set(POISSON_SOURCES
+  src/3rdparty/poisson4/bspline_data.cpp
   src/3rdparty/poisson4/factor.cpp
   src/3rdparty/poisson4/geometry.cpp
   src/3rdparty/poisson4/marching_cubes_poisson.cpp
index cfc372c2f9265a50031a30614770e96e3e54e0d6..441ad59d3a06ce04b7fe10467ab97b2a76468b4a 100644 (file)
@@ -466,15 +466,15 @@ void ON_SimpleArray<T>::Append( int count, const T* p )
 template <class T>
 void ON_SimpleArray<T>::Insert( int i, const T& x ) 
 {
-  if( i >= 0 && i <= m_count ) 
+  if( i >= 0 && i <= m_count )
   {
-    if ( m_count == m_capacity ) 
+    if ( m_count == m_capacity )
     {
       int newcapacity = NewCapacity();
       Reserve( newcapacity );
     }
          m_count++;
-    Move( i+1, i, m_count-1-i );
+    Move( i+1, i, static_cast<unsigned int>(m_count)-1-i );
          m_a[i] = x;
   }
 }
@@ -1372,7 +1372,7 @@ void ON_ClassArray<T>::Insert( int i, const T& x )
     DestroyElement( m_a[m_count] );
          m_count++;
     if ( i < m_count-1 ) {
-      Move( i+1, i, m_count-1-i );
+      Move( i+1, i, static_cast<unsigned int>(m_count)-1-i );
       // This call to memset is ok even when T has a vtable
       // because in-place construction is used later.
       memset( (void*)(&m_a[i]), 0, sizeof(T) );
index 80927a0e0e3d852f33a46bc7b9cf1bfa8048733b..9f2b87b85531796678edbdf83c16d7c3b01a0404 100644 (file)
@@ -32,6 +32,9 @@ DAMAGE.
 
 #include "ppolynomial.h"
 
+#include <cstdio>
+#include <cstring>
+
 namespace pcl
 {
   namespace poisson
index 85c0d60e2b7361fd66b3497e159fa85754696b00..49861aa88c4e5806624d6c36204c85bce96d0868 100644 (file)
@@ -27,6 +27,7 @@ DAMAGE.
 */
 
 #include "poisson_exceptions.h"
+#include "binary_node.h"
 
 namespace pcl
 {
@@ -95,15 +96,15 @@ namespace pcl
     {
       if( functionCount )
       {
-        if( vvDotTable ) delete[] vvDotTable;
-        if( dvDotTable ) delete[] dvDotTable;
-        if( ddDotTable ) delete[] ddDotTable;
+        delete[] vvDotTable;
+        delete[] dvDotTable;
+        delete[] ddDotTable;
 
-        if(  valueTables ) delete[]  valueTables;
-        if( dValueTables ) delete[] dValueTables;
+        delete[]  valueTables;
+        delete[] dValueTables;
         
-        if( baseFunctions ) delete[] baseFunctions;
-        if(  baseBSplines ) delete[]  baseBSplines;
+        delete[] baseFunctions;
+        delete[]  baseBSplines;
       }
       vvDotTable = dvDotTable = ddDotTable = NULL;
       valueTables = dValueTables=NULL;
@@ -292,9 +293,11 @@ namespace pcl
     template<int Degree,class Real>
     void BSplineData<Degree,Real>::clearDotTables( int flags )
     {
-      if( (flags & VV_DOT_FLAG) && vvDotTable ) delete[] vvDotTable , vvDotTable = NULL;
-      if( (flags & DV_DOT_FLAG) && dvDotTable ) delete[] dvDotTable , dvDotTable = NULL;
-      if( (flags & DD_DOT_FLAG) && ddDotTable ) delete[] ddDotTable , ddDotTable = NULL;
+      if (flags & VV_DOT_FLAG) {
+        delete[] vvDotTable ; vvDotTable = NULL;
+        delete[] dvDotTable ; dvDotTable = NULL;
+        delete[] ddDotTable ; ddDotTable = NULL;
+      }
     }
     template< int Degree , class Real >
     void BSplineData< Degree , Real >::setSampleSpan( int idx , int& start , int& end , double smooth ) const
@@ -367,8 +370,8 @@ namespace pcl
 
     template<int Degree,class Real>
     void BSplineData<Degree,Real>::clearValueTables(void){
-      if( valueTables){delete[]  valueTables;}
-      if(dValueTables){delete[] dValueTables;}
+      delete[]  valueTables;
+      delete[] dValueTables;
       valueTables=dValueTables=NULL;
     }
 
@@ -447,60 +450,10 @@ namespace pcl
       POISSON_THROW_EXCEPTION (pcl::poisson::PoissonBadArgumentException, "B-spline up-sampling not supported for degree " << Degree);
     }
     template<>
-    void BSplineElements< 1 >::upSample( BSplineElements< 1 >& high ) const
-    {
-      high.resize( size()*2 );
-      high.assign( high.size() , BSplineElementCoefficients<1>() );
-      for( int i=0 ; i<int(size()) ; i++ )
-      {
-        high[2*i+0][0] += 1 * (*this)[i][0];
-        high[2*i+0][1] += 0 * (*this)[i][0];
-        high[2*i+1][0] += 2 * (*this)[i][0];
-        high[2*i+1][1] += 1 * (*this)[i][0];
+    void BSplineElements< 1 >::upSample( BSplineElements< 1 >& high ) const;
 
-        high[2*i+0][0] += 1 * (*this)[i][1];
-        high[2*i+0][1] += 2 * (*this)[i][1];
-        high[2*i+1][0] += 0 * (*this)[i][1];
-        high[2*i+1][1] += 1 * (*this)[i][1];
-      }
-      high.denominator = denominator * 2;
-    }
     template<>
-    void BSplineElements< 2 >::upSample( BSplineElements< 2 >& high ) const
-    {
-      //    /----\
-      //   /      \
-      //  /        \  = 1  /--\       +3    /--\     +3      /--\   +1        /--\
-      // /          \     /    \           /    \           /    \           /    \
-      // |----------|     |----------|   |----------|   |----------|   |----------|
-
-      high.resize( size()*2 );
-      high.assign( high.size() , BSplineElementCoefficients<2>() );
-      for( int i=0 ; i<int(size()) ; i++ )
-      {
-        high[2*i+0][0] += 1 * (*this)[i][0];
-        high[2*i+0][1] += 0 * (*this)[i][0];
-        high[2*i+0][2] += 0 * (*this)[i][0];
-        high[2*i+1][0] += 3 * (*this)[i][0];
-        high[2*i+1][1] += 1 * (*this)[i][0];
-        high[2*i+1][2] += 0 * (*this)[i][0];
-
-        high[2*i+0][0] += 3 * (*this)[i][1];
-        high[2*i+0][1] += 3 * (*this)[i][1];
-        high[2*i+0][2] += 1 * (*this)[i][1];
-        high[2*i+1][0] += 1 * (*this)[i][1];
-        high[2*i+1][1] += 3 * (*this)[i][1];
-        high[2*i+1][2] += 3 * (*this)[i][1];
-
-        high[2*i+0][0] += 0 * (*this)[i][2];
-        high[2*i+0][1] += 1 * (*this)[i][2];
-        high[2*i+0][2] += 3 * (*this)[i][2];
-        high[2*i+1][0] += 0 * (*this)[i][2];
-        high[2*i+1][1] += 0 * (*this)[i][2];
-        high[2*i+1][2] += 1 * (*this)[i][2];
-      }
-      high.denominator = denominator * 4;
-    }
+    void BSplineElements< 2 >::upSample( BSplineElements< 2 >& high ) const;
 
     template< int Degree >
     void BSplineElements< Degree >::differentiate( BSplineElements< Degree-1 >& d ) const
index 8fa4cdc37ec2cb9cb8d2a4211604faab4a135ea6..9378b246532ee25fd12af3a2bc9cb0eb995e9d0a 100644 (file)
@@ -48,11 +48,11 @@ namespace pcl
     {
       if(res)
       {
-        if(  dotTable) delete[]   dotTable;
-        if( dDotTable) delete[]  dDotTable;
-        if(d2DotTable) delete[] d2DotTable;
-        if( valueTables) delete[]  valueTables;
-        if(dValueTables) delete[] dValueTables;
+        delete[]   dotTable;
+        delete[]  dDotTable;
+        delete[] d2DotTable;
+        delete[]  valueTables;
+        delete[] dValueTables;
       }
       dotTable=dDotTable=d2DotTable=NULL;
       valueTables=dValueTables=NULL;
@@ -224,18 +224,12 @@ namespace pcl
     template<int Degree,class Real>
     void FunctionData<Degree,Real>::clearDotTables( const int& flags )
     {
-      if((flags & DOT_FLAG) && dotTable)
+      if (flags & DOT_FLAG)
       {
         delete[] dotTable;
         dotTable=NULL;
-      }
-      if((flags & D_DOT_FLAG) && dDotTable)
-      {
         delete[] dDotTable;
         dDotTable=NULL;
-      }
-      if((flags & D2_DOT_FLAG) && d2DotTable)
-      {
         delete[] d2DotTable;
         d2DotTable=NULL;
       }
@@ -292,8 +286,8 @@ namespace pcl
 
     template<int Degree,class Real>
     void FunctionData<Degree,Real>::clearValueTables(void){
-      if( valueTables){delete[]  valueTables;}
-      if(dValueTables){delete[] dValueTables;}
+      delete[]  valueTables;
+      delete[] dValueTables;
       valueTables=dValueTables=NULL;
     }
 
index 9dfa26072653de53492254128a08d486bf4d11fb..bc3b0a80c5a8cf108ea4e07ab8a3ef59ce603422 100644 (file)
@@ -8,14 +8,14 @@ are permitted provided that the following conditions are met:
 Redistributions of source code must retain the above copyright notice, this list of
 conditions and the following disclaimer. Redistributions in binary form must reproduce
 the above copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the distribution. 
+in the documentation and/or other materials provided with the distribution.
 
 Neither the name of the Johns Hopkins University nor the names of its contributors
 may be used to endorse or promote products derived from this software without specific
-prior written permission. 
+prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
@@ -32,8 +32,6 @@ namespace pcl
 {
   namespace poisson
   {
-
-
     template<class Real>
     Real Random(void){return Real(rand())/RAND_MAX;}
 
@@ -78,6 +76,7 @@ namespace pcl
       p.coords[1]=-p1.coords[0]*p2.coords[2]+p1.coords[2]*p2.coords[0];
       p.coords[2]= p1.coords[0]*p2.coords[1]-p1.coords[1]*p2.coords[0];
     }
+
     template<class Real>
     void EdgeCollapse(const Real& edgeRatio,std::vector<TriangleIndex>& triangles,std::vector< Point3D<Real> >& positions,std::vector< Point3D<Real> >* normals){
       int i,j,*remapTable,*pointCount,idx[3];
@@ -173,6 +172,7 @@ namespace pcl
       delete[] pointCount;
       delete[] remapTable;
     }
+
     template<class Real>
     void TriangleCollapse(const Real& edgeRatio,std::vector<TriangleIndex>& triangles,std::vector< Point3D<Real> >& positions,std::vector< Point3D<Real> >* normals){
       int i,j,*remapTable,*pointCount,idx[3];
@@ -306,6 +306,7 @@ namespace pcl
       else                                                                                                     {p3=edges[triangles[tIndex].eIndex[2]].pIndex[1];}
       return 1;
     }
+
     template<class Real>
     double Triangulation<Real>::area(int p1,int p2,int p3){
       Point3D<Real> q1,q2,q;
@@ -316,18 +317,21 @@ namespace pcl
       CrossProduct(q1,q2,q);
       return Length(q);
     }
+
     template<class Real>
     double Triangulation<Real>::area(int tIndex){
       int p1,p2,p3;
       factor(tIndex,p1,p2,p3);
       return area(p1,p2,p3);
     }
+
     template<class Real>
     double Triangulation<Real>::area(void){
       double a=0;
       for(int i=0;i<int(triangles.size());i++){a+=area(i);}
       return a;
     }
+
     template<class Real>
     int Triangulation<Real>::addTriangle(int p1,int p2,int p3){
       int tIdx,eIdx,p[3];
@@ -366,6 +370,7 @@ namespace pcl
       }
       return tIdx;
     }
+
     template<class Real>
     int Triangulation<Real>::flipMinimize(int eIndex){
       double oldArea,newArea;
@@ -426,6 +431,5 @@ namespace pcl
       }
       return 1;
     }
-
   }
 }
index 1a936935b9f480282df2c2a59f72e23844e6d21a..18a6677a759296dc18c0f3acfa5c5543b2414ba5 100644 (file)
@@ -43,10 +43,8 @@ namespace pcl
     template <class Real>
     MinimalAreaTriangulation<Real>::~MinimalAreaTriangulation(void)
     {
-      if(bestTriangulation)
         delete[] bestTriangulation;
       bestTriangulation=NULL;
-      if(midPoint)
         delete[] midPoint;
       midPoint=NULL;
     }
@@ -104,9 +102,7 @@ namespace pcl
         }
         return;
       }
-      if(bestTriangulation)
         delete[] bestTriangulation;
-      if(midPoint)
         delete[] midPoint;
       bestTriangulation=NULL;
       midPoint=NULL;
@@ -123,9 +119,7 @@ namespace pcl
     template <class Real>
     Real MinimalAreaTriangulation<Real>::GetArea(const std::vector<Point3D<Real> >& vertices)
     {
-      if(bestTriangulation)
         delete[] bestTriangulation;
-      if(midPoint)
         delete[] midPoint;
       bestTriangulation=NULL;
       midPoint=NULL;
index ec13a00b0f2aca4cae77b01f5ac0eec85a898849..ebf0ae33516cce0e9c5c54cac53335a5ee8b2824 100644 (file)
@@ -8,14 +8,14 @@ are permitted provided that the following conditions are met:
 Redistributions of source code must retain the above copyright notice, this list of
 conditions and the following disclaimer. Redistributions in binary form must reproduce
 the above copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the distribution. 
+in the documentation and/or other materials provided with the distribution.
 
 Neither the name of the Johns Hopkins University nor the names of its contributors
 may be used to endorse or promote products derived from this software without specific
-prior written permission. 
+prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
@@ -77,16 +77,16 @@ namespace pcl
       maxDepth=0;
     }
     SortedTreeNodes::~SortedTreeNodes(void){
-      if( nodeCount ) delete[] nodeCount;
-      if( treeNodes ) delete[] treeNodes;
+      delete[] nodeCount;
+      delete[] treeNodes;
       nodeCount = NULL;
       treeNodes = NULL;
     }
 
     void SortedTreeNodes::set( TreeOctNode& root )
     {
-      if( nodeCount ) delete[] nodeCount;
-      if( treeNodes ) delete[] treeNodes;
+      delete[] nodeCount;
+      delete[] treeNodes;
       maxDepth = root.maxDepth()+1;
       nodeCount = new int[ maxDepth+1 ];
       treeNodes = new TreeOctNode*[ root.nodes() ];
@@ -1128,6 +1128,7 @@ namespace pcl
     }
     template< int Degree >
     int Octree< Degree >::GetMatrixRowSize( const OctNode< TreeNodeData , Real >::Neighbors5& neighbors5 ) const { return GetMatrixRowSize( neighbors5 , 0 , 5 , 0 , 5 , 0 , 5 ); }
+
     template< int Degree >
     int Octree< Degree >::GetMatrixRowSize( const OctNode< TreeNodeData , Real >::Neighbors5& neighbors5 , int xStart , int xEnd , int yStart , int yEnd , int zStart , int zEnd ) const
     {
@@ -1141,11 +1142,13 @@ namespace pcl
               count++;
       return count;
     }
+
     template< int Degree >
     int Octree< Degree >::SetMatrixRow( const OctNode< TreeNodeData , Real >::Neighbors5& neighbors5 , MatrixEntry< float >* row , int offset , const double stencil[5][5][5] ) const
     {
       return SetMatrixRow( neighbors5 , row , offset , stencil , 0 , 5 , 0 , 5 , 0 , 5 );
     }
+
     template< int Degree >
     int Octree< Degree >::SetMatrixRow( const OctNode< TreeNodeData , Real >::Neighbors5& neighbors5 , MatrixEntry< float >* row , int offset , const double stencil[5][5][5] , int xStart , int xEnd , int yStart , int yEnd , int zStart , int zEnd ) const
     {
@@ -1226,6 +1229,7 @@ namespace pcl
             }
       return count;
     }
+
     template< int Degree >
     void Octree< Degree >::SetDivergenceStencil( int depth , Point3D< double > *stencil , bool scatter ) const
     {
@@ -1284,6 +1288,7 @@ namespace pcl
 #endif // GRADIENT_DOMAIN_SOLUTION
       }
     }
+
     template< int Degree >
     void Octree< Degree >::SetLaplacianStencil( int depth , double stencil[5][5][5] ) const
     {
@@ -1304,6 +1309,7 @@ namespace pcl
         stencil[x][y][z] = GetLaplacian( symIndex );
       }
     }
+
     template< int Degree >
     void Octree< Degree >::SetLaplacianStencils( int depth , Stencil< double , 5 > stencils[2][2][2] ) const
     {
@@ -1328,6 +1334,7 @@ namespace pcl
         }
       }
     }
+
     template< int Degree >
     void Octree< Degree >::SetDivergenceStencils( int depth , Stencil< Point3D< double > ,  5 > stencils[2][2][2] , bool scatter ) const
     {
@@ -1380,6 +1387,7 @@ namespace pcl
         }
       }
     }
+
     template< int Degree >
     void Octree< Degree >::SetEvaluationStencils( int depth , Stencil< double ,  3 > stencil1[8] , Stencil< double , 3 > stencil2[8][8] ) const
     {
@@ -1421,6 +1429,7 @@ namespace pcl
           }
         }
     }
+
     template< int Degree >
     void Octree< Degree >::UpdateCoarserSupportBounds( const TreeOctNode* node , int& startX , int& endX , int& startY , int& endY , int& startZ , int& endZ )
     {
@@ -1497,6 +1506,7 @@ namespace pcl
         UpSampleData( void ) { start = 0 , v[0] = v[1] = 0.; }
         UpSampleData( int s , double v1 , double v2 ) { start = s , v[0] = v1 , v[1] = v2; }
     };
+
     template< int Degree >
     void Octree< Degree >::UpSampleCoarserSolution( int depth , const SortedTreeNodes& sNodes , Vector< Real >& Solution ) const
     {
@@ -1672,6 +1682,7 @@ namespace pcl
         constraints[i] += cSum;
       }
     }
+
     template< int Degree >
     template< class C >
     void Octree< Degree >::UpSample( int depth , const SortedTreeNodes& sNodes , C* coefficients ) const
@@ -1727,6 +1738,7 @@ namespace pcl
         }
       }
     }
+
     template< int Degree >
     void Octree< Degree >::SetCoarserPointValues( int depth , const SortedTreeNodes& sNodes , Real* metSolution )
     {
@@ -1748,6 +1760,7 @@ namespace pcl
         }
       }
     }
+
     template< int Degree >
     Real Octree< Degree >::WeightedCoarserFunctionValue( const OctNode< TreeNodeData , Real >::NeighborKey3& neighborKey , const TreeOctNode* pointNode , Real* metSolution ) const
     {
@@ -1781,6 +1794,7 @@ namespace pcl
       }
       return Real( pointValue * weight );
     }
+
     template<int Degree>
     int Octree<Degree>::GetFixedDepthLaplacian( SparseSymmetricMatrix< Real >& matrix , int depth , const SortedTreeNodes& sNodes , Real* metSolution )
     {
@@ -1825,6 +1839,7 @@ namespace pcl
       }
       return 1;
     }
+
     template<int Degree>
     int Octree<Degree>::GetRestrictedFixedDepthLaplacian( SparseSymmetricMatrix< Real >& matrix,int depth,const int* entries,int entryCount,
                                                           const TreeOctNode* rNode , Real radius ,
@@ -1962,6 +1977,7 @@ namespace pcl
 
       return iter;
     }
+
     template<int Degree>
     int Octree<Degree>::SolveFixedDepthMatrix( int depth , const SortedTreeNodes& sNodes , Real* metSolution , int startingDepth , bool showResidual , int minIters , double accuracy )
     {
@@ -2092,6 +2108,7 @@ namespace pcl
       delete[] asf.adjacencies;
       return tIter;
     }
+
     template<int Degree>
     int Octree<Degree>::HasNormals(TreeOctNode* node,Real epsilon)
     {
@@ -2101,6 +2118,7 @@ namespace pcl
 
       return hasNormals;
     }
+
     template<int Degree>
     void Octree<Degree>::ClipTree( void )
     {
@@ -2114,6 +2132,7 @@ namespace pcl
         }
       MemoryUsage();
     }
+
     template<int Degree>
     void Octree<Degree>::SetLaplacianConstraints( void )
     {
@@ -2312,15 +2331,19 @@ namespace pcl
       delete normals;
       normals = NULL;
     }
+
     template<int Degree>
     void Octree<Degree>::AdjacencyCountFunction::Function(const TreeOctNode* node1,const TreeOctNode* node2){adjacencyCount++;}
+
     template<int Degree>
     void Octree<Degree>::AdjacencySetFunction::Function(const TreeOctNode* node1,const TreeOctNode* node2){adjacencies[adjacencyCount++]=node1->nodeData.nodeIndex;}
+
     template<int Degree>
     void Octree<Degree>::RefineFunction::Function( TreeOctNode* node1 , const TreeOctNode* node2 )
     {
       if( !node1->children && node1->depth()<depth ) node1->initChildren();
     }
+
     template< int Degree >
     void Octree< Degree >::FaceEdgesFunction::Function( const TreeOctNode* node1 , const TreeOctNode* node2 )
     {
@@ -2421,6 +2444,7 @@ namespace pcl
       _sNodes.set( tree );
       MemoryUsage();
     }
+
     template<int Degree>
     void Octree<Degree>::GetMCIsoTriangles( Real isoValue , int subdivideDepth , CoredMeshData* mesh , int fullDepthIso , int nonLinearFit , bool addBarycenter , bool polygonMesh )
     {
@@ -2592,6 +2616,7 @@ namespace pcl
       delete[] coarseRootData.cornerValuesSet  , delete[] coarseRootData.cornerNormalsSet;
       delete rootData.boundaryValues;
     }
+
     template<int Degree>
     Real Octree<Degree>::getCenterValue( const OctNode< TreeNodeData , Real >::ConstNeighborKey3& neighborKey , const TreeOctNode* node){
       int idx[3];
@@ -2634,6 +2659,7 @@ namespace pcl
       }
       return value;
     }
+
     template< int Degree >
     Real Octree< Degree >::getCornerValue( const OctNode< TreeNodeData , Real >::ConstNeighborKey3& neighborKey3 , const TreeOctNode* node , int corner , const Real* metSolution )
     {
@@ -2694,6 +2720,7 @@ namespace pcl
       }
       return Real( value );
     }
+
     template< int Degree >
     Real Octree< Degree >::getCornerValue( const OctNode< TreeNodeData , Real >::ConstNeighborKey3& neighborKey3 , const TreeOctNode* node , int corner , const Real* metSolution , const double stencil1[3][3][3] , const double stencil2[3][3][3] )
     {
@@ -2733,6 +2760,7 @@ namespace pcl
       }
       return Real( value );
     }
+
     template< int Degree >
     Point3D< Real > Octree< Degree >::getCornerNormal( const OctNode< TreeNodeData , Real >::ConstNeighborKey5& neighborKey5 , const TreeOctNode* node , int corner , const Real* metSolution )
     {
@@ -2784,6 +2812,7 @@ namespace pcl
       }
       return normal;
     }
+
     template< int Degree >
     Real Octree<Degree>::GetIsoValue( void )
     {
@@ -2865,7 +2894,6 @@ namespace pcl
       }
     }
 
-
     template<int Degree>
     int Octree<Degree>::InteriorFaceRootCount(const TreeOctNode* node,const int &faceIndex,int maxDepth){
       int c1,c2,e1,e2,dir,off,cnt=0;
@@ -2945,6 +2973,7 @@ namespace pcl
       if(finest->children) return EdgeRootCount(&finest->children[c1],eIndex,maxDepth)+EdgeRootCount(&finest->children[c2],eIndex,maxDepth);
       else return MarchingCubes::HasEdgeRoots(finest->nodeData.mcIndex,eIndex);
     }
+
     template<int Degree>
     int Octree<Degree>::IsBoundaryFace(const TreeOctNode* node,int faceIndex,int subdivideDepth){
       int dir,offset,d,o[3],idx;
@@ -2957,12 +2986,14 @@ namespace pcl
       idx=(int(o[dir])<<1) + (offset<<1);
       return !(idx%(2<<(int(node->d)-subdivideDepth)));
     }
+
     template<int Degree>
     int Octree<Degree>::IsBoundaryEdge(const TreeOctNode* node,int edgeIndex,int subdivideDepth){
       int dir,x,y;
       Cube::FactorEdgeIndex(edgeIndex,dir,x,y);
       return IsBoundaryEdge(node,dir,x,y,subdivideDepth);
     }
+
     template<int Degree>
     int Octree<Degree>::IsBoundaryEdge( const TreeOctNode* node , int dir , int x , int y , int subdivideDepth )
     {
@@ -2990,6 +3021,7 @@ namespace pcl
       mask = 1<<( int(node->d) - subdivideDepth );
       return !(idx1%(mask)) || !(idx2%(mask));
     }
+
     template< int Degree >
     void Octree< Degree >::GetRootSpan( const RootInfo& ri , Point3D< float >& start , Point3D< float >& end )
     {
@@ -3021,6 +3053,7 @@ namespace pcl
         break;
       }
     }
+
     //////////////////////////////////////////////////////////////////////////////////////
     // The assumption made when calling this code is that the edge has at most one root //
     //////////////////////////////////////////////////////////////////////////////////////
@@ -3154,6 +3187,7 @@ namespace pcl
       position[o] = Real(center-width/2+width*averageRoot);
       return 1;
     }
+
     template< int Degree >
     int Octree< Degree >::GetRootIndex( const TreeOctNode* node , int edgeIndex , int maxDepth , int sDepth,RootInfo& ri )
     {
@@ -3235,6 +3269,7 @@ namespace pcl
         return 1;
       }
     }
+
     template<int Degree>
     int Octree<Degree>::GetRootIndex( const TreeOctNode* node , int edgeIndex , int maxDepth , RootInfo& ri )
     {
@@ -3313,6 +3348,7 @@ namespace pcl
         return 1;
       }
     }
+
     template<int Degree>
     int Octree<Degree>::GetRootPair(const RootInfo& ri,int maxDepth,RootInfo& pair){
       const TreeOctNode* node=ri.node;
@@ -3328,8 +3364,8 @@ namespace pcl
         node=node->parent;
       }
       return 0;
-
     }
+
     template<int Degree>
     int Octree< Degree >::GetRootIndex( const RootInfo& ri , RootData& rootData , CoredPointIndex& index )
     {
@@ -3353,6 +3389,7 @@ namespace pcl
       }
       return 0;
     }
+
     template< int Degree >
     int Octree< Degree >::SetMCRootPositions( TreeOctNode* node , int sDepth , Real isoValue , TreeOctNode::ConstNeighborKey5& neighborKey5 , RootData& rootData ,
                                               std::vector< Point3D< float > >* interiorPositions , CoredMeshData* mesh , const Real* metSolution , int nonLinearFit )
@@ -3420,6 +3457,7 @@ namespace pcl
       }
       return count;
     }
+
     template<int Degree>
     int Octree< Degree >::SetBoundaryMCRootPositions( int sDepth , Real isoValue , RootData& rootData , CoredMeshData* mesh , int nonLinearFit )
     {
@@ -3461,6 +3499,7 @@ namespace pcl
       }
       return count;
     }
+
     template<int Degree>
     void Octree< Degree >::GetMCIsoEdges( TreeOctNode* node , int sDepth , std::vector< std::pair< RootInfo , RootInfo > >& edges )
     {
@@ -3558,6 +3597,7 @@ namespace pcl
         }
       }
     }
+
     template<int Degree>
 #if MISHA_DEBUG
     int Octree< Degree >::GetMCIsoTriangles( TreeOctNode* node , CoredMeshData* mesh , RootData& rootData , std::vector< Point3D< float > >* interiorPositions , int offSet , int sDepth , bool polygonMesh , std::vector< Point3D< float > >* barycenters )
@@ -3636,6 +3676,7 @@ namespace pcl
       }
       return int(loops.size());
     }
+
     template<int Degree>
 #if MISHA_DEBUG
     int Octree<Degree>::AddTriangles( CoredMeshData* mesh , std::vector<CoredPointIndex>& edges , std::vector<Point3D<float> >* interiorPositions , int offSet , bool polygonMesh , std::vector< Point3D< float > >* barycenters )
@@ -3758,6 +3799,7 @@ namespace pcl
       }
       return int(edges.size())-2;
     }
+
     template< int Degree >
     Real* Octree< Degree >::GetSolutionGrid( int& res , float isoValue , int depth )
     {
@@ -3802,6 +3844,7 @@ namespace pcl
 
       return values;
     }
+
     template< int Degree >
     Real* Octree< Degree >::GetWeightGrid( int& res , int depth )
     {
@@ -3847,20 +3890,24 @@ namespace pcl
       int idx[DIMENSION];
       return CenterIndex(node,maxDepth,idx);
     }
+
     long long VertexData::CenterIndex(const TreeOctNode* node,int maxDepth,int idx[DIMENSION]){
       int d,o[3];
       node->depthAndOffset(d,o);
       for(int i=0;i<DIMENSION;i++){idx[i]=BinaryNode<Real>::CornerIndex(maxDepth+1,d+1,o[i]<<1,1);}
       return (long long)(idx[0]) | (long long)(idx[1])<<15 | (long long)(idx[2])<<30;
     }
+
     long long VertexData::CenterIndex(int depth,const int offSet[DIMENSION],int maxDepth,int idx[DIMENSION]){
       for(int i=0;i<DIMENSION;i++){idx[i]=BinaryNode<Real>::CornerIndex(maxDepth+1,depth+1,offSet[i]<<1,1);}
       return (long long)(idx[0]) | (long long)(idx[1])<<15 | (long long)(idx[2])<<30;
     }
+
     long long VertexData::CornerIndex(const TreeOctNode* node,int cIndex,int maxDepth){
       int idx[DIMENSION];
       return CornerIndex(node,cIndex,maxDepth,idx);
     }
+
     long long VertexData::CornerIndex( const TreeOctNode* node , int cIndex , int maxDepth , int idx[DIMENSION] )
     {
       int x[DIMENSION];
@@ -3870,6 +3917,7 @@ namespace pcl
       for( int i=0 ; i<DIMENSION ; i++ ) idx[i] = BinaryNode<Real>::CornerIndex( maxDepth+1 , d , o[i] , x[i] );
       return CornerIndexKey( idx );
     }
+
     long long VertexData::CornerIndex( int depth , const int offSet[DIMENSION] , int cIndex , int maxDepth , int idx[DIMENSION] )
     {
       int x[DIMENSION];
@@ -3877,14 +3925,17 @@ namespace pcl
       for( int i=0 ; i<DIMENSION ; i++ ) idx[i] = BinaryNode<Real>::CornerIndex( maxDepth+1 , depth , offSet[i] , x[i] );
       return CornerIndexKey( idx );
     }
+
     long long VertexData::CornerIndexKey( const int idx[DIMENSION] )
     {
       return (long long)(idx[0]) | (long long)(idx[1])<<15 | (long long)(idx[2])<<30;
     }
+
     long long VertexData::FaceIndex(const TreeOctNode* node,int fIndex,int maxDepth){
       int idx[DIMENSION];
       return FaceIndex(node,fIndex,maxDepth,idx);
     }
+
     long long VertexData::FaceIndex(const TreeOctNode* node,int fIndex,int maxDepth,int idx[DIMENSION]){
       int dir,offset;
       Cube::FactorFaceIndex(fIndex,dir,offset);
@@ -3894,10 +3945,12 @@ namespace pcl
       idx[dir]=BinaryNode<Real>::CornerIndex(maxDepth+1,d,o[dir],offset);
       return (long long)(idx[0]) | (long long)(idx[1])<<15 | (long long)(idx[2])<<30;
     }
+
     long long VertexData::EdgeIndex(const TreeOctNode* node,int eIndex,int maxDepth){
       int idx[DIMENSION];
       return EdgeIndex(node,eIndex,maxDepth,idx);
     }
+
     long long VertexData::EdgeIndex(const TreeOctNode* node,int eIndex,int maxDepth,int idx[DIMENSION]){
       int o,i1,i2;
       int d,off[3];
@@ -3920,9 +3973,5 @@ namespace pcl
       };
       return (long long)(idx[0]) | (long long)(idx[1])<<15 | (long long)(idx[2])<<30;
     }
-
-    
   }
 }
-
-
index 1ea060c045d499b8d8cf5c409ee0f14d003d017c..9cae3118b96f6454203f9a99db30ecd7ce846cfb 100644 (file)
@@ -8,14 +8,14 @@ are permitted provided that the following conditions are met:
 Redistributions of source code must retain the above copyright notice, this list of
 conditions and the following disclaimer. Redistributions in binary form must reproduce
 the above copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the distribution. 
+in the documentation and/or other materials provided with the distribution.
 
 Neither the name of the Johns Hopkins University nor the names of its contributors
 may be used to endorse or promote products derived from this software without specific
-prior written permission. 
+prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
@@ -40,7 +40,6 @@ namespace pcl
 {
   namespace poisson
   {
-
     template<class NodeData,class Real> const int OctNode<NodeData,Real>::DepthShift=5;
     template<class NodeData,class Real> const int OctNode<NodeData,Real>::OffsetShift=19;
     template<class NodeData,class Real> const int OctNode<NodeData,Real>::DepthMask=(1<<DepthShift)-1;
@@ -62,6 +61,7 @@ namespace pcl
       }
       else{UseAlloc=0;}
     }
+
     template<class NodeData,class Real>
     int OctNode<NodeData,Real>::UseAllocator(void){return UseAlloc;}
 
@@ -73,9 +73,10 @@ namespace pcl
 
     template <class NodeData,class Real>
     OctNode<NodeData,Real>::~OctNode(void){
-      if(!UseAlloc){if(children){delete[] children;}}
+      if(!UseAlloc){delete[] children;}
       parent=children=NULL;
     }
+
     template <class NodeData,class Real>
     void OctNode<NodeData,Real>::setFullDepth(int maxDepth){
       if( maxDepth )
@@ -91,7 +92,7 @@ namespace pcl
 
       if(UseAlloc){children=internalAllocator.newElements(8);}
       else{
-        if(children){delete[] children;}
+        delete[] children;
         children=NULL;
         children=new OctNode[Cube::CORNERS];
       }
@@ -116,6 +117,7 @@ namespace pcl
       }
       return 1;
     }
+
     template <class NodeData,class Real>
     inline void OctNode<NodeData,Real>::Index(int depth,const int offset[3],short& d,short off[3]){
       d=short(depth);
@@ -131,6 +133,7 @@ namespace pcl
       offset[1]=(int(off[1])+1)&(~(1<<depth));
       offset[2]=(int(off[2])+1)&(~(1<<depth));
     }
+
     template<class NodeData,class Real>
     inline int OctNode<NodeData,Real>::depth(void) const {return int(d);}
     template<class NodeData,class Real>
@@ -140,6 +143,7 @@ namespace pcl
       offset[1]=(int((index>>OffsetShift2)&OffsetMask)+1)&(~(1<<depth));
       offset[2]=(int((index>>OffsetShift3)&OffsetMask)+1)&(~(1<<depth));
     }
+
     template<class NodeData,class Real>
     inline int OctNode<NodeData,Real>::Depth(const long long& index){return int(index&DepthMask);}
     template <class NodeData,class Real>
@@ -152,6 +156,7 @@ namespace pcl
       width=Real(1.0/(1<<depth));
       for(int dim=0;dim<DIMENSION;dim++){center.coords[dim]=Real(0.5+offset[dim])*width;}
     }
+
     template< class NodeData , class Real >
     bool OctNode< NodeData , Real >::isInside( Point3D< Real > p ) const
     {
@@ -161,6 +166,7 @@ namespace pcl
       w /= 2;
       return (c[0]-w)<p[0] && p[0]<=(c[0]+w) && (c[1]-w)<p[1] && p[1]<=(c[1]+w) && (c[2]-w)<p[2] && p[2]<=(c[2]+w);
     }
+
     template <class NodeData,class Real>
     inline void OctNode<NodeData,Real>::CenterAndWidth(const long long& index,Point3D<Real>& center,Real& width){
       int depth,offset[3];
@@ -184,6 +190,7 @@ namespace pcl
         return c+1;
       }
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::nodes(void) const{
       if(!children){return 1;}
@@ -193,6 +200,7 @@ namespace pcl
         return c+1;
       }
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::leaves(void) const{
       if(!children){return 1;}
@@ -202,6 +210,7 @@ namespace pcl
         return c;
       }
     }
+
     template<class NodeData,class Real>
     int OctNode<NodeData,Real>::maxDepthLeaves(int maxDepth) const{
       if(depth()>maxDepth){return 0;}
@@ -212,6 +221,7 @@ namespace pcl
         return c;
       }
     }
+
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::root(void) const{
       const OctNode* temp=this;
@@ -219,7 +229,6 @@ namespace pcl
       return temp;
     }
 
-
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::nextBranch( const OctNode* current ) const
     {
@@ -227,12 +236,14 @@ namespace pcl
       if(current-current->parent->children==Cube::CORNERS-1) return nextBranch( current->parent );
       else return current+1;
     }
+
     template <class NodeData,class Real>
     OctNode<NodeData,Real>* OctNode<NodeData,Real>::nextBranch(OctNode* current){
       if(!current->parent || current==this){return NULL;}
       if(current-current->parent->children==Cube::CORNERS-1){return nextBranch(current->parent);}
       else{return current+1;}
     }
+
     template< class NodeData , class Real >
     const OctNode< NodeData , Real >* OctNode< NodeData , Real >::prevBranch( const OctNode* current ) const
     {
@@ -240,6 +251,7 @@ namespace pcl
       if( current-current->parent->children==0 ) return prevBranch( current->parent );
       else return current-1;
     }
+
     template< class NodeData , class Real >
     OctNode< NodeData , Real >* OctNode< NodeData , Real >::prevBranch( OctNode* current )
     {
@@ -247,6 +259,7 @@ namespace pcl
       if( current-current->parent->children==0 ) return prevBranch( current->parent );
       else return current-1;
     }
+
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::nextLeaf(const OctNode* current) const{
       if(!current){
@@ -259,6 +272,7 @@ namespace pcl
       if(!temp){return NULL;}
       else{return temp->nextLeaf();}
     }
+
     template <class NodeData,class Real>
     OctNode<NodeData,Real>* OctNode<NodeData,Real>::nextLeaf(OctNode* current){
       if(!current){
@@ -279,6 +293,7 @@ namespace pcl
       else if( current->children ) return &current->children[0];
       else return nextBranch(current);
     }
+
     template <class NodeData,class Real>
     OctNode<NodeData,Real>* OctNode<NodeData,Real>::nextNode( OctNode* current )
     {
@@ -308,6 +323,7 @@ namespace pcl
       if(processCurrent){F->Function(this,node);}
       if(children){__processNodeNodes(node,F);}
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::processNodeFaces(OctNode* node,NodeAdjacencyFunction* F,int fIndex,int processCurrent){
@@ -318,6 +334,7 @@ namespace pcl
         __processNodeFaces(node,F,c1,c2,c3,c4);
       }
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::processNodeEdges(OctNode* node,NodeAdjacencyFunction* F,int eIndex,int processCurrent){
@@ -328,6 +345,7 @@ namespace pcl
         __processNodeEdges(node,F,c1,c2);
       }
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::processNodeCorners(OctNode* node,NodeAdjacencyFunction* F,int cIndex,int processCurrent){
@@ -338,6 +356,7 @@ namespace pcl
         F->Function(temp,node);
       }
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__processNodeNodes(OctNode* node,NodeAdjacencyFunction* F){
@@ -358,6 +377,7 @@ namespace pcl
       if(children[6].children){children[6].__processNodeNodes(node,F);}
       if(children[7].children){children[7].__processNodeNodes(node,F);}
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__processNodeEdges(OctNode* node,NodeAdjacencyFunction* F,int cIndex1,int cIndex2){
@@ -366,6 +386,7 @@ namespace pcl
       if(children[cIndex1].children){children[cIndex1].__processNodeEdges(node,F,cIndex1,cIndex2);}
       if(children[cIndex2].children){children[cIndex2].__processNodeEdges(node,F,cIndex1,cIndex2);}
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__processNodeFaces(OctNode* node,NodeAdjacencyFunction* F,int cIndex1,int cIndex2,int cIndex3,int cIndex4){
@@ -378,6 +399,7 @@ namespace pcl
       if(children[cIndex3].children){children[cIndex3].__processNodeFaces(node,F,cIndex1,cIndex2,cIndex3,cIndex4);}
       if(children[cIndex4].children){children[cIndex4].__processNodeFaces(node,F,cIndex1,cIndex2,cIndex3,cIndex4);}
     }
+
     template<class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessNodeAdjacentNodes(int maxDepth,OctNode* node1,int width1,OctNode* node2,int width2,NodeAdjacencyFunction* F,int processCurrent){
@@ -389,6 +411,7 @@ namespace pcl
 
       ProcessNodeAdjacentNodes(c1[0]-c2[0],c1[1]-c2[1],c1[2]-c2[2],node1,(width1*w1)>>1,node2,(width2*w2)>>1,w2,F,processCurrent);
     }
+
     template<class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessNodeAdjacentNodes(int dx,int dy,int dz,
@@ -400,6 +423,7 @@ namespace pcl
       if(!node2->children){return;}
       __ProcessNodeAdjacentNodes(-dx,-dy,-dz,node1,radius1,node2,radius2,width2/2,F);
     }
+
     template<class NodeData,class Real>
     template<class TerminatingNodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessTerminatingNodeAdjacentNodes(int maxDepth,OctNode* node1,int width1,OctNode* node2,int width2,TerminatingNodeAdjacencyFunction* F,int processCurrent){
@@ -411,6 +435,7 @@ namespace pcl
 
       ProcessTerminatingNodeAdjacentNodes(c1[0]-c2[0],c1[1]-c2[1],c1[2]-c2[2],node1,(width1*w1)>>1,node2,(width2*w2)>>1,w2,F,processCurrent);
     }
+
     template<class NodeData,class Real>
     template<class TerminatingNodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessTerminatingNodeAdjacentNodes(int dx,int dy,int dz,
@@ -423,6 +448,7 @@ namespace pcl
       if(!node2->children){return;}
       __ProcessTerminatingNodeAdjacentNodes(-dx,-dy,-dz,node1,radius1,node2,radius2,width2/2,F);
     }
+
     template<class NodeData,class Real>
     template<class PointAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessPointAdjacentNodes( int maxDepth , const int c1[3] , OctNode* node2 , int width2 , PointAdjacencyFunction* F , int processCurrent )
@@ -432,6 +458,7 @@ namespace pcl
       w2 = node2->width( maxDepth+1 );
       ProcessPointAdjacentNodes( c1[0]-c2[0] , c1[1]-c2[1] , c1[2]-c2[2] , node2 , (width2*w2)>>1 , w2 , F , processCurrent );
     }
+
     template<class NodeData,class Real>
     template<class PointAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessPointAdjacentNodes(int dx,int dy,int dz,
@@ -443,6 +470,7 @@ namespace pcl
       if( !node2->children ) return;
       __ProcessPointAdjacentNodes( -dx , -dy , -dz , node2 , radius2 , width2>>1 , F );
     }
+
     template<class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessFixedDepthNodeAdjacentNodes(int maxDepth,
@@ -458,6 +486,7 @@ namespace pcl
 
       ProcessFixedDepthNodeAdjacentNodes(c1[0]-c2[0],c1[1]-c2[1],c1[2]-c2[2],node1,(width1*w1)>>1,node2,(width2*w2)>>1,w2,depth,F,processCurrent);
     }
+
     template<class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessFixedDepthNodeAdjacentNodes(int dx,int dy,int dz,
@@ -474,6 +503,7 @@ namespace pcl
         __ProcessFixedDepthNodeAdjacentNodes(-dx,-dy,-dz,node1,radius1,node2,radius2,width2/2,depth-1,F);
       }
     }
+
     template<class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessMaxDepthNodeAdjacentNodes(int maxDepth,
@@ -488,6 +518,7 @@ namespace pcl
       w2=node2->width(maxDepth+1);
       ProcessMaxDepthNodeAdjacentNodes(c1[0]-c2[0],c1[1]-c2[1],c1[2]-c2[2],node1,(width1*w1)>>1,node2,(width2*w2)>>1,w2,depth,F,processCurrent);
     }
+
     template<class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::ProcessMaxDepthNodeAdjacentNodes(int dx,int dy,int dz,
@@ -501,6 +532,7 @@ namespace pcl
       if(processCurrent){F->Function(node2,node1);}
       if(d<depth && node2->children){__ProcessMaxDepthNodeAdjacentNodes(-dx,-dy,-dz,node1,radius1,node2,radius2,width2>>1,depth-1,F);}
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__ProcessNodeAdjacentNodes(int dx,int dy,int dz,
@@ -528,6 +560,7 @@ namespace pcl
         if(o&128){F->Function(&node2->children[7],node1);if(node2->children[7].children){__ProcessNodeAdjacentNodes(dx2,dy2,dz2,node1,radius1,&node2->children[7],radius,cWidth,F);}}
       }
     }
+
     template <class NodeData,class Real>
     template<class TerminatingNodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__ProcessTerminatingNodeAdjacentNodes(int dx,int dy,int dz,
@@ -555,6 +588,7 @@ namespace pcl
         if(o&128){if(F->Function(&node2->children[7],node1) && node2->children[7].children){__ProcessTerminatingNodeAdjacentNodes(dx2,dy2,dz2,node1,radius1,&node2->children[7],radius,cWidth,F);}}
       }
     }
+
     template <class NodeData,class Real>
     template<class PointAdjacencyFunction>
     void OctNode<NodeData,Real>::__ProcessPointAdjacentNodes(int dx,int dy,int dz,
@@ -582,6 +616,7 @@ namespace pcl
         if(o&128){F->Function(&node2->children[7]);if(node2->children[7].children){__ProcessPointAdjacentNodes(dx2,dy2,dz2,&node2->children[7],radius,cWidth,F);}}
       }
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__ProcessFixedDepthNodeAdjacentNodes(int dx,int dy,int dz,
@@ -621,6 +656,7 @@ namespace pcl
         }
       }
     }
+
     template <class NodeData,class Real>
     template<class NodeAdjacencyFunction>
     void OctNode<NodeData,Real>::__ProcessMaxDepthNodeAdjacentNodes(int dx,int dy,int dz,
@@ -660,6 +696,7 @@ namespace pcl
         }
       }
     }
+
     template <class NodeData,class Real>
     inline int OctNode<NodeData,Real>::ChildOverlap(int dx,int dy,int dz,int d,int cRadius2)
     {
@@ -703,6 +740,7 @@ namespace pcl
       }
       return temp;
     }
+
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::getNearestLeaf(const Point3D<Real>& p) const{
       int nearest;
@@ -752,6 +790,7 @@ namespace pcl
       if(idx1[0]==idx2[0] && idx1[1]==idx2[1]){return 1;}
       else                                                                     {return 0;}
     }
+
     template<class NodeData,class Real>
     int OctNode<NodeData,Real>::CornerIndex(const Point3D<Real>& center,const Point3D<Real>& p){
       int cIndex=0;
@@ -760,11 +799,12 @@ namespace pcl
       if(p.coords[2]>center.coords[2]){cIndex|=4;}
       return cIndex;
     }
+
     template <class NodeData,class Real>
     template<class NodeData2>
     OctNode<NodeData,Real>& OctNode<NodeData,Real>::operator = (const OctNode<NodeData2,Real>& node){
       int i;
-      if(children){delete[] children;}
+      delete[] children;
       children=NULL;
 
       d=node.depth ();
@@ -775,10 +815,12 @@ namespace pcl
       }
       return *this;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::CompareForwardDepths(const void* v1,const void* v2){
       return ((const OctNode<NodeData,Real>*)v1)->depth-((const OctNode<NodeData,Real>*)v2)->depth;
     }
+
     template< class NodeData , class Real >
     int OctNode< NodeData , Real >::CompareByDepthAndXYZ( const void* v1 , const void* v2 )
     {
@@ -798,6 +840,7 @@ namespace pcl
       for( int i=0 ; i<31 ; i++ ) key |= ( ( _p[0] & (1ull<<i) )<<(2*i) ) | ( ( _p[1] & (1ull<<i) )<<(2*i+1) ) | ( ( _p[2] & (1ull<<i) )<<(2*i+2) );
       return key;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::CompareByDepthAndZIndex( const void* v1 , const void* v2 )
     {
@@ -829,14 +872,17 @@ namespace pcl
       return int(n1->off[2])-int(n2->off[2]);
       return 0;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::CompareBackwardDepths(const void* v1,const void* v2){
       return ((const OctNode<NodeData,Real>*)v2)->depth-((const OctNode<NodeData,Real>*)v1)->depth;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::CompareBackwardPointerDepths(const void* v1,const void* v2){
       return (*(const OctNode<NodeData,Real>**)v2)->depth()-(*(const OctNode<NodeData,Real>**)v1)->depth();
     }
+
     template <class NodeData,class Real>
     inline int OctNode<NodeData,Real>::Overlap2(const int &depth1,const int offSet1[DIMENSION],const Real& multiplier1,const int &depth2,const int offSet2[DIMENSION],const Real& multiplier2){
       int d=depth2-depth1;
@@ -849,11 +895,13 @@ namespace pcl
          ){return 0;}
       return 1;
     }
+
     template <class NodeData,class Real>
     inline int OctNode<NodeData,Real>::Overlap(int c1,int c2,int c3,int dWidth){
       if(c1>=dWidth || c1<=-dWidth || c2>=dWidth || c2<=-dWidth || c3>=dWidth || c3<=-dWidth){return 0;}
       else{return 1;}
     }
+
     template <class NodeData,class Real>
     OctNode<NodeData,Real>* OctNode<NodeData,Real>::faceNeighbor(int faceIndex,int forceChildren){return __faceNeighbor(faceIndex>>1,faceIndex&1,forceChildren);}
     template <class NodeData,class Real>
@@ -874,6 +922,7 @@ namespace pcl
         return &temp->children[pIndex];
       }
     }
+
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::__faceNeighbor(int dir,int off) const {
       if(!parent){return NULL;}
@@ -898,6 +947,7 @@ namespace pcl
       };
       return __edgeNeighbor(o,i,idx,forceChildren);
     }
+
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::edgeNeighbor(int edgeIndex) const {
       int idx[2],o,i[2];
@@ -909,6 +959,7 @@ namespace pcl
       };
       return __edgeNeighbor(o,i,idx);
     }
+
     template <class NodeData,class Real>
     const OctNode<NodeData,Real>* OctNode<NodeData,Real>::__edgeNeighbor(int o,const int i[2],const int idx[2]) const{
       if(!parent){return NULL;}
@@ -938,6 +989,7 @@ namespace pcl
       }
       else{return NULL;}
     }
+
     template <class NodeData,class Real>
     OctNode<NodeData,Real>* OctNode<NodeData,Real>::__edgeNeighbor(int o,const int i[2],const int idx[2],int forceChildren){
       if(!parent){return NULL;}
@@ -1020,6 +1072,7 @@ namespace pcl
       }
       else{return NULL;}
     }
+
     template <class NodeData,class Real>
     OctNode<NodeData,Real>* OctNode<NodeData,Real>::cornerNeighbor(int cornerIndex,int forceChildren){
       int pIndex,aIndex=0;
@@ -1072,32 +1125,37 @@ namespace pcl
       }
       else{return NULL;}
     }
+
     ////////////////////////
     // OctNodeNeighborKey //
     ////////////////////////
     template<class NodeData,class Real>
     OctNode<NodeData,Real>::Neighbors3::Neighbors3(void){clear();}
+
     template<class NodeData,class Real>
     void OctNode<NodeData,Real>::Neighbors3::clear(void){
       for(int i=0;i<3;i++){for(int j=0;j<3;j++){for(int k=0;k<3;k++){neighbors[i][j][k]=NULL;}}}
     }
+
     template<class NodeData,class Real>
     OctNode<NodeData,Real>::NeighborKey3::NeighborKey3(void){ neighbors=NULL; }
+
     template<class NodeData,class Real>
     OctNode<NodeData,Real>::NeighborKey3::~NeighborKey3(void)
     {
-      if( neighbors ) delete[] neighbors;
+      delete[] neighbors;
       neighbors = NULL;
     }
 
     template<class NodeData,class Real>
     void OctNode<NodeData,Real>::NeighborKey3::set( int d )
     {
-      if( neighbors ) delete[] neighbors;
+      delete[] neighbors;
       neighbors = NULL;
       if( d<0 ) return;
       neighbors = new Neighbors3[d+1];
     }
+
     template< class NodeData , class Real >
     typename OctNode<NodeData,Real>::Neighbors3& OctNode<NodeData,Real>::NeighborKey3::setNeighbors( OctNode<NodeData,Real>* root , Point3D< Real > p , int d )
     {
@@ -1174,6 +1232,7 @@ namespace pcl
       }
       return neighbors[d];
     }
+
     template< class NodeData , class Real >
     typename OctNode<NodeData,Real>::Neighbors3& OctNode<NodeData,Real>::NeighborKey3::getNeighbors( OctNode<NodeData,Real>* root , Point3D< Real > p , int d )
     {
@@ -1307,6 +1366,7 @@ namespace pcl
       }
       return neighbors[d];
     }
+
     // Note the assumption is that if you enable an edge, you also enable adjacent faces.
     // And, if you enable a corner, you enable adjacent edges and faces.
     template< class NodeData , class Real >
@@ -1467,25 +1527,29 @@ namespace pcl
     ///////////////////////
     template<class NodeData,class Real>
     OctNode<NodeData,Real>::ConstNeighbors3::ConstNeighbors3(void){clear();}
+
     template<class NodeData,class Real>
     void OctNode<NodeData,Real>::ConstNeighbors3::clear(void){
       for(int i=0;i<3;i++){for(int j=0;j<3;j++){for(int k=0;k<3;k++){neighbors[i][j][k]=NULL;}}}
     }
+
     template<class NodeData,class Real>
     OctNode<NodeData,Real>::ConstNeighborKey3::ConstNeighborKey3(void){neighbors=NULL;}
+
     template<class NodeData,class Real>
     OctNode<NodeData,Real>::ConstNeighborKey3::~ConstNeighborKey3(void){
-      if(neighbors){delete[] neighbors;}
+      delete[] neighbors;
       neighbors=NULL;
     }
 
     template<class NodeData,class Real>
     void OctNode<NodeData,Real>::ConstNeighborKey3::set(int d){
-      if(neighbors){delete[] neighbors;}
+      delete[] neighbors;
       neighbors=NULL;
       if(d<0){return;}
       neighbors=new ConstNeighbors3[d+1];
     }
+
     template<class NodeData,class Real>
     typename OctNode<NodeData,Real>::ConstNeighbors3& OctNode<NodeData,Real>::ConstNeighborKey3::getNeighbors(const OctNode<NodeData,Real>* node){
       int d=node->depth();
@@ -1544,6 +1608,7 @@ namespace pcl
       }
       return neighbors[node->depth()];
     }
+
     template<class NodeData,class Real>
     typename OctNode<NodeData,Real>::ConstNeighbors3& OctNode<NodeData,Real>::ConstNeighborKey3::getNeighbors( const OctNode<NodeData,Real>* node , int minDepth )
     {
@@ -1606,59 +1671,69 @@ namespace pcl
     }
 
     template< class NodeData , class Real > OctNode< NodeData , Real >::Neighbors5::Neighbors5( void ){ clear(); }
+
     template< class NodeData , class Real > OctNode< NodeData , Real >::ConstNeighbors5::ConstNeighbors5( void ){ clear(); }
+
     template< class NodeData , class Real >
     void OctNode< NodeData , Real >::Neighbors5::clear( void )
     {
       for( int i=0 ; i<5 ; i++ ) for( int j=0 ; j<5 ; j++ ) for( int k=0 ; k<5 ; k++ ) neighbors[i][j][k] = NULL;
     }
+
     template< class NodeData , class Real >
     void OctNode< NodeData , Real >::ConstNeighbors5::clear( void )
     {
       for( int i=0 ; i<5 ; i++ ) for( int j=0 ; j<5 ; j++ ) for( int k=0 ; k<5 ; k++ ) neighbors[i][j][k] = NULL;
     }
+
     template< class NodeData , class Real >
     OctNode< NodeData , Real >::NeighborKey5::NeighborKey5( void )
     {
       _depth = -1;
       neighbors = NULL;
     }
+
     template< class NodeData , class Real >
     OctNode< NodeData , Real >::ConstNeighborKey5::ConstNeighborKey5( void )
     {
       _depth = -1;
       neighbors = NULL;
     }
+
     template< class NodeData , class Real >
     OctNode< NodeData , Real >::NeighborKey5::~NeighborKey5( void )
     {
-      if( neighbors ) delete[] neighbors;
+      delete[] neighbors;
       neighbors = NULL;
     }
+
     template< class NodeData , class Real >
     OctNode< NodeData , Real >::ConstNeighborKey5::~ConstNeighborKey5( void )
     {
-      if( neighbors ) delete[] neighbors;
+      delete[] neighbors;
       neighbors = NULL;
     }
+
     template< class NodeData , class Real >
     void OctNode< NodeData , Real >::NeighborKey5::set( int d )
     {
-      if( neighbors ) delete[] neighbors;
+      delete[] neighbors;
       neighbors = NULL;
       if(d<0) return;
       _depth = d;
       neighbors=new Neighbors5[d+1];
     }
+
     template< class NodeData , class Real >
     void OctNode< NodeData , Real >::ConstNeighborKey5::set( int d )
     {
-      if( neighbors ) delete[] neighbors;
+      delete[] neighbors;
       neighbors = NULL;
       if(d<0) return;
       _depth = d;
       neighbors=new ConstNeighbors5[d+1];
     }
+
     template< class NodeData , class Real >
     typename OctNode< NodeData , Real >::Neighbors5& OctNode< NodeData , Real >::NeighborKey5::getNeighbors( OctNode* node )
     {
@@ -1775,6 +1850,7 @@ namespace pcl
       }
       return neighbors[d];
     }
+
     template< class NodeData , class Real >
     typename OctNode< NodeData , Real >::Neighbors5& OctNode< NodeData , Real >::NeighborKey5::setNeighbors( OctNode* node , int xStart , int xEnd , int yStart , int yEnd , int zStart , int zEnd )
     {
@@ -1819,6 +1895,7 @@ namespace pcl
       }
       return neighbors[d];
     }
+
     template< class NodeData , class Real >
     typename OctNode< NodeData , Real >::ConstNeighbors5& OctNode< NodeData , Real >::ConstNeighborKey5::getNeighbors( const OctNode* node )
     {
@@ -1861,7 +1938,6 @@ namespace pcl
       return neighbors[d];
     }
 
-
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::write(const char* fileName) const{
       FILE* fp=fopen(fileName,"wb");
@@ -1870,12 +1946,14 @@ namespace pcl
       fclose(fp);
       return ret;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::write(FILE* fp) const{
       fwrite(this,sizeof(OctNode<NodeData,Real>),1,fp);
       if(children){for(int i=0;i<Cube::CORNERS;i++){children[i].write(fp);}}
       return 1;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::read(const char* fileName){
       FILE* fp=fopen(fileName,"rb");
@@ -1884,6 +1962,7 @@ namespace pcl
       fclose(fp);
       return ret;
     }
+
     template <class NodeData,class Real>
     int OctNode<NodeData,Real>::read(FILE* fp){
       fread(this,sizeof(OctNode<NodeData,Real>),1,fp);
@@ -1898,17 +1977,18 @@ namespace pcl
       }
       return 1;
     }
+
     template<class NodeData,class Real>
     int OctNode<NodeData,Real>::width(int maxDepth) const {
       int d=depth();
       return 1<<(maxDepth-d);
     }
+
     template<class NodeData,class Real>
     void OctNode<NodeData,Real>::centerIndex(int maxDepth,int index[DIMENSION]) const {
       int d,o[3];
       depthAndOffset(d,o);
       for(int i=0;i<DIMENSION;i++){index[i]=BinaryNode<Real>::CornerIndex(maxDepth,d+1,o[i]<<1,1);}
     }
-
   }
 }
index 45973dbc8e9b87c707c919bf665debebce0110e2..1d7bffa7fe3a3bdcd9f3f18043272c02ec4e7d67 100644 (file)
@@ -8,14 +8,14 @@ are permitted provided that the following conditions are met:
 Redistributions of source code must retain the above copyright notice, this list of
 conditions and the following disclaimer. Redistributions in binary form must reproduce
 the above copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the distribution. 
+in the documentation and/or other materials provided with the distribution.
 
 Neither the name of the Johns Hopkins University nor the names of its contributors
 may be used to endorse or promote products derived from this software without specific
-prior written permission. 
+prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
@@ -26,10 +26,15 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF S
 DAMAGE.
 */
 
+#include "factor.h"
+
 #include <float.h>
 #include <math.h>
+
 #include <algorithm>
-#include "factor.h"
+
+#include <cstdio>
+#include <cstring>
 
 ////////////////
 // Polynomial //
@@ -74,9 +79,9 @@ namespace pcl
       for(int i=0;i<=Degree;i++){p.coefficients[i+1]=coefficients[i]/(i+1);}
       return p;
     }
-    template<> double Polynomial< 0 >::operator() ( double t ) const { return coefficients[0]; }
-    template<> double Polynomial< 1 >::operator() ( double t ) const { return coefficients[0]+coefficients[1]*t; }
-    template<> double Polynomial< 2 >::operator() ( double t ) const { return coefficients[0]+(coefficients[1]+coefficients[2]*t)*t; }
+    template<> inline double Polynomial< 0 >::operator() ( double t ) const { return coefficients[0]; }
+    template<> inline double Polynomial< 1 >::operator() ( double t ) const { return coefficients[0]+coefficients[1]*t; }
+    template<> inline double Polynomial< 2 >::operator() ( double t ) const { return coefficients[0]+(coefficients[1]+coefficients[2]*t)*t; }
     template<int Degree>
     double Polynomial<Degree>::operator() ( double t ) const{
       double v=coefficients[Degree];
@@ -296,14 +301,14 @@ namespace pcl
         }
       }
     }
-    template< >
+    template< > inline
     Polynomial< 0 > Polynomial< 0 >::BSplineComponent( int i )
     {
       Polynomial p;
       p.coefficients[0] = 1.;
       return p;
     }
-    template< int Degree >
+    template< int Degree > inline
     Polynomial< Degree > Polynomial< Degree >::BSplineComponent( int i )
     {
       Polynomial p;
index 5f9de7d3efb224a3b19f246e7e7f938dc854b43a..6d1d78a449cbc4b54374538f94a5098dfb740a99 100644 (file)
@@ -28,6 +28,9 @@ DAMAGE.
 
 #include "factor.h"
 
+#include <cstdio>
+#include <cstring>
+
 ////////////////////////
 // StartingPolynomial //
 ////////////////////////
@@ -370,7 +373,7 @@ namespace pcl
       }
       printf("\n");
     }
-    template< >
+    template< > inline
     PPolynomial< 0 > PPolynomial< 0 >::BSpline( double radius )
     {
       PPolynomial q;
index 0b3fd47ded3b89b02ebf7c4d23ac23391e424743..193e64dd1a37f80cfd3072de816cd479c678343b 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/processing.h>
 
index 208e3bd2e51d7f9d3ce3b45b59c4af809c128fe5..eb076d1fba7d86f3a14ffe63a5f89e3e5f35a277 100644 (file)
@@ -40,8 +40,7 @@
 #pragma once
 
 #if defined __GNUC__
-#  pragma GCC system_header 
+#  pragma GCC system_header
 #endif
 
 #include <boost/dynamic_bitset/dynamic_bitset.hpp>
-#include <boost/shared_ptr.hpp>
index 4bad4b8bc3067cef7074273d991374dd82eb0d06..2db2e92ac61cc18fed90c4f1834419b7a7e29961 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/pcl_config.h>
 #ifdef HAVE_QHULL 
index 94fe4320b07a3ccc84d0a3ff4376e9a7769b06f2..e1d5db849e4cb767d9837760eddfd05844b7c1f7 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/boost.h>
 #include <pcl/surface/reconstruction.h>
index 028d270254f324a6378892dcaaa1289f93369f71..f98a9609b7a48a38b52c7acb262b6f78ab1bdb66 100644 (file)
@@ -40,7 +40,7 @@
 #ifndef PCL_SURFACE_IMPL_MLS_H_
 #define PCL_SURFACE_IMPL_MLS_H_
 
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <pcl/surface/mls.h>
 #include <pcl/common/io.h>
 #include <pcl/common/copy_point.h>
@@ -292,9 +292,11 @@ pcl::MovingLeastSquares<PointInT, PointOutT>::performProcessing (PointCloudOut &
 #endif
 
   // For all points
-#ifdef _OPENMP
-#pragma omp parallel for schedule (dynamic,1000) num_threads (threads)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(corresponding_input_indices, projected_points, projected_points_normals) \
+  schedule(dynamic,1000) \
+  num_threads(threads)
   for (int cp = 0; cp < static_cast<int> (indices_->size ()); ++cp)
   {
     // Allocate enough space to hold the results of nearest neighbor searches
index 1cdaa8213592cfafcf7a102fa8b342c87bb76684..4c262cdc32bc964c4a80b6ea27cd7de2f21df089 100644 (file)
  *
  */
 
+#pragma once
+
+
+namespace pcl
+{
 
-//////////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointInT, typename PointOutT> void
-pcl::CloudSurfaceProcessing<PointInT, PointOutT>::process (pcl::PointCloud<PointOutT> &output)
+CloudSurfaceProcessing<PointInT, PointOutT>::process (pcl::PointCloud<PointOutT> &output)
 {
   // Copy the header
   output.header = input_->header;
@@ -57,3 +61,6 @@ pcl::CloudSurfaceProcessing<PointInT, PointOutT>::process (pcl::PointCloud<Point
 
   deinitCompute ();
 }
+
+} // namespace pcl
+
index 6c357560e0154e2665e02c296a25f73ba74f27d3..33a304369c179df9bcad6f4dfa01d80f50402525 100644 (file)
 
 #ifndef PCL_SURFACE_RECONSTRUCTION_IMPL_H_
 #define PCL_SURFACE_RECONSTRUCTION_IMPL_H_
+
 #include <pcl/search/pcl_search.h>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template <typename PointInT> void
-pcl::SurfaceReconstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
+SurfaceReconstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
 {
   // Copy the header
   output.header = input_->header;
 
-  if (!initCompute ()) 
+  if (!initCompute ())
   {
     output.cloud.width = output.cloud.height = 0;
     output.cloud.data.clear ();
@@ -81,15 +85,15 @@ pcl::SurfaceReconstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
   deinitCompute ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT> void
-pcl::SurfaceReconstruction<PointInT>::reconstruct (pcl::PointCloud<PointInT> &points,
-                                                   std::vector<pcl::Vertices> &polygons)
+SurfaceReconstruction<PointInT>::reconstruct (pcl::PointCloud<PointInT> &points,
+                                              std::vector<pcl::Vertices> &polygons)
 {
   // Copy the header
   points.header = input_->header;
 
-  if (!initCompute ()) 
+  if (!initCompute ())
   {
     points.width = points.height = 0;
     points.clear ();
@@ -121,14 +125,14 @@ pcl::SurfaceReconstruction<PointInT>::reconstruct (pcl::PointCloud<PointInT> &po
   deinitCompute ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT> void
-pcl::MeshConstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
+MeshConstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
 {
   // Copy the header
   output.header = input_->header;
 
-  if (!initCompute ()) 
+  if (!initCompute ())
   {
     output.cloud.width = output.cloud.height = 1;
     output.cloud.data.clear ();
@@ -161,11 +165,11 @@ pcl::MeshConstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
   deinitCompute ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT> void
-pcl::MeshConstruction<PointInT>::reconstruct (std::vector<pcl::Vertices> &polygons)
+MeshConstruction<PointInT>::reconstruct (std::vector<pcl::Vertices> &polygons)
 {
-  if (!initCompute ()) 
+  if (!initCompute ())
   {
     polygons.clear ();
     return;
@@ -195,6 +199,7 @@ pcl::MeshConstruction<PointInT>::reconstruct (std::vector<pcl::Vertices> &polygo
   deinitCompute ();
 }
 
+} // namespace pcl
 
 #endif  // PCL_SURFACE_RECONSTRUCTION_IMPL_H_
 
index a6d607160fd30b60628e3945e1dddb2b1a8d770d..48ad61ef7a46c3a8eb0b70807589bdea9412c87f 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <pcl/common/distances.h>
 #include <pcl/surface/texture_mapping.h>
+#include <unordered_set>
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 template<typename PointInT> std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> >
@@ -579,6 +580,9 @@ pcl::TextureMapping<PointInT>::sortFacesByCamera (pcl::TextureMesh &tex_mesh, pc
     removeOccludedPoints (transformed_cloud, filtered_cloud, octree_voxel_size, visible, occluded);
     visible_pts = *filtered_cloud;
 
+    // pushing occluded idxs into a set for faster lookup
+    std::unordered_set<index_t> occluded_set(occluded.cbegin(), occluded.cend());
+
     // find visible faces => add them to polygon N for camera N
     // add polygon group for current camera in clean
     std::vector<pcl::Vertices> visibleFaces_currentCam;
@@ -586,32 +590,18 @@ pcl::TextureMapping<PointInT>::sortFacesByCamera (pcl::TextureMesh &tex_mesh, pc
     for (std::size_t faces = 0; faces < tex_mesh.tex_polygons[0].size (); ++faces)
     {
       // check if all the face's points are visible
-      bool faceIsVisible = true;
-      std::vector<int>::iterator it;
-
       // iterate over face's vertex
-      for (std::size_t current_pt_indice = 0; faceIsVisible && current_pt_indice < tex_mesh.tex_polygons[0][faces].vertices.size (); ++current_pt_indice)
+      const auto faceIsVisible = std::all_of(tex_mesh.tex_polygons[0][faces].vertices.cbegin(),
+                                             tex_mesh.tex_polygons[0][faces].vertices.cend(),
+                                             [&](const auto& vertex)
       {
-        // TODO this is far too long! Better create an helper function that raycasts here.
-        it = find (occluded.begin (), occluded.end (), tex_mesh.tex_polygons[0][faces].vertices[current_pt_indice]);
-
-        if (it == occluded.end ())
-        {
-          // point is not occluded
-          // does it land on the camera's image plane?
-          PointInT pt = transformed_cloud->points[tex_mesh.tex_polygons[0][faces].vertices[current_pt_indice]];
-          Eigen::Vector2f dummy_UV;
-          if (!getPointUVCoordinates (pt, camera, dummy_UV))
-          {
-            // point is not visible by the camera
-            faceIsVisible = false;
+          if (occluded_set.find(vertex) != occluded_set.cend()) {
+            return false;  // point is occluded
           }
-        }
-        else
-        {
-          faceIsVisible = false;
-        }
-      }
+          // is the point visible to the camera?
+          Eigen::Vector2f dummy_UV;
+          return this->getPointUVCoordinates ((*transformed_cloud)[vertex], camera, dummy_UV);
+      });
 
       if (faceIsVisible)
       {
@@ -1099,4 +1089,3 @@ pcl::TextureMapping<PointInT>::isFaceProjected (const Camera &camera, const Poin
     template class PCL_EXPORTS pcl::TextureMapping<T>;
 
 #endif /* TEXTURE_MAPPING_HPP_ */
-
index 5a499be5077c2597ab44d511ed8ff08c04726fa6..514c2545dc0064fa41cbba7ec16981ee32880d85 100644 (file)
@@ -35,6 +35,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/boost.h>
 #include <pcl/surface/reconstruction.h>
index ebdfb71dc35f3e957e2b59dd9ce14a12193e74a8..3912b177ae220fbec906e955d801a871d6d40b5c 100644 (file)
@@ -35,6 +35,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/boost.h>
 #include <pcl/surface/marching_cubes.h>
@@ -91,7 +92,7 @@ namespace pcl
       /** \brief Method that sets the distance for ignoring voxels which are far from point cloud.
         * If the distance is negative, then the distance functions would be calculated in all voxels;
         * otherwise, only voxels with distance lower than dist_ignore would be involved in marching cube.
-        * \param[in] threshold of distance. Default value is -1.0. Set to negative if all voxels are
+        * \param[in] dist_ignore threshold of distance. Default value is -1.0. Set to negative if all voxels are
         * to be involved.
         */
       inline void
index 22fa923aa6249bb30cf893772a312297cf93cb15..f8b69193591f5445fba7626ba8d87055faa1d76b 100644 (file)
@@ -35,6 +35,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/boost.h>
 #include <pcl/surface/marching_cubes.h>
index 232a3975d591e7f34e0bc105de88fbaf32ac99ca..deca6064472729cf64fb04b6f982a15d85ba68aa 100644 (file)
@@ -44,6 +44,7 @@
 #include <random>
 
 // PCL includes
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/search/pcl_search.h>
@@ -356,7 +357,7 @@ namespace pcl
       /** \brief Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimation.
         * \param[in] polynomial_fit set to true for polynomial fit
         */
-      PCL_DEPRECATED("use setPolynomialOrder() instead")
+      PCL_DEPRECATED(1, 12, "use setPolynomialOrder() instead")
       inline void
       setPolynomialFit (bool polynomial_fit)
       {
@@ -374,7 +375,7 @@ namespace pcl
       }
 
       /** \brief Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial). */
-      PCL_DEPRECATED("use getPolynomialOrder() instead")
+      PCL_DEPRECATED(1, 12, "use getPolynomialOrder() instead")
       inline bool
       getPolynomialFit () const { return (order_ > 1); }
 
@@ -485,7 +486,7 @@ namespace pcl
       getDilationIterations () const { return (dilation_iteration_num_); }
 
       /** \brief Set whether the mls results should be stored for each point in the input cloud
-        * \param[in] True if the mls results should be stored, otherwise false.
+        * \param[in] cache_mls_results True if the mls results should be stored, otherwise false.
         * \note The cache_mls_results_ is forced to true when using upsampling method VOXEL_GRID_DILATION or DISTINCT_CLOUD.
         * \note If memory consumption is a concern set to false when not using upsampling method VOXEL_GRID_DILATION or DISTINCT_CLOUD.
         */
@@ -746,7 +747,7 @@ namespace pcl
   };
 
   template <typename PointInT, typename PointOutT>
-  using MovingLeastSquaresOMP PCL_DEPRECATED("use MovingLeastSquares instead, it supports OpenMP now") = MovingLeastSquares<PointInT, PointOutT>;
+  using MovingLeastSquaresOMP PCL_DEPRECATED(1, 12, "use MovingLeastSquares instead, it supports OpenMP now") = MovingLeastSquares<PointInT, PointOutT>;
 }
 
 #ifdef PCL_NO_PRECOMPILE
index 6752ae8fef90bf0fd01cecaef4ecd23da4ba243c..999c6b3be4cb57143cab2fa11b14dee376220ad5 100644 (file)
@@ -197,12 +197,12 @@ namespace pcl
         return grc2gl (E + i, F + j);
       } // local row/col index to global lexicographic index
       int
-      gl2gr (int A)
+      gl2gr (int A) const
       {
         return (A / m_nurbs.CVCount (1));
       } // global lexicographic in global row index
       int
-      gl2gc (int A)
+      gl2gc (int A) const
       {
         return (A % m_nurbs.CVCount (1));
       } // global lexicographic in global col index
index 41c77bb6cdba53007a50aead4a8c2d5b3cf08c1e..83882168a3c0cb0df923e45be39d73e90921238f 100644 (file)
@@ -175,12 +175,12 @@ namespace pcl
         return grc2gl (E + i, F + j);
       } // local row/col index to global lexicographic index
       int
-      gl2gr (int A)
+      gl2gr (int A) const
       {
         return (A / m_nurbs.CVCount (1));
       } // global lexicographic in global row index
       int
-      gl2gc (int A)
+      gl2gc (int A) const
       {
         return (A % m_nurbs.CVCount (1));
       } // global lexicographic in global col index
index d074c99647a76efd5742a2a3db769d477577b741..3fefdcf3b2d970206ba8f05fd40d82cae2de352a 100644 (file)
@@ -41,6 +41,7 @@
 #include <pcl/surface/on_nurbs/nurbs_data.h>
 #include <pcl/surface/on_nurbs/nurbs_solve.h>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
index d0794e1ca99cd8606e2652658c8412a7a4d2e180..8d6654aabeeae741741e35b948c304d320c369da 100644 (file)
@@ -291,7 +291,7 @@ namespace pcl
 
       // index routines
       int
-      grc2gl (int I, int J)
+      grc2gl (int I, int J) const
       {
         return m_nurbs.CVCount (1) * I + J;
       } // global row/col index to global lexicographic index
@@ -301,12 +301,12 @@ namespace pcl
         return grc2gl (E + i, F + j);
       } // local row/col index to global lexicographic index
       int
-      gl2gr (int A)
+      gl2gr (int A) const
       {
         return (static_cast<int> (A / m_nurbs.CVCount (1)));
       } // global lexicographic in global row index
       int
-      gl2gc (int A)
+      gl2gc (int A) const
       {
         return (static_cast<int> (A % m_nurbs.CVCount (1)));
       } // global lexicographic in global col index
index 9b5a0786e4efdcdc6cb152d41fe3b3169e928c58..7639c0ac444e9a266ae59401e9561229881dae05 100644 (file)
@@ -44,6 +44,7 @@
 #undef Success
 #include <Eigen/StdVector>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
index 89a672aebdf47c3e0b17a8ebc7045e5098592f01..de6ae41d4222be085dbb1ffd7ada707b08ab1415 100644 (file)
@@ -40,6 +40,7 @@
 #undef Success
 #include <Eigen/Dense>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/on_nurbs/sparse_mat.h>
 
index 4796ecfcb550a5ad1f1a99091d01a2ef907e6a17..791310694b9fc7ef4a2f49fc71cf454807362c1b 100644 (file)
@@ -31,7 +31,7 @@
  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
  *
- * 
+ *
  *
  */
 
@@ -50,6 +50,7 @@
 #include <pcl/surface/on_nurbs/fitting_surface_pdm.h>
 #include <pcl/surface/on_nurbs/nurbs_data.h>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
@@ -105,18 +106,18 @@ namespace pcl
         void
         compute_quadfit ();
         void
-        compute_refinement (FittingSurface* fitting);
+        compute_refinement (FittingSurface* fitting) const;
         void
-        compute_boundary (FittingSurface* fitting);
+        compute_boundary (FittingSurface* fitting) const;
         void
-        compute_interior (FittingSurface* fitting);
+        compute_interior (FittingSurface* fitting) const;
 
         Eigen::Vector2d
         project (const Eigen::Vector3d &pt);
 
         bool
-        is_back_facing (const Eigen::Vector3d &v0, 
-                        const Eigen::Vector3d &v1, 
+        is_back_facing (const Eigen::Vector3d &v0,
+                        const Eigen::Vector3d &v1,
                         const Eigen::Vector3d &v2,
                         const Eigen::Vector3d &v3);
 
@@ -149,7 +150,7 @@ namespace pcl
          *  \param[in] intrinsic The camera projection matrix.
          *  \param[in] intrinsic The world matrix.*/
         void
-        setProjectionMatrix (const Eigen::Matrix4d &intrinsic, 
+        setProjectionMatrix (const Eigen::Matrix4d &intrinsic,
                              const Eigen::Matrix4d &extrinsic);
 
         /** \brief Compute point cloud and fit (multiple) models */
@@ -175,27 +176,27 @@ namespace pcl
 
         /** \brief Get error of each interior point (L2-norm of point to closest point on surface) and square-error */
         void
-        getInteriorError (std::vector<double> &error);
+        getInteriorError (std::vector<double> &error) const;
 
         /** \brief Get error of each boundary point (L2-norm of point to closest point on surface) and square-error */
         void
-        getBoundaryError (std::vector<double> &error);
+        getBoundaryError (std::vector<double> &error) const;
 
         /** \brief Get parameter of each interior point */
         void
-        getInteriorParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params);
+        getInteriorParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params) const;
 
         /** \brief Get parameter of each boundary point */
         void
-        getBoundaryParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params);
+        getBoundaryParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params) const;
 
         /** \brief get the normals to the interior points given by setInterior() */
         void
-        getInteriorNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normal);
+        getInteriorNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normal) const;
 
         /** \brief get the normals to the boundary points given by setBoundary() */
         void
-        getBoundaryNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals);
+        getBoundaryNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals) const;
 
         /** \brief Get the closest point on a NURBS from a point pt in parameter space
          *  \param[in] nurbs  The NURBS surface
@@ -204,9 +205,9 @@ namespace pcl
          *  \param[in] maxSteps Maximum iteration steps
          *  \param[in] accuracy Accuracy below which the iterations stop */
         static void
-        getClosestPointOnNurbs (ON_NurbsSurface nurbs, 
-                                const Eigen::Vector3d &pt, 
-                                Eigen::Vector2d& params, 
+        getClosestPointOnNurbs (ON_NurbsSurface nurbs,
+                                const Eigen::Vector3d &pt,
+                                Eigen::Vector2d& params,
                                 int maxSteps = 100,
                                 double accuracy = 1e-4);
 
index b9fe9f0bff6a12db483ed125654e14285dad6288..60312cc5ac5d3d2b73e4ab07523aa25dbc5db5be 100644 (file)
 #pragma once
 
 #include <pcl/common/angles.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/surface/reconstruction.h>
 
+
 namespace pcl
 {
 
index 2aefc1be2cf7ae0cd2f550fa641df35d1df8aee2..0c6ceeaebbee7515596330e3b2d350a6b5cc8630 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/reconstruction.h>
 
index 06161044463f360a485bf6131501bbaeeb3912e1..02f9b5e2c01100c4f0c177133ee8281d6d25c549 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <pcl/surface/boost.h>
 #include <pcl/PolygonMesh.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 namespace pcl
index 59ea2cfdebe680aaf2d286db6922b739f724a3e6..8525008057f8a10deaea6780cc97f757df0caf9d 100644 (file)
@@ -39,6 +39,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/surface/reconstruction.h>
 #include <pcl/common/transforms.h>
index 7bb22a28bebe8acbcd3588451af36d90dd65ea22..3f9884b2725fa78f68e59dd67d3c2cedfe6cf850 100644 (file)
@@ -65,7 +65,7 @@ namespace pcl
 
       /** \brief Get the target reduction factor */
       inline float
-      getTargetReductionFactor ()
+      getTargetReductionFactor () const
       {
         return target_reduction_factor_;
       }
index 67755ca69c14b0c937ba78f9f5474516103af40b..e2edb7710d70f19a503e8bb0aaa08482143f8126 100644 (file)
@@ -73,7 +73,7 @@ namespace pcl
 
       /** \brief Get the number of iterations. */
       inline int
-      getNumIter ()
+      getNumIter () const
       {
         return num_iter_;
       };
@@ -89,7 +89,7 @@ namespace pcl
 
       /** \brief Get the convergence criterion. */
       inline float
-      getConvergence ()
+      getConvergence () const
       {
         return convergence_;
       };
@@ -108,7 +108,7 @@ namespace pcl
 
       /** \brief Get the relaxation factor of the Laplacian smoothing */
       inline float
-      getRelaxationFactor ()
+      getRelaxationFactor () const
       {
         return relaxation_factor_;
       };
@@ -124,7 +124,7 @@ namespace pcl
 
       /** \brief Get the status of the feature edge smoothing */
       inline bool
-      getFeatureEdgeSmoothing ()
+      getFeatureEdgeSmoothing () const
       {
         return feature_edge_smoothing_;
       };
@@ -140,7 +140,7 @@ namespace pcl
 
       /** \brief Get the angle threshold for considering an edge to be sharp */
       inline float
-      getFeatureAngle ()
+      getFeatureAngle () const
       {
         return feature_angle_;
       };
@@ -156,7 +156,7 @@ namespace pcl
 
       /** \brief Get the edge angle to control smoothing along edges */
       inline float
-      getEdgeAngle ()
+      getEdgeAngle () const
       {
         return edge_angle_;
       };
@@ -172,7 +172,7 @@ namespace pcl
 
       /** \brief Get the status of the boundary smoothing */
       inline bool
-      getBoundarySmoothing ()
+      getBoundarySmoothing () const
       {
         return boundary_smoothing_;
       }
index 7780eaadd4616b976d35349cf7d85f207c9804cf..220e17baa006b80eddc5a73fef9e6dd3073ade62 100644 (file)
@@ -73,7 +73,7 @@ namespace pcl
 
       /** \brief Get the number of iterations. */
       inline int
-      getNumIter ()
+      getNumIter () const
       {
         return num_iter_;
       };
@@ -89,7 +89,7 @@ namespace pcl
 
       /** \brief Get the pass band value. */
       inline float
-      getPassBand ()
+      getPassBand () const
       {
         return pass_band_;
       };
@@ -108,7 +108,7 @@ namespace pcl
 
       /** \brief Get whether the coordinate normalization is active or not */
       inline bool
-      getNormalizeCoordinates ()
+      getNormalizeCoordinates () const
       {
         return normalize_coordinates_;
       }
@@ -124,7 +124,7 @@ namespace pcl
 
       /** \brief Get the status of the feature edge smoothing */
       inline bool
-      getFeatureEdgeSmoothing ()
+      getFeatureEdgeSmoothing () const
       {
         return feature_edge_smoothing_;
       };
@@ -140,7 +140,7 @@ namespace pcl
 
       /** \brief Get the angle threshold for considering an edge to be sharp */
       inline float
-      getFeatureAngle ()
+      getFeatureAngle () const
       {
         return feature_angle_;
       };
@@ -156,7 +156,7 @@ namespace pcl
 
       /** \brief Get the edge angle to control smoothing along edges */
       inline float
-      getEdgeAngle ()
+      getEdgeAngle () const
       {
         return edge_angle_;
       };
@@ -173,7 +173,7 @@ namespace pcl
 
       /** \brief Get the status of the boundary smoothing */
       inline bool
-      getBoundarySmoothing ()
+      getBoundarySmoothing () const
       {
         return boundary_smoothing_;
       }
index 1e3d2b083d1eae32ebc601a497fb35dcf1caa240..e9fac7bc39e5684329ecb7523969569e6c54f4d8 100644 (file)
@@ -5822,7 +5822,7 @@ void ON_Annotation2Text::SetText(const wchar_t* s)
 
 // SDKBREAK Oct 30, 07 - LW
 // This function should not be used any longer
-PCL_DEPRECATED("Use the version that takes a model transform argument")
+PCL_DEPRECATED(1, 12, "Use the version that takes a model transform argument")
 bool ON_Annotation2::GetTextXform( 
       ON_RECT /*gdi_text_rect*/,
       const ON_Font& /*font*/,
@@ -5862,7 +5862,7 @@ bool ON_Annotation2::GetTextXform(
 // New function added Oct 30, 07 - LW 
 // To use model xform to draw annotation in blocks correctly
 #if 0
-PCL_DEPRECATED("Use the version that takes a dimstyle pointer")
+PCL_DEPRECATED(1, 12, "Use the version that takes a dimstyle pointer")
 bool ON_Annotation2::GetTextXform( 
       ON_RECT gdi_text_rect,
       const ON_Font& font,
@@ -5991,7 +5991,7 @@ static bool GetLeaderEndAndDirection( const ON_Annotation2* pAnn,
 
 // SDKBREAK Oct 30, 07 - LW
 // This function should not be used any longer
-PCL_DEPRECATED("Use the version that takes a model transform argument")
+PCL_DEPRECATED(1, 12, "Use the version that takes a model transform argument")
 bool ON_Annotation2::GetTextXform( 
       ON_RECT /*gdi_text_rect*/,
       int /*gdi_height_of_I*/,
index 7090b932696e27745d88769704cbb91240001f93..9d5374b8bdcf9646d60ab6beb0cf1cb5d91af392 100644 (file)
@@ -509,10 +509,10 @@ RELATED FUNCTIONS:
 {
   unsigned char stack_buffer[4*64*sizeof(double)];
   double delta_t;
-  register double alpha0;
-  register double alpha1;
-  register double *cv0, *cv1;
-  register int i, j, k; 
+  double alpha0;
+  double alpha1;
+  double *cv0, *cv1;
+  int i, j, k; 
   double* CV, *tmp;
   void* free_me = 0;
   const int degree = order-1;
@@ -733,11 +733,11 @@ RELATED FUNCTIONS:
   TL_EvNurbBasis
   TL_EvNurbBasisDer
 *****************************************************************************/
-  register double a0, a1, x, y;
+  double a0, a1, x, y;
   const double *k0;
   double *t_k, *k_t, *N0;
   const int d = order-1;
-  register int j, r;
+  int j, r;
 
   t_k = (double*)alloca( d<<4 );
   k_t = t_k + d;
diff --git a/surface/src/3rdparty/poisson4/bspline_data.cpp b/surface/src/3rdparty/poisson4/bspline_data.cpp
new file mode 100644 (file)
index 0000000..7c19a76
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2020-, OpenPerception
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of the copyright holder(s) nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <pcl/surface/3rdparty/poisson4/bspline_data.h>
+
+namespace pcl {
+namespace poisson {
+template <>
+void
+BSplineElements<1>::upSample(BSplineElements<1>& high) const
+{
+  high.resize(size() * 2);
+  high.assign(high.size(), BSplineElementCoefficients<1>());
+  for (int i = 0; i < int(size()); i++) {
+    high[2 * i + 0][0] += 1 * (*this)[i][0];
+    high[2 * i + 0][1] += 0 * (*this)[i][0];
+    high[2 * i + 1][0] += 2 * (*this)[i][0];
+    high[2 * i + 1][1] += 1 * (*this)[i][0];
+
+    high[2 * i + 0][0] += 1 * (*this)[i][1];
+    high[2 * i + 0][1] += 2 * (*this)[i][1];
+    high[2 * i + 1][0] += 0 * (*this)[i][1];
+    high[2 * i + 1][1] += 1 * (*this)[i][1];
+  }
+  high.denominator = denominator * 2;
+}
+
+template <>
+void
+BSplineElements<2>::upSample(BSplineElements<2>& high) const
+{
+  /*    /----\
+   *   /      \
+   *  /        \  = 1  /--\       +3    /--\     +3      /--\   +1        /--\
+   * /          \     /    \           /    \           /    \           /    \
+   * |----------|     |----------|   |----------|   |----------|   |----------|
+   */
+
+  high.resize(size() * 2);
+  high.assign(high.size(), BSplineElementCoefficients<2>());
+  for (int i = 0; i < int(size()); i++) {
+    high[2 * i + 0][0] += 1 * (*this)[i][0];
+    high[2 * i + 0][1] += 0 * (*this)[i][0];
+    high[2 * i + 0][2] += 0 * (*this)[i][0];
+    high[2 * i + 1][0] += 3 * (*this)[i][0];
+    high[2 * i + 1][1] += 1 * (*this)[i][0];
+    high[2 * i + 1][2] += 0 * (*this)[i][0];
+
+    high[2 * i + 0][0] += 3 * (*this)[i][1];
+    high[2 * i + 0][1] += 3 * (*this)[i][1];
+    high[2 * i + 0][2] += 1 * (*this)[i][1];
+    high[2 * i + 1][0] += 1 * (*this)[i][1];
+    high[2 * i + 1][1] += 3 * (*this)[i][1];
+    high[2 * i + 1][2] += 3 * (*this)[i][1];
+
+    high[2 * i + 0][0] += 0 * (*this)[i][2];
+    high[2 * i + 0][1] += 1 * (*this)[i][2];
+    high[2 * i + 0][2] += 3 * (*this)[i][2];
+    high[2 * i + 1][0] += 0 * (*this)[i][2];
+    high[2 * i + 1][1] += 0 * (*this)[i][2];
+    high[2 * i + 1][2] += 1 * (*this)[i][2];
+  }
+  high.denominator = denominator * 4;
+}
+} // namespace poisson
+} // namespace pcl
index ea8ffd71b1cfcc3664dc76f0ff73f16bf42c2a33..fcd6846787e9c72f321fb7372e18c35252215b12 100644 (file)
@@ -122,7 +122,7 @@ SequentialFitter::compute_quadfit ()
 }
 
 void
-SequentialFitter::compute_refinement (FittingSurface* fitting)
+SequentialFitter::compute_refinement (FittingSurface* fitting) const
 {
   // Refinement
   FittingSurface::Parameter paramFP (0.0, 1.0, 0.0, m_params.forceBoundary, m_params.stiffnessBoundary, 0.0);
@@ -137,7 +137,7 @@ SequentialFitter::compute_refinement (FittingSurface* fitting)
 }
 
 void
-SequentialFitter::compute_boundary (FittingSurface* fitting)
+SequentialFitter::compute_boundary (FittingSurface* fitting) const
 {
   FittingSurface::Parameter paramFP (0.0, 1.0, 0.0, m_params.forceBoundary, m_params.stiffnessBoundary, 0.0);
 
@@ -149,7 +149,7 @@ SequentialFitter::compute_boundary (FittingSurface* fitting)
   }
 }
 void
-SequentialFitter::compute_interior (FittingSurface* fitting)
+SequentialFitter::compute_interior (FittingSurface* fitting) const
 {
   // iterate interior points
   //std::vector<double> wInt(m_data.interior.PointCount(), m_params.forceInterior);
@@ -420,37 +420,37 @@ SequentialFitter::compute_interior (const ON_NurbsSurface &nurbs)
 }
 
 void
-SequentialFitter::getInteriorError (std::vector<double> &error)
+SequentialFitter::getInteriorError (std::vector<double> &error) const
 {
   error = m_data.interior_error;
 }
 
 void
-SequentialFitter::getBoundaryError (std::vector<double> &error)
+SequentialFitter::getBoundaryError (std::vector<double> &error) const
 {
   error = m_data.boundary_error;
 }
 
 void
-SequentialFitter::getInteriorParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params)
+SequentialFitter::getInteriorParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params) const
 {
   params = m_data.interior_param;
 }
 
 void
-SequentialFitter::getBoundaryParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params)
+SequentialFitter::getBoundaryParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > &params) const
 {
   params = m_data.boundary_param;
 }
 
 void
-SequentialFitter::getInteriorNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals)
+SequentialFitter::getInteriorNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals) const
 {
   normals = m_data.interior_normals;
 }
 
 void
-SequentialFitter::getBoundaryNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals)
+SequentialFitter::getBoundaryNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals) const
 {
   normals = m_data.boundary_normals;
 }
index 5791ec27fcf7a3c74d45cca7675336f61da9127d..c1d8c2ac9156402c84f1d5f7af5f6afb36d503d6 100644 (file)
@@ -26,3 +26,8 @@ PCL_ADD_TEST(test_2d test_2d FILES test_2d.cpp
                        "${PCL_SOURCE_DIR}/test/2d/opening_binary.pcd"
                        "${PCL_SOURCE_DIR}/test/2d/closing_binary.pcd"
                        "${PCL_SOURCE_DIR}/test/2d/canny.pcd")
+
+PCL_ADD_TEST(test_2d_keypoint_instantiation_with_precompile test_2d_keypoint_instantiation_with_precompile FILES keypoint_instantiation.cpp LINK_WITH pcl_gtest pcl_common)
+
+PCL_ADD_TEST(test_2d_keypoint_instantiation_without_precompile test_2d_keypoint_instantiation_without_precompile FILES keypoint_instantiation.cpp LINK_WITH pcl_gtest pcl_common)
+target_compile_definitions(test_2d_keypoint_instantiation_without_precompile PUBLIC PCL_NO_PRECOMPILE)
diff --git a/test/2d/keypoint_instantiation.cpp b/test/2d/keypoint_instantiation.cpp
new file mode 100644 (file)
index 0000000..6b8a915
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ *  Software License Agreement (BSD License)
+ *
+ *  Point Cloud Library (PCL) - www.pointclouds.org
+ *  Copyright (c) 2020-, Open Perception, Inc.
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Willow Garage, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <pcl/2d/keypoint.h> // for pcl::Keypoint
+
+#include <pcl/point_types.h> // for pcl::PointXYZ
+#include <pcl/test/gtest.h>  // for SUCCEED
+
+/** This isn't useful except for testing the instantiation of this class. See #3898 */
+TEST (Keypoint, instantiatesWithAndWithoutPrecompiledHeaders)
+{
+  pcl::Keypoint<pcl::PointXYZ> keypoint = pcl::Keypoint<pcl::PointXYZ>();
+  SUCCEED();
+}
+
+/** --[ */
+int
+main (int argc, char** argv)
+{
+  testing::InitGoogleTest (&argc, argv);
+  return (RUN_ALL_TESTS ());
+}
+/* ]-- */
index 2301318a63a9868673864405b653880987d3212e..b669b589a55063d39c9c9392d49aa702ecf38405 100644 (file)
@@ -67,8 +67,8 @@ using namespace pcl;
 
 TEST (Convolution, borderOptions)
 {
-  kernel<pcl::PointXYZI> *k = new kernel<pcl::PointXYZI> ();
-  Convolution<pcl::PointXYZI> *conv = new Convolution<pcl::PointXYZI> ();
+  kernel<pcl::PointXYZI> k;
+  Convolution<pcl::PointXYZI> conv;
 
   /*dummy clouds*/
   pcl::PointCloud<pcl::PointXYZI>::Ptr input_cloud (new pcl::PointCloud<pcl::PointXYZI>);
@@ -80,14 +80,14 @@ TEST (Convolution, borderOptions)
   int height = input_cloud->height;
   int width = input_cloud->width;
 
-  k->setKernelType(kernel<pcl::PointXYZI>::DERIVATIVE_CENTRAL_X);
-  k->fetchKernel (*kernel_cloud);
+  k.setKernelType(kernel<pcl::PointXYZI>::DERIVATIVE_CENTRAL_X);
+  k.fetchKernel (*kernel_cloud);
 
-  conv->setKernel(*kernel_cloud);
-  conv->setInputCloud(input_cloud);
+  conv.setKernel(*kernel_cloud);
+  conv.setInputCloud(input_cloud);
 
-  conv->setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_MIRROR);
-  conv->filter (*output_cloud);
+  conv.setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_MIRROR);
+  conv.filter (*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, ((*input_cloud)(j+1,i).intensity-(*input_cloud)(j-1,i).intensity), 1);
@@ -98,8 +98,8 @@ TEST (Convolution, borderOptions)
     EXPECT_NEAR ((*output_cloud)(width-1,i).intensity, ((*input_cloud)(width-1,i).intensity-(*input_cloud)(width-2,i).intensity), 1);
   }
 
-  conv->setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_CLAMP);
-  conv->filter (*output_cloud);
+  conv.setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_CLAMP);
+  conv.filter (*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, ((*input_cloud)(j+1,i).intensity-(*input_cloud)(j-1,i).intensity), 1);
@@ -110,8 +110,8 @@ TEST (Convolution, borderOptions)
   //  EXPECT_NEAR ((*output_cloud)(width-1,i).intensity, ((*input_cloud)(width-1,i).intensity-(*input_cloud)(width-2,i).intensity), 1);
   }
 
-  conv->setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_ZERO_PADDING);
-  conv->filter (*output_cloud);
+  conv.setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_ZERO_PADDING);
+  conv.filter (*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, ((*input_cloud)(j+1,i).intensity-(*input_cloud)(j-1,i).intensity), 1);
@@ -125,8 +125,8 @@ TEST (Convolution, borderOptions)
 
 TEST (Convolution, gaussianSmooth)
 {
-  kernel<pcl::PointXYZI> *k = new kernel<pcl::PointXYZI> ();
-  Convolution<pcl::PointXYZI> *conv = new Convolution<pcl::PointXYZI> ();
+  kernel<pcl::PointXYZI> k;
+  Convolution<pcl::PointXYZI> conv;
 
   /*dummy clouds*/
   pcl::PointCloud<pcl::PointXYZI>::Ptr input_cloud (new pcl::PointCloud<pcl::PointXYZI>);
@@ -140,20 +140,19 @@ TEST (Convolution, gaussianSmooth)
   int height = input_cloud->height;
   int width = input_cloud->width;
 
-  k->setKernelType(kernel<pcl::PointXYZI>::GAUSSIAN);
-  k->setKernelSize(3);
-  k->setKernelSigma(1.0f);
-  k->fetchKernel (*kernel_cloud);
+  k.setKernelType(kernel<pcl::PointXYZI>::GAUSSIAN);
+  k.setKernelSize(3);
+  k.setKernelSigma(1.0f);
+  k.fetchKernel (*kernel_cloud);
 
-  conv->setKernel(*kernel_cloud);
-  conv->setInputCloud(input_cloud);
+  conv.setKernel(*kernel_cloud);
+  conv.setInputCloud(input_cloud);
 
-  conv->setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_MIRROR);
-  conv->filter (*output_cloud);
+  conv.setBoundaryOptions(Convolution<pcl::PointXYZI>::BOUNDARY_OPTION_MIRROR);
+  conv.filter (*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, (*gt_output_cloud)(j,i).intensity, 1);
-
 }
 
 TEST(Edge, sobel)
@@ -272,11 +271,11 @@ TEST(Morphology, erosion)
   pcl::io::loadPCDFile(lena, *input_cloud);
   pcl::io::loadPCDFile(erosion_ref, *gt_output_cloud);
 
-  Morphology<pcl::PointXYZI> *morph = new Morphology<pcl::PointXYZI>();
-  morph->setInputCloud(input_cloud);
-  morph->structuringElementRectangle(*structuring_element_cloud, 3, 3);
-  morph->setStructuringElement(structuring_element_cloud);
-  morph->erosionGray(*output_cloud);
+  Morphology<pcl::PointXYZI> morph;
+  morph.setInputCloud(input_cloud);
+  morph.structuringElementRectangle(*structuring_element_cloud, 3, 3);
+  morph.setStructuringElement(structuring_element_cloud);
+  morph.erosionGray(*output_cloud);
 
   int height = input_cloud->height;
   int width = input_cloud->width;
@@ -287,12 +286,11 @@ TEST(Morphology, erosion)
 
   pcl::io::loadPCDFile(erosion_binary_ref, *gt_output_cloud);
   threshold(input_cloud, 100);
-  morph->setInputCloud(input_cloud);
-  morph->erosionBinary(*output_cloud);
+  morph.setInputCloud(input_cloud);
+  morph.erosionBinary(*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, (*gt_output_cloud)(j,i).intensity/255.0, 1);
-
 }
 
 TEST(Morphology, dilation)
@@ -306,11 +304,11 @@ TEST(Morphology, dilation)
   pcl::io::loadPCDFile(lena, *input_cloud);
   pcl::io::loadPCDFile(dilation_ref, *gt_output_cloud);
 
-  Morphology<pcl::PointXYZI> *morph = new Morphology<pcl::PointXYZI>();
-  morph->setInputCloud(input_cloud);
-  morph->structuringElementRectangle(*structuring_element_cloud, 3, 3);
-  morph->setStructuringElement(structuring_element_cloud);
-  morph->dilationGray(*output_cloud);
+  Morphology<pcl::PointXYZI> morph;
+  morph.setInputCloud(input_cloud);
+  morph.structuringElementRectangle(*structuring_element_cloud, 3, 3);
+  morph.setStructuringElement(structuring_element_cloud);
+  morph.dilationGray(*output_cloud);
 
   int height = input_cloud->height;
   int width = input_cloud->width;
@@ -321,8 +319,8 @@ TEST(Morphology, dilation)
 
   pcl::io::loadPCDFile(dilation_binary_ref, *gt_output_cloud);
   threshold(input_cloud, 100);
-  morph->setInputCloud(input_cloud);
-  morph->dilationBinary(*output_cloud);
+  morph.setInputCloud(input_cloud);
+  morph.dilationBinary(*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, (*gt_output_cloud)(j,i).intensity/255.0, 1);
@@ -339,11 +337,11 @@ TEST(Morphology, opening)
   pcl::io::loadPCDFile(lena, *input_cloud);
   pcl::io::loadPCDFile(opening_ref, *gt_output_cloud);
 
-  Morphology<pcl::PointXYZI> *morph = new Morphology<pcl::PointXYZI>();
-  morph->setInputCloud(input_cloud);
-  morph->structuringElementRectangle(*structuring_element_cloud, 3, 3);
-  morph->setStructuringElement(structuring_element_cloud);
-  morph->openingGray(*output_cloud);
+  Morphology<pcl::PointXYZI> morph;
+  morph.setInputCloud(input_cloud);
+  morph.structuringElementRectangle(*structuring_element_cloud, 3, 3);
+  morph.setStructuringElement(structuring_element_cloud);
+  morph.openingGray(*output_cloud);
 
   int height = input_cloud->height;
   int width = input_cloud->width;
@@ -354,8 +352,8 @@ TEST(Morphology, opening)
 
   pcl::io::loadPCDFile(opening_binary_ref, *gt_output_cloud);
   threshold(input_cloud, 100);
-  morph->setInputCloud(input_cloud);
-  morph->openingBinary(*output_cloud);
+  morph.setInputCloud(input_cloud);
+  morph.openingBinary(*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, (*gt_output_cloud)(j,i).intensity/255.0, 1);
@@ -372,11 +370,11 @@ TEST(Morphology, closing)
   pcl::io::loadPCDFile(lena, *input_cloud);
   pcl::io::loadPCDFile(closing_ref, *gt_output_cloud);
 
-  Morphology<pcl::PointXYZI> *morph = new Morphology<pcl::PointXYZI>();
-  morph->setInputCloud(input_cloud);
-  morph->structuringElementRectangle(*structuring_element_cloud, 3, 3);
-  morph->setStructuringElement(structuring_element_cloud);
-  morph->closingGray(*output_cloud);
+  Morphology<pcl::PointXYZI> morph;
+  morph.setInputCloud(input_cloud);
+  morph.structuringElementRectangle(*structuring_element_cloud, 3, 3);
+  morph.setStructuringElement(structuring_element_cloud);
+  morph.closingGray(*output_cloud);
 
   int height = input_cloud->height;
   int width = input_cloud->width;
@@ -387,8 +385,8 @@ TEST(Morphology, closing)
 
   pcl::io::loadPCDFile(closing_binary_ref, *gt_output_cloud);
   threshold(input_cloud, 100);
-  morph->setInputCloud(input_cloud);
-  morph->closingBinary(*output_cloud);
+  morph.setInputCloud(input_cloud);
+  morph.closingBinary(*output_cloud);
   for (int i = 1; i < height - 1; i++)
     for (int j = 1; j < width - 1; j++)
       EXPECT_NEAR ((*output_cloud)(j,i).intensity, (*gt_output_cloud)(j,i).intensity/255.0, 1);
index ad5492cf82b13093f6a03a76c16dc9a3324300aa..3da1ebea60455c33ff54a769d6e77faf686e3e00 100644 (file)
@@ -3,6 +3,7 @@ set(SUBSYS_DESC "Point cloud library global unit tests")
 
 set(DEFAULT OFF)
 set(build TRUE)
+set(REASON "Disabled by default")
 PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ${DEFAULT} "${REASON}")
 PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS ${OPT_DEPS})
 
@@ -22,7 +23,7 @@ if(MSVC)
   add_custom_target(tests "${CMAKE_CTEST_COMMAND}" -C $<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release> -V -T Test VERBATIM)
 else()
   add_custom_target(tests "${CMAKE_CTEST_COMMAND}" -V -T Test VERBATIM)
-endif()  
+endif()
 
 set_target_properties(tests PROPERTIES FOLDER "Tests")
 
index 74026aec8bbe02322a4112dbbe64dca3fa19ca81..9ad268f7c131c96cf2ee8de87d809ebbc13dfee5 100644 (file)
@@ -40,7 +40,6 @@
 #include <pcl/test/gtest.h>
 #include <pcl/pcl_tests.h>
 #include <pcl/point_types.h>
-#include <pcl/common/point_operators.h>
 #include <pcl/common/intensity.h>
 
 using namespace pcl;
index e42c78f8b14d39cf91a33c7b1889ea59179e46a5..86ce0d95dbd38455c6e84ce527931c43445d2064 100644 (file)
@@ -130,6 +130,11 @@ TEST (PCL, copyPointCloud)
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
+// Ignore unknown pragma warning on MSVC (4996)
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4068)
+#endif
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #pragma GCC diagnostic push
 TEST (PCL, concatenatePointCloud)
@@ -317,6 +322,9 @@ TEST (PCL, concatenatePointCloud)
   }
 }
 #pragma GCC diagnostic pop
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 TEST (PCL, concatenatePointCloud2)
index fdd43f79c257a56e4ebc185e8c8f226c0400fe6c..6208e505a4dc8522e3787257307751ad713a2147 100644 (file)
@@ -38,7 +38,6 @@
 #include <pcl/test/gtest.h>
 #include <pcl/pcl_tests.h>
 #include <pcl/point_types.h>
-#include <pcl/common/point_operators.h>
 
 using namespace pcl;
 using namespace pcl::test;
index b58e8fb9b2fd1a82c297fb5fd753c176592743c8..94bf64edd317c9d227188ab1f6b7e1369f5e7c6b 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <pcl/test/gtest.h>
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
index a2bace35a31c8dc97f6046a9b4ad153eee6cbbee..637af7323318639acb2fda1b9f29e13d620aa52b 100644 (file)
  */
 
 
-#include <pcl/point_traits.h>
+#include <pcl/memory.h>  // for pcl::has_custom_allocator, PCL_MAKE_ALIGNED_OPERATOR_NEW
+#include <pcl/type_traits.h>
 #include <pcl/point_types.h>
+#include <pcl/common/point_tests.h> // for pcl::isXYFinite, pcl::isXYZFinite, pcl::isNormalFinite
 
 #include <pcl/test/gtest.h>
 
@@ -46,7 +48,15 @@ TEST (TypeTraits, HasCustomAllocatorTrait)
   struct Foo
   {
   public:
+    // Manually ignore warnings here because of an issue in Eigen which
+    // results in a local typedef being unused inside the new and delete
+    // operators added by Eigen for C++14 or lower standards
+    /** \todo Remove for C++17 (or future standards)
+     */
+    #pragma clang diagnostic push
+    #pragma clang diagnostic ignored "-Wunused-local-typedef"
     PCL_MAKE_ALIGNED_OPERATOR_NEW
+    #pragma clang diagnostic pop
   };
 
   struct Bar
index ba1ea939a7b4f7cf18bbf556d1d913c79e78b072..4f4cef3f658aa48f42b68f8f5824627c72f36b45 100644 (file)
@@ -308,7 +308,7 @@ TEST (PCL, IntegralImageNormalEstimationIndexingIssue)
 
   pcl::IndicesPtr indicesptr (new pcl::Indices ());
   indicesptr->resize(cloudptr->size() / 2);
-  for (int i = 0; i < cloudptr->size() / 2; ++i)
+  for (std::size_t i = 0; i < cloudptr->size() / 2; ++i)
   {
     (*indicesptr)[i] = i + cloudptr->size() / 2;
   }
@@ -328,7 +328,7 @@ TEST (PCL, IntegralImageNormalEstimationIndexingIssue)
 
   std::vector<PointXYZ> normalsVec;
   normalsVec.resize(normals->size());
-  for( int i = 0; i < normals->size(); ++i )
+  for(std::size_t i = 0; i < normals->size(); ++i )
   {
     normalsVec[i].x = normals->points[i].normal_x;
     normalsVec[i].y = normals->points[i].normal_y;
index 98485104d89bf1d5d3d15a13fb17e22a499279c8..dd518002bcd72f682bd0925ec618716caa1abb30 100644 (file)
@@ -39,6 +39,8 @@
  */
 
 #include <pcl/test/gtest.h>
+#include <pcl/memory.h>  // for pcl::make_shared
+#include <pcl/pcl_base.h>  // for pcl::Indices
 #include <pcl/pcl_tests.h>
 #include <pcl/point_types.h>
 #include <pcl/filters/box_clipper3D.h>
@@ -71,7 +73,7 @@ TEST (BoxClipper3D, Filters)
   input->push_back (PointXYZ (-0.9f, -0.9f, -0.9f));
 
   ExtractIndices<PointXYZ> extract_indices;
-  std::vector<int> indices;
+  pcl::Indices indices;
 
   BoxClipper3D<PointXYZ> boxClipper3D (Affine3f::Identity ());
   boxClipper3D.clipPointCloud3D (*input, indices);
@@ -79,7 +81,7 @@ TEST (BoxClipper3D, Filters)
   PointCloud<PointXYZ> cloud_out;
 
   extract_indices.setInputCloud (input);
-  extract_indices.setIndices (boost::make_shared<vector<int> > (indices));
+  extract_indices.setIndices (pcl::make_shared<pcl::Indices> (indices));
   extract_indices.filter (cloud_out);
 
   EXPECT_EQ (int (indices.size ()), 9);
index d2bb3a62a22ddad03f7e93f6ba135361dcbd61d7..fe429bba6f0cb5c6c6c973b9f2738b71ff10e3b1 100644 (file)
@@ -266,7 +266,7 @@ TEST (ExtractIndices, Filters)
   ps.setFilterLimits (0.99, 2.01);
   for (int i = 0; i < 2; i++)
   {
-    ps.setFilterLimitsNegative ((bool)i);
+    ps.setNegative ((bool)i);
     ps.filter (scf);
     std::cerr << scf.points.size () << std::endl;
     for (std::size_t j = 0; j < scf.points.size (); ++j)
@@ -306,7 +306,7 @@ TEST (PassThrough, Filters)
   EXPECT_NEAR (output.points[41].y, 0.039749, 1e-5);
   EXPECT_NEAR (output.points[41].z, 0.052133, 1e-5);
 
-  pt.setFilterLimitsNegative (true);
+  pt.setNegative (true);
   pt.filter (output);
 
   EXPECT_EQ (int (output.points.size ()), 355);
@@ -350,7 +350,7 @@ TEST (PassThrough, Filters)
   EXPECT_NEAR (output.points[41].y, 0.039749, 1e-5);
   EXPECT_NEAR (output.points[41].z, 0.052133, 1e-5);
 
-  pt_.setFilterLimitsNegative (true);
+  pt_.setNegative (true);
   pt_.filter (output);
 
   EXPECT_EQ (int (output.points.size ()), 355);
@@ -380,7 +380,7 @@ TEST (PassThrough, Filters)
   EXPECT_NEAR (output.points[output.points.size () - 1].x, cloud->points[cloud->points.size () - 1].x, 1e-5);
 
   pt.setFilterFieldName ("z");
-  pt.setFilterLimitsNegative (false);
+  pt.setNegative (false);
   pt.setKeepOrganized (true);
   pt.filter (output);
 
@@ -396,7 +396,7 @@ TEST (PassThrough, Filters)
   EXPECT_TRUE (std::isnan (output.points[41].y));
   EXPECT_TRUE (std::isnan (output.points[41].z));
 
-  pt.setFilterLimitsNegative (true);
+  pt.setNegative (true);
   pt.filter (output);
 
   EXPECT_EQ (output.points.size (), cloud->points.size ());
index 04dacaada10f447b339ecea40620e80dd05a6dac..76cb2cfbf95f0a89a90840a56c1ade708ef3d31b 100644 (file)
@@ -105,31 +105,44 @@ TEST (CovarianceSampling, Filters)
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 TEST (NormalSpaceSampling, Filters)
 {
+  // pcl::Normal is not precompiled by default so we use PointNormal
+  auto cloud = pcl::make_shared<PointCloud<PointNormal>> ();
+  // generate 16 points (8 unique) with unit norm
+  cloud->reserve (16);
+  // ensure that the normals have unit norm
+  const auto value = std::sqrt(1/3.f);
+  for (int unique = 0; unique < 8; ++unique) {
+    const auto i = ((unique % 2) < 1) ? -1 : 1;  // points alternate sign
+    const auto j = ((unique % 4) < 2) ? -1 : 1;  // 2 points negative, 2 positive
+    const auto k = ((unique % 8) < 4) ? -1 : 1;  // first 4 points negative, rest positive
+    for (int duplicate = 0; duplicate < 2; ++duplicate) {
+      cloud->emplace_back (0.f, 0.f, 0.f, i * value,  j * value, k * value);
+    }
+  }
+
   NormalSpaceSampling<PointNormal, PointNormal> normal_space_sampling;
-  normal_space_sampling.setInputCloud (cloud_walls_normals);
-  normal_space_sampling.setNormals (cloud_walls_normals);
-  normal_space_sampling.setBins (4, 4, 4);
+  normal_space_sampling.setInputCloud (cloud);
+  normal_space_sampling.setNormals (cloud);
+  normal_space_sampling.setBins (2, 2, 2);
   normal_space_sampling.setSeed (0);
-  normal_space_sampling.setSample (static_cast<unsigned int> (cloud_walls_normals->size ()) / 4);
+  normal_space_sampling.setSample (8);
 
-  IndicesPtr walls_indices (new std::vector<int> ());
+  IndicesPtr walls_indices  = pcl::make_shared<Indices> ();
   normal_space_sampling.filter (*walls_indices);
 
-  CovarianceSampling<PointNormal, PointNormal> covariance_sampling;
-  covariance_sampling.setInputCloud (cloud_walls_normals);
-  covariance_sampling.setNormals (cloud_walls_normals);
-  covariance_sampling.setIndices (walls_indices);
-  covariance_sampling.setNumberOfSamples (0);
-  double cond_num_walls_sampled = covariance_sampling.computeConditionNumber ();
-
+  // The orientation space of the normals is divided into 2x2x2 buckets
+  // points are samples arbitrarily from each bucket in succession until the
+  // requested number of samples is met. This means we expect to see only one index
+  // for every two elements in the original array e.g. 0, 3, 4, 6, etc...
+  // if 0 is sampled, index 1 can no longer be there and so forth
+  std::array<std::set<index_t>, 8> buckets;
+  for (const auto index : *walls_indices)
+    buckets[index/2].insert (index);
 
-  EXPECT_NEAR (33.04893, cond_num_walls_sampled, 1e-1);
 
-  EXPECT_EQ (1412, (*walls_indices)[0]);
-  EXPECT_EQ (1943, (*walls_indices)[walls_indices->size () / 4]);
-  EXPECT_EQ (2771, (*walls_indices)[walls_indices->size () / 2]);
-  EXPECT_EQ (3215, (*walls_indices)[walls_indices->size () * 3 / 4]);
-  EXPECT_EQ (2503, (*walls_indices)[walls_indices->size () - 1]);
+  EXPECT_EQ (8u, walls_indices->size ());
+  for (const auto& bucket : buckets)
+    EXPECT_EQ (1u, bucket.size ());
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
index 5c4ba54014a65378b14ed9067f5e5089f5c16fe2..5a615b388f01abcb2af9a42e963be66979def820 100644 (file)
@@ -41,6 +41,7 @@
 #include <pcl/test/gtest.h>
 
 #include <pcl/geometry/triangle_mesh.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 
 #include "test_mesh_common_functions.h"
index 1e95033a67d6ed950d0449643ef2270eb0745d17..93ae1d5d328b38013be7ebb5e7401f20f80ba3ed 100644 (file)
@@ -44,6 +44,7 @@
 #include <pcl/geometry/quad_mesh.h>
 #include <pcl/geometry/polygon_mesh.h>
 #include <pcl/geometry/mesh_conversion.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
index dca0a776e1fd05caa4c625ff9cd372af0e00efc1..d1cb5c652f18a0e68594099e2d41658e6c6c39aa 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <pcl/test/gtest.h>
 #include <pcl/PCLPointCloud2.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <pcl/point_types.h>
 #include <pcl/common/io.h>
 #include <pcl/console/print.h>
index fcbc87820206c4e19b256560f93ccbdbb48c2486..f2c90aab877bd61504ea8011ec2eeebda7a564ef 100644 (file)
@@ -63,8 +63,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA)
   for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR;
     compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) {
     // instantiate point cloud compression encoder/decoder
-    pcl::io::OctreePointCloudCompression<pcl::PointXYZRGBA>* pointcloud_encoder = new pcl::io::OctreePointCloudCompression<pcl::PointXYZRGBA>((pcl::io::compression_Profiles_e) compression_profile, false);
-    pcl::io::OctreePointCloudCompression<pcl::PointXYZRGBA>* pointcloud_decoder = new pcl::io::OctreePointCloudCompression<pcl::PointXYZRGBA>();
+    pcl::io::OctreePointCloudCompression<pcl::PointXYZRGBA> pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false);
+    pcl::io::OctreePointCloudCompression<pcl::PointXYZRGBA> pointcloud_decoder;
     pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_out(new pcl::PointCloud<pcl::PointXYZRGBA>());
     // iterate over runs
     for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++)
@@ -98,8 +98,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA)
 
 //        std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count;
         std::stringstream compressed_data;
-        pointcloud_encoder->encodePointCloud(cloud, compressed_data);
-        pointcloud_decoder->decodePointCloud(compressed_data, cloud_out);
+        pointcloud_encoder.encodePointCloud(cloud, compressed_data);
+        pointcloud_decoder.decodePointCloud(compressed_data, cloud_out);
         EXPECT_GT((int)cloud_out->width, 0) << "decoded PointCloud width <= 0";
         EXPECT_GT((int)cloud_out->height, 0) << " decoded PointCloud height <= 0 ";
       }
@@ -120,8 +120,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZ)
         compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile)
   {
     // instantiate point cloud compression encoder/decoder
-    pcl::io::OctreePointCloudCompression<pcl::PointXYZ>* pointcloud_encoder = new pcl::io::OctreePointCloudCompression<pcl::PointXYZ>((pcl::io::compression_Profiles_e) compression_profile, false);
-    pcl::io::OctreePointCloudCompression<pcl::PointXYZ>* pointcloud_decoder = new pcl::io::OctreePointCloudCompression<pcl::PointXYZ>();
+    pcl::io::OctreePointCloudCompression<pcl::PointXYZ> pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false);
+    pcl::io::OctreePointCloudCompression<pcl::PointXYZ> pointcloud_decoder;
     pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out(new pcl::PointCloud<pcl::PointXYZ>());
     // loop over runs
     for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++)
@@ -143,8 +143,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZ)
       std::stringstream compressed_data;
       try
       { // decodePointCloud() throws exceptions on errors
-        pointcloud_encoder->encodePointCloud(cloud, compressed_data);
-        pointcloud_decoder->decodePointCloud(compressed_data, cloud_out);
+        pointcloud_encoder.encodePointCloud(cloud, compressed_data);
+        pointcloud_decoder.decodePointCloud(compressed_data, cloud_out);
         EXPECT_GT((int)cloud_out->width, 0) << "decoded PointCloud width <= 0";
         EXPECT_GT((int)cloud_out->height, 0) << " decoded PointCloud height <= 0 ";
       }
index 360976d648bcd4dbac56e41f2cc40fc0af6d2faa..a6dd6f1cb1289ac2fa6dc396754e0d371d0b490f 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <pcl/test/gtest.h>
 #include <pcl/PCLPointCloud2.h>
-#include <pcl/point_traits.h>
+#include <pcl/type_traits.h>
 #include <pcl/point_types.h>
 #include <pcl/common/io.h>
 #include <pcl/console/print.h>
index c2f09d55eaa88b99bf42c80d8de01d3b68150b4a..0de67ac123b976143c326af2bc270552308a5610 100644 (file)
  *
  */
 
-#include <pcl/test/gtest.h>
-#include <iostream>  // For debug
-#include <map>
-#include <pcl/common/time.h>
+#include <pcl/kdtree/impl/kdtree_flann.hpp>
+
 #include <pcl/point_cloud.h>
 #include <pcl/point_types.h>
 #include <pcl/common/distances.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+#include <pcl/common/time.h>
 #include <pcl/io/pcd_io.h>
-#include <pcl/kdtree/impl/kdtree_flann.hpp>
+#include <pcl/test/gtest.h>
+
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/xml_parser.hpp>
 
+#include <iostream>  // For debug
+#include <map>
+
 
 using namespace std;
 using namespace pcl;
index a8cd9eb2b7c6b6ed85f04cc3e42e94c3e15979e9..f05cf49523cd6ad3324f3cde4d321a01914113eb 100644 (file)
@@ -154,6 +154,48 @@ TEST (PCL, findFeatureCorrespondences)
 */
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// This test if the ICP algorithm can successfully find the transformation of a cloud that has been
+// moved 0.7 in x direction.
+// It indirectly test the KDTree doesn't get an empty input cloud, see #3624
+// It is more or less a copy of https://github.com/PointCloudLibrary/pcl/blob/cc7fe363c6463a0abc617b1e17e94ab4bd4169ef/doc/tutorials/content/sources/iterative_closest_point/iterative_closest_point.cpp
+TEST(PCL, ICP_translated)
+{
+  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in(new pcl::PointCloud<pcl::PointXYZ>(5,1));
+  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out(new pcl::PointCloud<pcl::PointXYZ>);
+
+  // Fill in the CloudIn data
+  for (auto& point : *cloud_in)
+  {
+    point.x = 1024 * rand() / (RAND_MAX + 1.0f);
+    point.y = 1024 * rand() / (RAND_MAX + 1.0f);
+    point.z = 1024 * rand() / (RAND_MAX + 1.0f);
+  }
+
+  *cloud_out = *cloud_in;
+
+  for (auto& point : *cloud_out)
+    point.x += 0.7f;
+
+  pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
+  icp.setInputSource(cloud_in);
+  icp.setInputTarget(cloud_out);
+
+  pcl::PointCloud<pcl::PointXYZ> Final;
+  icp.align(Final);
+
+  // Check that we have sucessfully converged
+  ASSERT_EQ(icp.hasConverged(), true);
+
+  // Test that the fitness score is below acceptable threshold
+  EXPECT_LT(icp.getFitnessScore(), 1e-6);
+
+  // Ensure that the translation found is within acceptable threshold.
+  EXPECT_NEAR(icp.getFinalTransformation()(0, 3), 0.7, 2e-3);
+  EXPECT_NEAR(icp.getFinalTransformation()(1, 3), 0.0, 2e-3);
+  EXPECT_NEAR(icp.getFinalTransformation()(2, 3), 0.0, 2e-3);
+}
+
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 TEST (PCL, IterativeClosestPoint)
 {
@@ -169,26 +211,26 @@ TEST (PCL, IterativeClosestPoint)
   reg.align (cloud_reg);
   EXPECT_EQ (int (cloud_reg.points.size ()), int (cloud_source.points.size ()));
 
-  //Eigen::Matrix4f transformation = reg.getFinalTransformation ();
-//  EXPECT_NEAR (transformation (0, 0), 0.8806,  1e-3);
-//  EXPECT_NEAR (transformation (0, 1), 0.036481287330389023, 1e-2);
-//  EXPECT_NEAR (transformation (0, 2), -0.4724, 1e-3);
-//  EXPECT_NEAR (transformation (0, 3), 0.03453, 1e-3);
-//
-//  EXPECT_NEAR (transformation (1, 0), -0.02354,  1e-3);
-//  EXPECT_NEAR (transformation (1, 1),  0.9992,   1e-3);
-//  EXPECT_NEAR (transformation (1, 2),  0.03326,  1e-3);
-//  EXPECT_NEAR (transformation (1, 3), -0.001519, 1e-3);
-//
-//  EXPECT_NEAR (transformation (2, 0),  0.4732,  1e-3);
-//  EXPECT_NEAR (transformation (2, 1), -0.01817, 1e-3);
-//  EXPECT_NEAR (transformation (2, 2),  0.8808,  1e-3);
-//  EXPECT_NEAR (transformation (2, 3),  0.04116, 1e-3);
-//
-//  EXPECT_EQ (transformation (3, 0), 0);
-//  EXPECT_EQ (transformation (3, 1), 0);
-//  EXPECT_EQ (transformation (3, 2), 0);
-//  EXPECT_EQ (transformation (3, 3), 1);
+  Eigen::Matrix4f transformation = reg.getFinalTransformation ();
+  EXPECT_NEAR (transformation (0, 0), 0.8806,  1e-3);
+  EXPECT_NEAR (transformation (0, 1), 0.036481287330389023, 1e-2);
+  EXPECT_NEAR (transformation (0, 2), -0.4724, 1e-3);
+  EXPECT_NEAR (transformation (0, 3), 0.03453, 1e-3);
+
+  EXPECT_NEAR (transformation (1, 0), -0.02354,  1e-3);
+  EXPECT_NEAR (transformation (1, 1),  0.9992,   1e-3);
+  EXPECT_NEAR (transformation (1, 2),  0.03326,  1e-3);
+  EXPECT_NEAR (transformation (1, 3), -0.001519, 1e-3);
+
+  EXPECT_NEAR (transformation (2, 0),  0.4732,  1e-3);
+  EXPECT_NEAR (transformation (2, 1), -0.01817, 1e-3);
+  EXPECT_NEAR (transformation (2, 2),  0.8808,  1e-3);
+  EXPECT_NEAR (transformation (2, 3),  0.04116, 1e-3);
+
+  EXPECT_EQ (transformation (3, 0), 0);
+  EXPECT_EQ (transformation (3, 1), 0);
+  EXPECT_EQ (transformation (3, 2), 0);
+  EXPECT_EQ (transformation (3, 3), 1);
 }
 
 TEST (PCL, IterativeClosestPointWithNormals)
index 66087a743ba0c2d72d4b5caee1f4f0627bc9715c..97ead7816fa1f1dc4a817e20c7f999cc120206e7 100644 (file)
@@ -106,7 +106,7 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search)
   std::priority_queue<prioPointQueueEntry, std::vector<prioPointQueueEntry, Eigen::aligned_allocator<prioPointQueueEntry> > > pointCandidates;
 
   // create octree
-  pcl::search::Search<PointXYZ>* octree = new  pcl::search::AutotunedSearch<PointXYZ>(pcl::search::OCTREE);
+  pcl::search::Search<PointXYZ> octree(pcl::search::OCTREE);
 
   std::vector<int> k_indices;
   std::vector<float> k_sqr_distances;
@@ -166,8 +166,8 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search)
     }
 
     // octree nearest neighbor search
-    octree->setInputCloud (cloudIn);
-    octree->nearestKSearch (searchPoint, (int)K, k_indices, k_sqr_distances);
+    octree.setInputCloud (cloudIn);
+    octree.nearestKSearch (searchPoint, (int)K, k_indices, k_sqr_distances);
 
     ASSERT_EQ ( k_indices.size() , k_indices_bruteforce.size() );
 
@@ -260,8 +260,8 @@ TEST (PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search)
 TEST (PCL, KdTreeWrapper_nearestKSearch)
 {
 
-  pcl::search::Search<PointXYZ>* kdtree = new pcl::search::AutotunedSearch<PointXYZ>(pcl::search::KDTREE);
-  kdtree->setInputCloud (cloud.makeShared ());
+  pcl::search::Search<PointXYZ> kdtree(pcl::search::KDTREE);
+  kdtree.setInputCloud (cloud.makeShared ());
   PointXYZ test_point (0.01f, 0.01f, 0.01f);
   unsigned int no_of_neighbors = 20;
   multimap<float, int> sorted_brute_force_result;
@@ -283,7 +283,7 @@ TEST (PCL, KdTreeWrapper_nearestKSearch)
   std::vector<float> k_distances;
   k_distances.resize (no_of_neighbors);
 
-  kdtree->nearestKSearch (test_point, no_of_neighbors, k_indices, k_distances);
+  kdtree.nearestKSearch (test_point, no_of_neighbors, k_indices, k_distances);
 
   EXPECT_EQ (k_indices.size (), no_of_neighbors);
 
@@ -301,20 +301,19 @@ TEST (PCL, KdTreeWrapper_nearestKSearch)
 
   ScopeTime scopeTime ("FLANN nearestKSearch");
   {
-    pcl::search::Search<PointXYZ>* kdtree = new pcl::search::AutotunedSearch<PointXYZ>(pcl::search::KDTREE);
-    //kdtree->initSearchDS ();
-    kdtree->setInputCloud (cloud_big.makeShared ());
+    pcl::search::AutotunedSearch<PointXYZ> kdtree (pcl::search::KDTREE);
+    //kdtree.initSearchDS ();
+    kdtree.setInputCloud (cloud_big.makeShared ());
     for (std::size_t i = 0; i < cloud_big.points.size (); ++i)
-      kdtree->nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
+      kdtree.nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
   }
-
 }      
 
 
 /* Function to auto evaluate the best search structure for the given dataset */
 TEST (PCL, AutoTunedSearch_Evaluate)
 {
-  pcl::search::Search<PointXYZ>* search = new pcl::search::AutotunedSearch<PointXYZ>(pcl::search::AUTO_TUNED);
+  pcl::search::AutotunedSearch<PointXYZ> search (pcl::search::AUTO_TUNED);
 
   pcl::PCDReader pcd;
   pcl::PointCloud<PointXYZ>::Ptr cloudIn (new pcl::PointCloud<PointXYZ>);
@@ -325,8 +324,8 @@ TEST (PCL, AutoTunedSearch_Evaluate)
     return;
   }
 
- search->evaluateSearchMethods (cloudIn, pcl::search::NEAREST_K_SEARCH);
- search->evaluateSearchMethods (cloudIn, pcl::search::NEAREST_RADIUS_SEARCH);
+ search.evaluateSearchMethods (cloudIn, pcl::search::NEAREST_K_SEARCH);
+ search.evaluateSearchMethods (cloudIn, pcl::search::NEAREST_RADIUS_SEARCH);
 }
 
 
@@ -338,8 +337,8 @@ main(int argc, char** argv)
   init ();
 
   // Testing using explicit instantiation of inherited class
-  pcl::search::Search<PointXYZ>* kdtree = new pcl::search::AutotunedSearch<PointXYZ>(pcl::search::KDTREE);
-  kdtree->setInputCloud (cloud.makeShared ());
+  pcl::search::AutotunedSearch<PointXYZ> kdtree(pcl::search::KDTREE);
+  kdtree.setInputCloud (cloud.makeShared ());
 
   return (RUN_ALL_TESTS ());
 };
index df666e67fa3cd47a29e1fc03631dd25a44a3bff4..c283309722530a9b81583bce59c505fbc0e4b841 100644 (file)
@@ -76,8 +76,8 @@ init ()
 /* Test for FlannSearch nearestKSearch */
 TEST (PCL, FlannSearch_nearestKSearch)
 {
-  pcl::search::Search<PointXYZ>* FlannSearch = new pcl::search::FlannSearch<PointXYZ> (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
-  FlannSearch->setInputCloud (cloud.makeShared ());
+  pcl::search::FlannSearch<PointXYZ> FlannSearch (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
+  FlannSearch.setInputCloud (cloud.makeShared ());
   PointXYZ test_point (0.01f, 0.01f, 0.01f);
   unsigned int no_of_neighbors = 20;
   multimap<float, int> sorted_brute_force_result;
@@ -100,7 +100,7 @@ TEST (PCL, FlannSearch_nearestKSearch)
   std::vector<float> k_distances;
   k_distances.resize (no_of_neighbors);
 
-  FlannSearch->nearestKSearch (test_point, no_of_neighbors, k_indices, k_distances);
+  FlannSearch.nearestKSearch (test_point, no_of_neighbors, k_indices, k_distances);
 
   //if (k_indices.size () != no_of_neighbors)  std::cerr << "Found "<<k_indices.size ()<<" instead of "<<no_of_neighbors<<" neighbors.\n";
   EXPECT_EQ (k_indices.size (), no_of_neighbors);
@@ -119,11 +119,11 @@ TEST (PCL, FlannSearch_nearestKSearch)
 
   ScopeTime scopeTime ("FLANN nearestKSearch");
   {
-    pcl::search::Search<PointXYZ>* FlannSearch = new pcl::search::FlannSearch<PointXYZ>( new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
-    //FlannSearch->initSearchDS ();
-    FlannSearch->setInputCloud (cloud_big.makeShared ());
+    pcl::search::FlannSearch<PointXYZ> FlannSearch( new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
+    //FlannSearch.initSearchDS ();
+    FlannSearch.setInputCloud (cloud_big.makeShared ());
     for (const auto &point : cloud_big.points)
-      FlannSearch->nearestKSearch (point, no_of_neighbors, k_indices, k_distances);
+      FlannSearch.nearestKSearch (point, no_of_neighbors, k_indices, k_distances);
   }
 }
 
@@ -133,9 +133,9 @@ TEST (PCL, FlannSearch_differentPointT)
 
   unsigned int no_of_neighbors = 20;
 
-  pcl::search::Search<PointXYZ>* FlannSearch = new pcl::search::FlannSearch<PointXYZ> (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
-  //FlannSearch->initSearchDS ();
-  FlannSearch->setInputCloud (cloud_big.makeShared ());
+  pcl::search::FlannSearch<PointXYZ> FlannSearch (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
+  //FlannSearch.initSearchDS ();
+  FlannSearch.setInputCloud (cloud_big.makeShared ());
 
   PointCloud<PointXYZRGB> cloud_rgb;
 
@@ -145,7 +145,7 @@ TEST (PCL, FlannSearch_differentPointT)
 
   std::vector< std::vector< float > > dists;
   std::vector< std::vector< int > > indices;
-  FlannSearch->nearestKSearchT (cloud_rgb, std::vector<int> (),no_of_neighbors,indices,dists);
+  FlannSearch.nearestKSearchT (cloud_rgb, std::vector<int> (),no_of_neighbors,indices,dists);
 
   std::vector<int> k_indices;
   k_indices.resize (no_of_neighbors);
@@ -159,8 +159,8 @@ TEST (PCL, FlannSearch_differentPointT)
 
   for (std::size_t i = 0; i < cloud_rgb.points.size (); ++i)
   {
-    //FlannSearch->nearestKSearchT (cloud_rgb.points[i], no_of_neighbors, k_indices_t, k_distances_t);
-    FlannSearch->nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
+    //FlannSearch.nearestKSearchT (cloud_rgb.points[i], no_of_neighbors, k_indices_t, k_distances_t);
+    FlannSearch.nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
     EXPECT_EQ (k_indices.size (), indices[i].size ());
     EXPECT_EQ (k_distances.size (), dists[i].size ());
     for (std::size_t j = 0; j< no_of_neighbors; j++)
@@ -180,13 +180,13 @@ TEST (PCL, FlannSearch_multipointKnnSearch)
   unsigned int no_of_neighbors = 20;
 
 
-  pcl::search::Search<PointXYZ>* FlannSearch = new pcl::search::FlannSearch<PointXYZ> (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
-  //FlannSearch->initSearchDS ();
-  FlannSearch->setInputCloud (cloud_big.makeShared ());
+  pcl::search::FlannSearch<PointXYZ> FlannSearch (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
+  //FlannSearch.initSearchDS ();
+  FlannSearch.setInputCloud (cloud_big.makeShared ());
 
   std::vector< std::vector< float > > dists;
   std::vector< std::vector< int > > indices;
-  FlannSearch->nearestKSearch (cloud_big, std::vector<int>(),no_of_neighbors,indices,dists);
+  FlannSearch.nearestKSearch (cloud_big, std::vector<int>(),no_of_neighbors,indices,dists);
 
   std::vector<int> k_indices;
   k_indices.resize (no_of_neighbors);
@@ -195,7 +195,7 @@ TEST (PCL, FlannSearch_multipointKnnSearch)
 
   for (std::size_t i = 0; i < cloud_big.points.size (); ++i)
   {
-    FlannSearch->nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
+    FlannSearch.nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
     EXPECT_EQ (k_indices.size (), indices[i].size ());
     EXPECT_EQ (k_distances.size (), dists[i].size ());
     for (std::size_t j = 0; j< no_of_neighbors; j++ )
@@ -213,9 +213,9 @@ TEST (PCL, FlannSearch_knnByIndex)
   unsigned int no_of_neighbors = 3;
 
 
-  pcl::search::Search<PointXYZ>* flann_search = new pcl::search::FlannSearch<PointXYZ> (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
+  pcl::search::FlannSearch<PointXYZ> flann_search (new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
   //FlannSearch->initSearchDS ();
-  flann_search->setInputCloud (cloud_big.makeShared ());
+  flann_search.setInputCloud (cloud_big.makeShared ());
 
   std::vector< std::vector< float > > dists;
   std::vector< std::vector< int > > indices;
@@ -224,7 +224,7 @@ TEST (PCL, FlannSearch_knnByIndex)
   {
     query_indices.push_back (int (i));
   }
-  flann_search->nearestKSearch (cloud_big, query_indices,no_of_neighbors,indices,dists);
+  flann_search.nearestKSearch (cloud_big, query_indices,no_of_neighbors,indices,dists);
 
   std::vector<int> k_indices;
   k_indices.resize (no_of_neighbors);
@@ -233,14 +233,14 @@ TEST (PCL, FlannSearch_knnByIndex)
 
   for (std::size_t i = 0; i < query_indices.size (); ++i)
   {
-    flann_search->nearestKSearch (cloud_big[2*i], no_of_neighbors, k_indices, k_distances);
+    flann_search.nearestKSearch (cloud_big[2*i], no_of_neighbors, k_indices, k_distances);
     EXPECT_EQ (k_indices.size (), indices[i].size ());
     EXPECT_EQ (k_distances.size (), dists[i].size ());
     for (std::size_t j = 0; j< no_of_neighbors; j++)
     {
       EXPECT_TRUE (k_indices[j] == indices[i][j] || k_distances[j] == dists[i][j]);
     }
-    flann_search->nearestKSearch (cloud_big,query_indices[i], no_of_neighbors, k_indices, k_distances);
+    flann_search.nearestKSearch (cloud_big,query_indices[i], no_of_neighbors, k_indices, k_distances);
     EXPECT_EQ (k_indices.size (), indices[i].size ());
     EXPECT_EQ (k_distances.size (), dists[i].size ());
     for (std::size_t j = 0; j< no_of_neighbors; j++)
@@ -372,8 +372,8 @@ main (int argc, char** argv)
   init ();
 
   // Testing using explicit instantiation of inherited class
-  pcl::search::Search<PointXYZ>* FlannSearch = new pcl::search::FlannSearch<PointXYZ> ( new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
-  FlannSearch->setInputCloud (cloud.makeShared ());
+  pcl::search::FlannSearch<PointXYZ> FlannSearch ( new search::FlannSearch<PointXYZ>::KdTreeIndexCreator);
+  FlannSearch.setInputCloud (cloud.makeShared ());
 
   return (RUN_ALL_TESTS ());
 }
index 028bbbf5576df8c18c3a13f47e13f1fd2daf3a01..6c73feb172d5e492d35a3abfff24a95baca5c98c 100644 (file)
@@ -71,8 +71,8 @@ init ()
 
 /* Test for KdTree nearestKSearch */TEST (PCL, KdTree_nearestKSearch)
 {
-  pcl::search::Search<PointXYZ>* kdtree = new pcl::search::KdTree<PointXYZ> ();
-  kdtree->setInputCloud (cloud.makeShared ());
+  pcl::search::KdTree<PointXYZ> kdtree;
+  kdtree.setInputCloud (cloud.makeShared ());
   PointXYZ test_point (0.01f, 0.01f, 0.01f);
   unsigned int no_of_neighbors = 20;
   multimap<float, int> sorted_brute_force_result;
@@ -95,7 +95,7 @@ init ()
   std::vector<float> k_distances;
   k_distances.resize (no_of_neighbors);
 
-  kdtree->nearestKSearch (test_point, no_of_neighbors, k_indices, k_distances);
+  kdtree.nearestKSearch (test_point, no_of_neighbors, k_indices, k_distances);
 
   //if (k_indices.size () != no_of_neighbors)  std::cerr << "Found "<<k_indices.size ()<<" instead of "<<no_of_neighbors<<" neighbors.\n";
   EXPECT_EQ (k_indices.size (), no_of_neighbors);
@@ -114,11 +114,11 @@ init ()
 
   ScopeTime scopeTime ("FLANN nearestKSearch");
   {
-    pcl::search::Search<PointXYZ>* kdtree = new pcl::search::KdTree<PointXYZ>();
-    //kdtree->initSearchDS ();
-    kdtree->setInputCloud (cloud_big.makeShared ());
+    pcl::search::KdTree<PointXYZ> kdtree;
+    //kdtree.initSearchDS ();
+    kdtree.setInputCloud (cloud_big.makeShared ());
     for (const auto &point : cloud_big.points)
-    kdtree->nearestKSearch (point, no_of_neighbors, k_indices, k_distances);
+    kdtree.nearestKSearch (point, no_of_neighbors, k_indices, k_distances);
   }
 }
 
@@ -128,9 +128,9 @@ TEST (PCL, KdTree_differentPointT)
 {
   unsigned int no_of_neighbors = 20;
 
-  pcl::search::Search<PointXYZ>* kdtree = new pcl::search::KdTree<PointXYZ> ();
-  //kdtree->initSearchDS ();
-  kdtree->setInputCloud (cloud_big.makeShared ());
+  pcl::search::KdTree<PointXYZ> kdtree;
+  //kdtree.initSearchDS ();
+  kdtree.setInputCloud (cloud_big.makeShared ());
 
   PointCloud<PointXYZRGB> cloud_rgb;
 
@@ -138,7 +138,7 @@ TEST (PCL, KdTree_differentPointT)
 
   std::vector< std::vector< float > > dists;
   std::vector< std::vector< int > > indices;
-  kdtree->nearestKSearchT (cloud_rgb, std::vector<int> (),no_of_neighbors,indices,dists);
+  kdtree.nearestKSearchT (cloud_rgb, std::vector<int> (),no_of_neighbors,indices,dists);
 
   std::vector<int> k_indices;
   k_indices.resize (no_of_neighbors);
@@ -152,8 +152,8 @@ TEST (PCL, KdTree_differentPointT)
 
   for (std::size_t i = 0; i < cloud_rgb.points.size (); ++i)
   {
-    kdtree->nearestKSearchT<pcl::PointXYZRGB> (cloud_rgb.points[i], no_of_neighbors, k_indices_t, k_distances_t);
-    kdtree->nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
+    kdtree.nearestKSearchT<pcl::PointXYZRGB> (cloud_rgb.points[i], no_of_neighbors, k_indices_t, k_distances_t);
+    kdtree.nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
     EXPECT_EQ (k_indices.size (), indices[i].size ());
     EXPECT_EQ (k_distances.size (), dists[i].size ());
     for (std::size_t j=0; j< no_of_neighbors; j++)
@@ -170,13 +170,13 @@ TEST (PCL, KdTree_multipointKnnSearch)
 {
   unsigned int no_of_neighbors = 20;
 
-  pcl::search::Search<PointXYZ>* kdtree = new pcl::search::KdTree<PointXYZ> ();
-  //kdtree->initSearchDS ();
-  kdtree->setInputCloud (cloud_big.makeShared ());
+  pcl::search::KdTree<PointXYZ> kdtree;
+  //kdtree.initSearchDS ();
+  kdtree.setInputCloud (cloud_big.makeShared ());
 
   std::vector< std::vector< float > > dists;
   std::vector< std::vector< int > > indices;
-  kdtree->nearestKSearch (cloud_big, std::vector<int> (),no_of_neighbors,indices,dists);
+  kdtree.nearestKSearch (cloud_big, std::vector<int> (),no_of_neighbors,indices,dists);
 
   std::vector<int> k_indices;
   k_indices.resize (no_of_neighbors);
@@ -185,7 +185,7 @@ TEST (PCL, KdTree_multipointKnnSearch)
 
   for (std::size_t i = 0; i < cloud_big.points.size (); ++i)
   {
-    kdtree->nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
+    kdtree.nearestKSearch (cloud_big.points[i], no_of_neighbors, k_indices, k_distances);
     EXPECT_EQ (k_indices.size (), indices[i].size ());
     EXPECT_EQ (k_distances.size (), dists[i].size ());
     for (std::size_t j=0; j< no_of_neighbors; j++)
@@ -202,8 +202,8 @@ main (int argc, char** argv)
   init ();
 
   // Testing using explicit instantiation of inherited class
-  pcl::search::Search<PointXYZ>* kdtree = new pcl::search::KdTree<PointXYZ> ();
-  kdtree->setInputCloud (cloud.makeShared ());
+  pcl::search::KdTree<PointXYZ> kdtree;
+  kdtree.setInputCloud (cloud.makeShared ());
 
   return (RUN_ALL_TESTS ());
 }
index b2a7f2efa4fab06ea847b9863609d47d9407df90..3d1cf02638faa21ca2bf6d8580d49c2315ff0643 100644 (file)
@@ -83,7 +83,7 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search)
   std::priority_queue<prioPointQueueEntry, pcl::PointCloud<prioPointQueueEntry>::VectorType> pointCandidates;
 
   // create octree
-  pcl::search::Search<PointXYZ>* octree = new pcl::search::Octree<PointXYZ> (0.1);
+  pcl::search::Octree<PointXYZ> octree(0.1);
 
   std::vector<int> k_indices;
   std::vector<float> k_sqr_distances;
@@ -146,8 +146,8 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search)
       pointCandidates.pop ();
     }
     // octree nearest neighbor search
-    octree->setInputCloud (cloudIn);
-    octree->nearestKSearch (searchPoint, static_cast<int> (K), k_indices, k_sqr_distances);
+    octree.setInputCloud (cloudIn);
+    octree.nearestKSearch (searchPoint, static_cast<int> (K), k_indices, k_sqr_distances);
 
     ASSERT_EQ ( k_indices.size() , k_indices_bruteforce.size() );
 
index 262dd5921de683c64241945310963365929e9b8f..24afaaedc5ed8f73ec718da8f5a3cf5128eb8d1d 100644 (file)
@@ -81,7 +81,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search)
   srand (time (NULL));
 
   // create organized search
-  pcl::search::Search<PointXYZ>* organizedNeighborSearch = new pcl::search::OrganizedNeighbor<PointXYZ>();
+  pcl::search::OrganizedNeighbor<PointXYZ> organizedNeighborSearch;
 
   std::vector<int> k_indices;
   std::vector<float> k_sqr_distances;
@@ -124,8 +124,8 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search)
     k_sqr_distances.clear();
 
     // organized nearest neighbor search
-    organizedNeighborSearch->setInputCloud (cloudIn);
-//    organizedNeighborSearch->nearestKSearch (searchPoint, (int)K, k_indices, k_sqr_distances);
+    organizedNeighborSearch.setInputCloud (cloudIn);
+//    organizedNeighborSearch.nearestKSearch (searchPoint, (int)K, k_indices, k_sqr_distances);
 
     k_indices_bruteforce.clear();
     k_sqr_distances_bruteforce.clear();
@@ -182,7 +182,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search_Kinec
   srand (time (NULL));
 
   // create organized search
-  pcl::search::Search<PointXYZ>* organizedNeighborSearch = new pcl::search::OrganizedNeighbor<PointXYZ>();
+  pcl::search::OrganizedNeighbor<PointXYZ> organizedNeighborSearch;
 
   std::vector<int> k_indices;
   std::vector<float> k_sqr_distances;
@@ -222,8 +222,8 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search_Kinec
     k_sqr_distances.clear();
 
     // organized nearest neighbor search
-    organizedNeighborSearch->setInputCloud (cloudIn);
-    organizedNeighborSearch->nearestKSearch (searchIdx, (int)K, k_indices, k_sqr_distances);
+    organizedNeighborSearch.setInputCloud (cloudIn);
+    organizedNeighborSearch.nearestKSearch (searchIdx, (int)K, k_indices, k_sqr_distances);
  
     k_indices_bruteforce.clear();
     k_sqr_distances_bruteforce.clear();
@@ -265,7 +265,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search)
 
   srand (time (NULL));
   
-  pcl::search::Search<PointXYZ>* organizedNeighborSearch = new pcl::search::OrganizedNeighbor<PointXYZ>();
+  pcl::search::OrganizedNeighbor<PointXYZ> organizedNeighborSearch;
 
   std::vector<int> k_indices;
   std::vector<float> k_sqr_distances;
@@ -327,9 +327,9 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search)
     std::vector<int> cloudNWRSearch;
     std::vector<float> cloudNWRRadius;
 
-    organizedNeighborSearch->setInputCloud (cloudIn);
+    organizedNeighborSearch.setInputCloud (cloudIn);
 
-    organizedNeighborSearch->radiusSearch (randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
+    organizedNeighborSearch.radiusSearch (randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
    
       
     // check if result from organized radius search can be also found in bruteforce search
@@ -368,7 +368,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search)
     ASSERT_EQ (cloudNWRRadius.size() , cloudSearchBruteforce.size ());
 
     // check if result limitation works
-    organizedNeighborSearch->radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5);
+    organizedNeighborSearch.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5);
 
     ASSERT_EQ (cloudNWRRadius.size () <= 5, true);
   }
@@ -380,7 +380,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_
   constexpr unsigned int test_runs = 10;
   srand (time (NULL));
 
-  pcl::search::Search<PointXYZ>* organizedNeighborSearch = new pcl::search::OrganizedNeighbor<PointXYZ>();
+  pcl::search::OrganizedNeighbor<PointXYZ> organizedNeighborSearch();
 
   std::vector<int> k_indices;
   std::vector<float> k_sqr_distances;
@@ -446,15 +446,15 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_
     std::vector<float> cloudNWRRadius;
     
     double check_time = getTime();
-    organizedNeighborSearch->setInputCloud (cloudIn);
-    organizedNeighborSearch->radiusSearch (randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
+    organizedNeighborSearch.setInputCloud (cloudIn);
+    organizedNeighborSearch.radiusSearch (randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
     
     double check_time2 = getTime();
     
     radiusSearchLPTime += check_time2 - check_time;
 
-    organizedNeighborSearch->setInputCloud (cloudIn);
-    organizedNeighborSearch->radiusSearch (randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
+    organizedNeighborSearch.setInputCloud (cloudIn);
+    organizedNeighborSearch.radiusSearch (randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
 
     radiusSearchTime += getTime() - check_time2;
   }
@@ -475,7 +475,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_
   constexpr unsigned int test_runs = 10;
   srand (time (NULL));
 
-  pcl::search::Search<PointXYZ>* organizedNeighborSearch = new pcl::search::OrganizedNeighbor<PointXYZ>();
+  pcl::search::OrganizedNeighbor<PointXYZ> organizedNeighborSearch();
 
   // typical focal length from kinect
   unsigned int randomIdx;
@@ -512,8 +512,8 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_
       cloudNWRRadius2.clear();
 
       double check_time = getTime();
-      organizedNeighborSearch->setInputCloud (cloudIn);
-      organizedNeighborSearch->radiusSearch (randomIdx, searchRadius, cloudNWRSearch2, cloudNWRRadius2, INT_MAX); //,INT_MAX);
+      organizedNeighborSearch.setInputCloud (cloudIn);
+      organizedNeighborSearch.radiusSearch (randomIdx, searchRadius, cloudNWRSearch2, cloudNWRRadius2, INT_MAX); //,INT_MAX);
 
       double check_time2 = getTime();
       sum_time+= check_time2 - check_time;
@@ -525,8 +525,8 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_
        cloudNWRSearch.clear();
        cloudNWRRadius.clear();
        double check_time = getTime();
-       organizedNeighborSearch->setInputCloud (cloudIn);
-       organizedNeighborSearch->approxRadiusSearch (cloudIn, randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
+       organizedNeighborSearch.setInputCloud (cloudIn);
+       organizedNeighborSearch.approxRadiusSearch (cloudIn, randomIdx, searchRadius, cloudNWRSearch, cloudNWRRadius, INT_MAX); //,INT_MAX);
 
        double check_time2 = getTime();
        sum_time2+= check_time2 - check_time;
@@ -587,7 +587,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_
     ASSERT_EQ (cloudNWRRadius.size() , cloudSearchBruteforce.size ());
 
     // check if result limitation works
-    organizedNeighborSearch->radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5);
+    organizedNeighborSearch.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5);
 
     ASSERT_EQ (cloudNWRRadius.size () <= 5, true);
   }
index 348fe83451c94d0407b22f3628dfbb0c28e005a3..ef6af3b177094e15de79ef4114ad591ded29adf6 100644 (file)
 #include <pcl/search/organized.h>
 #include <pcl/search/octree.h>
 #include <pcl/io/pcd_io.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
 #include <pcl/common/time.h>
 
+
 using namespace pcl;
 using namespace std;
 
@@ -299,7 +301,9 @@ testKNNSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector<se
   }
   
   // remove also Nans
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    shared(nan_mask, point_cloud) \
+    default(none)
   for (int pIdx = 0; pIdx < int (point_cloud->size ()); ++pIdx)
   {
     if (!isFinite (point_cloud->points [pIdx]))
@@ -310,7 +314,9 @@ testKNNSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector<se
   if (!input_indices.empty ())
     input_indices_.reset (new pcl::Indices (input_indices));
   
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    shared(input_indices, input_indices_, point_cloud, search_methods) \
+    default(none)
   for (int sIdx = 0; sIdx < int (search_methods.size ()); ++sIdx)
     search_methods [sIdx]->setInputCloud (point_cloud, input_indices_);
 
@@ -320,7 +326,9 @@ testKNNSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector<se
     // find nn for each point in the cloud
     for (const int &query_index : query_indices)
     {
-      #pragma omp parallel for
+      #pragma omp parallel for \
+        shared(indices, input_indices, indices_mask, distances, knn, nan_mask, passed, point_cloud, query_index, search_methods) \
+        default(none)
       for (int sIdx = 0; sIdx < int (search_methods.size ()); ++sIdx)
       {
         search_methods [sIdx]->nearestKSearch (point_cloud->points[query_index], knn, indices [sIdx], distances [sIdx]);
@@ -330,7 +338,9 @@ testKNNSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector<se
       }
       
       // compare results to each other
-      #pragma omp parallel for
+      #pragma omp parallel for \
+        shared(distances, indices, passed, search_methods) \
+        default(none)
       for (int sIdx = 1; sIdx < int (search_methods.size ()); ++sIdx)
       {
         passed [sIdx] = passed [sIdx] && compareResults (indices [0],    distances [0],    search_methods [0]->getName (),
@@ -369,7 +379,9 @@ testRadiusSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector
   }
   
   // remove also Nans
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none) \
+    shared(nan_mask, point_cloud)
   for (int pIdx = 0; pIdx < int (point_cloud->size ()); ++pIdx)
   {
     if (!isFinite (point_cloud->points [pIdx]))
@@ -380,7 +392,9 @@ testRadiusSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector
   if (!input_indices.empty ())
     input_indices_.reset (new pcl::Indices (input_indices));
   
-  #pragma omp parallel for
+  #pragma omp parallel for \
+    default(none) \
+    shared(input_indices_, point_cloud, search_methods)
   for (int sIdx = 0; sIdx < int (search_methods.size ()); ++sIdx)
     search_methods [sIdx]->setInputCloud (point_cloud, input_indices_);
 
@@ -391,7 +405,9 @@ testRadiusSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector
     // find nn for each point in the cloud
     for (const int &query_index : query_indices)
     {
-      #pragma omp parallel for
+      #pragma omp parallel for \
+        default(none) \
+        shared(distances, indices, indices_mask, input_indices, nan_mask, passed, point_cloud, radius, query_index, search_methods)
       for (int sIdx = 0; sIdx < static_cast<int> (search_methods.size ()); ++sIdx)
       {
         search_methods [sIdx]->radiusSearch (point_cloud->points[query_index], radius, indices [sIdx], distances [sIdx], 0);
@@ -401,7 +417,9 @@ testRadiusSearch (typename PointCloud<PointT>::ConstPtr point_cloud, std::vector
       }
       
       // compare results to each other
-      #pragma omp parallel for
+      #pragma omp parallel for \
+        default(none) \
+        shared(distances, indices, passed, search_methods)
       for (int sIdx = 1; sIdx < static_cast<int> (search_methods.size ()); ++sIdx)
       {
         passed [sIdx] = passed [sIdx] && compareResults (indices [0],    distances [0],    search_methods [0]->getName (),
index 73a9b5f73d2648a8917490a31a5b6b7fe667335a..3c83692ef44dcb3d8a7d89e672537d352809f0ed 100644 (file)
@@ -94,9 +94,9 @@ TEST (ORROctreeTest, OctreeSphereIntersection)
   float frac_of_points_for_registration = 0.3f;
   std::string object_name = "test_object";
 
-  ModelLibrary::Model* new_model = new ModelLibrary::Model (*model_cloud, *model_cloud_normals, voxel_size, object_name, frac_of_points_for_registration);
+  ModelLibrary::Model new_model (*model_cloud, *model_cloud_normals, voxel_size, object_name, frac_of_points_for_registration);
 
-  const ORROctree& octree = new_model->getOctree ();
+  const ORROctree& octree = new_model.getOctree ();
   const std::vector<ORROctree::Node*> &full_leaves = octree.getFullLeaves ();
   list<ORROctree::Node*> inter_leaves;
 
@@ -113,7 +113,6 @@ TEST (ORROctreeTest, OctreeSphereIntersection)
       EXPECT_NE(*leaf1, *leaf2);
     }
   }
-
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
index a6c4c5c6c8612479822d5d501453793e618122fd..b34c30d5521540461de65363dec43c88a3707e4c 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <pcl/test/gtest.h>
 
+#include <pcl/common/generate.h>
 #include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/features/normal_3d.h>
@@ -60,6 +61,28 @@ PointCloud<PointNormal>::Ptr cloud_with_normals1 (new PointCloud<PointNormal>);
 search::KdTree<PointXYZ>::Ptr tree3;
 search::KdTree<PointNormal>::Ptr tree4;
 
+// Test that updatepointcloud works when removing points. Ie. modifying vtk data structure to reflect modified pointcloud
+// See #4001 and #3452 for previously undetected error.
+////////////////////////////////////////////////////////////////////////////////
+TEST(PCL, PCLVisualizer_updatePointCloud)
+{
+  pcl::common::CloudGenerator<pcl::PointXYZRGB, pcl::common::UniformGenerator<float> > generator;
+
+  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>());
+  int result = generator.fill(3, 1, *cloud);
+
+  // Setup a basic viewport window
+  pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
+  pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZRGB> color_green(cloud, 0, 225, 100);
+  viewer->addPointCloud<pcl::PointXYZRGB>(cloud, color_green, "sample cloud");
+
+  // remove points one by one)
+  while (!cloud->empty()) {
+    cloud->erase(cloud->end() - 1);
+    viewer->updatePointCloud(cloud, "sample cloud");
+    viewer->spinOnce(100);
+  }
+}
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 TEST (PCL, PCLVisualizer_camera)
 {
index 097c6e133a6ecbe92edd0b6b6a0916bd4d62e803..1911f7b9f4098c21e3c33291bee8f371073d46d2 100644 (file)
@@ -183,9 +183,6 @@ else()
   PCL_ADD_EXECUTABLE(pcl_pcd2png COMPONENT ${SUBSYS_NAME} SOURCES pcd2png.cpp)
   target_link_libraries(pcl_pcd2png pcl_common pcl_io)
 
-  PCL_ADD_EXECUTABLE(pcl_organized_pcd_to_png COMPONENT ${SUBSYS_NAME} SOURCES organized_pcd_to_png.cpp)
-  target_link_libraries (pcl_organized_pcd_to_png pcl_common pcl_io)
-
   PCL_ADD_EXECUTABLE(pcl_tiff2pcd COMPONENT ${SUBSYS_NAME} SOURCES tiff2pcd.cpp)
   target_link_libraries(pcl_tiff2pcd pcl_common pcl_io)
 
index 46bb030ed26c8c46d4177bf52d81501350b07981..ed20728a4428abf835e8ff3fd5f36a98f763c71a 100644 (file)
@@ -46,7 +46,6 @@
 
 #ifndef Q_MOC_RUN
 // Marking all Boost headers as system headers to remove warnings
-#include <boost/make_shared.hpp>
 #include <boost/date_time/gregorian/gregorian_types.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
index 90ecb022de7c929a52d8b94ca92368f69ad8a92a..2136cd439cfcf75a1c4c0025bf4028bcfaa2ead2 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Point Cloud Library (PCL) - www.pointclouds.org
  *  Copyright (c) 2011, Willow Garage, Inc.
- *  
+ *
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
  */
 
 #include <pcl/PCLPointCloud2.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_types.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/segmentation/extract_clusters.h>
@@ -43,8 +44,8 @@
 #include <pcl/console/print.h>
 #include <pcl/console/parse.h>
 #include <pcl/console/time.h>
+
 #include <vector>
-#include "boost.h"
 
 using namespace pcl;
 using namespace pcl::io;
@@ -62,11 +63,11 @@ printHelp (int, char **argv)
 {
   print_error ("Syntax is: %s input.pcd output.pcd <options>\n", argv[0]);
   print_info ("  where options are:\n");
-  print_info ("                     -min X = use a minimum of X points peer cluster (default: "); 
+  print_info ("                     -min X = use a minimum of X points peer cluster (default: ");
   print_value ("%d", default_min); print_info (")\n");
-  print_info ("                     -max X      = use a maximum of X points peer cluster (default: "); 
+  print_info ("                     -max X      = use a maximum of X points peer cluster (default: ");
   print_value ("%d", default_max); print_info (")\n");
-  print_info ("                     -tolerance X = the spacial distance between clusters (default: "); 
+  print_info ("                     -tolerance X = the spacial distance between clusters (default: ");
   print_value ("%lf", default_tolerance); print_info (")\n");
 }
 
@@ -96,7 +97,7 @@ compute (const pcl::PCLPointCloud2::ConstPtr &input, std::vector<pcl::PCLPointCl
   // Estimate
   TicToc tt;
   tt.tic ();
-  
+
   print_highlight (stderr, "Computing ");
 
   // Creating the KdTree object for the search method of the extraction
@@ -119,7 +120,7 @@ compute (const pcl::PCLPointCloud2::ConstPtr &input, std::vector<pcl::PCLPointCl
   {
     pcl::ExtractIndices<pcl::PCLPointCloud2> extract;
     extract.setInputCloud (input);
-    extract.setIndices (boost::make_shared<const pcl::PointIndices> (*it));
+    extract.setIndices (pcl::make_shared<const pcl::PointIndices> (*it));
     pcl::PCLPointCloud2::Ptr out (new pcl::PCLPointCloud2);
     extract.filter (*out);
     output.push_back (out);
@@ -143,7 +144,7 @@ saveCloud (const std::string &filename, const std::vector<pcl::PCLPointCloud2::P
 
     print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", output[i]->width * output[i]->height); print_info (" points]\n");
   }
-  
+
 }
 
 /* ---[ */
@@ -178,7 +179,7 @@ main (int argc, char** argv)
 
   // Load the first file
   pcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2);
-  if (!loadCloud (argv[p_file_indices[0]], *cloud)) 
+  if (!loadCloud (argv[p_file_indices[0]], *cloud))
     return (-1);
 
   // Perform the feature estimation
index 699babe37f16bca6cd3302a9acb358664d8046c0..d55655875266e7470e77915500644e15103631ef 100644 (file)
@@ -35,6 +35,7 @@
  *
  */
 
+#include <pcl/memory.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/common/time.h>
 #include <pcl/console/print.h>
@@ -43,7 +44,6 @@
 #include <pcl/io/depth_sense_grabber.h>
 #include <pcl/visualization/pcl_visualizer.h>
 
-#include <boost/shared_ptr.hpp>
 #include <boost/format.hpp>
 
 #include <iostream>
index 315a7f954fd03e1e26f2427db9ac69e4f864dd56..cbec0683477e6c274d3dd18b6da0269eec5cce25 100644 (file)
@@ -112,9 +112,9 @@ saveCloud (const string &filename, const pcl::PCLPointCloud2 &output,
 int
 batchProcess (const std::vector<string> &pcd_files, string &output_dir, float sigma_s, float sigma_r)
 {
-#if _OPENMP
-#pragma omp parallel for
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(output_dir, pcd_files, sigma_r, sigma_s)
   for (int i = 0; i < int (pcd_files.size ()); ++i)
   {
     // Load the first file
index b5f44a8dc8ede3f6f8c628fa6e6a1f8fcdc1fbcb..adea87eab45bd737b17d22f17accd81f976ec5aa 100644 (file)
@@ -131,9 +131,9 @@ saveCloud (const string &filename, const pcl::PCLPointCloud2 &output,
 int
 batchProcess (const std::vector<string> &pcd_files, string &output_dir, int k, double radius)
 {
-#if _OPENMP
-#pragma omp parallel for
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(k, output_dir, pcd_files, radius)
   for (int i = 0; i < int (pcd_files.size ()); ++i)
   {
     // Load the first file
index 7cde623a226d96e42b7949b8da41d3d0964fa6ca..54f35df73c8d038e4a4350df2f7ef8b9ea0f85de 100644 (file)
@@ -185,24 +185,21 @@ main(int argc, char ** argv)
 
   pcl::TimeTrigger trigger;
   
-  pcl::ONIGrabber* grabber = nullptr;
-  if (frame_rate == 0)
-    grabber = new  pcl::ONIGrabber(arg, true, true);
-  else
+  pcl::ONIGrabber grabber (arg, true, frame_rate == 0);
+  if (frame_rate != 0)
   {
-    grabber = new  pcl::ONIGrabber(arg, true, false);
     trigger.setInterval (1.0 / static_cast<double> (frame_rate));
-    trigger.registerCallback ([=] { grabber->start (); });
+    trigger.registerCallback ([&] { grabber.start (); });
     trigger.start();
   }
-  if (grabber->providesCallback<pcl::ONIGrabber::sig_cb_openni_point_cloud_rgb > () && !pcl::console::find_switch (argc, argv, "-xyz"))
+  if (grabber.providesCallback<pcl::ONIGrabber::sig_cb_openni_point_cloud_rgb > () && !pcl::console::find_switch (argc, argv, "-xyz"))
   {
-    SimpleONIViewer<pcl::PointXYZRGBA> v(*grabber);
+    SimpleONIViewer<pcl::PointXYZRGBA> v(grabber);
     v.run();
   }
   else
   {
-    SimpleONIViewer<pcl::PointXYZ> v(*grabber);
+    SimpleONIViewer<pcl::PointXYZ> v(grabber);
     v.run();
   }
 
index 9c6306603c2a8a32710abb481530b782962e6830..1df1fb6568b437398ee1144440f7bb8dee127bd6 100644 (file)
@@ -224,8 +224,7 @@ class SimpleOpenNIViewer
       
       cloud_connection.disconnect();
       image_connection.disconnect();
-      if (rgb_data)
-        delete[] rgb_data;
+      delete[] rgb_data;
     }
 
     pcl::visualization::CloudViewer cloud_viewer_;
diff --git a/tools/organized_pcd_to_png.cpp b/tools/organized_pcd_to_png.cpp
deleted file mode 100644 (file)
index 0a2be3a..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Software License Agreement (BSD License)
- *
- *  Point Cloud Library (PCL) - www.pointclouds.org
- *  Copyright (c) 2013, Open Perception, Inc.
- *
- *  All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions
- *  are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the following
- *     disclaimer in the documentation and/or other materials provided
- *     with the distribution.
- *   * Neither the name of the copyright holder(s) nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *  POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <pcl/io/pcd_io.h>
-#include <pcl/console/print.h>
-#include <pcl/console/parse.h>
-#include <pcl/console/time.h>
-#include <pcl/io/png_io.h>
-
-using namespace pcl;
-using namespace pcl::io;
-using namespace pcl::console;
-
-void
-printHelp (int, char **argv)
-{
-  print_error ("Syntax is: %s input.pcd output.png\n", argv[0]);
-}
-
-bool
-loadCloud (const std::string &filename, pcl::PCLPointCloud2 &cloud)
-{
-  TicToc tt;
-  print_highlight ("Loading "); print_value ("%s ", filename.c_str ());
-
-  tt.tic ();
-  if (loadPCDFile (filename, cloud) < 0)
-    return (false);
-  print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", cloud.width * cloud.height); print_info (" points]\n");
-  print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (cloud).c_str ());
-
-  return (true);
-}
-
-void
-saveImage (const std::string &filename, const PointCloud<RGB> &image)
-{
-  TicToc tt;
-  tt.tic ();
-
-  print_highlight ("Saving "); print_value ("%s ", filename.c_str ());
-  io::savePNGFile (filename, image, "rgb");
-
-  print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", image.width * image.height); print_info (" points]\n");
-}
-
-/* ---[ */
-int
-main (int argc, char** argv)
-{
-  print_error ("This tool is deprecated, please use \"pcl_pcd2png\" instead!\n");
-  print_info ("Convert the RGB information of an organized PCD file to a PNG image. For more information, use: %s -h\n", argv[0]);
-
-  if (argc < 3)
-  {
-    printHelp (argc, argv);
-    return (-1);
-  }
-
-  // Parse the command line arguments for .pcd files
-  std::vector<int> pcd_file_indices = parse_file_extension_argument (argc, argv, ".pcd");
-  if (pcd_file_indices.size () != 1)
-  {
-    print_error ("Need one input PCD file and one output PNG file.\n");
-    return (-1);
-  }
-
-  std::vector<int> png_file_indices = parse_file_extension_argument (argc, argv, ".png");
-  if (png_file_indices.size () != 1)
-  {
-    print_error ("Need one input PCD file and one output PNG file.\n");
-    return (-1);
-  }
-
-  // Load the first file
-  pcl::PCLPointCloud2 cloud;
-  if (!loadCloud (argv[pcd_file_indices[0]], cloud))
-    return (-1);
-
-
-  PointCloud<RGB> image;
-  fromPCLPointCloud2 (cloud, image);
-
-
-  // Check if the cloud is organized
-  if (!image.isOrganized ())
-  {
-    PCL_ERROR ("Input cloud is not organized.\n");
-    return (-1);
-  }
-
-  // Save cloud
-  saveImage (argv[png_file_indices[0]], image);
-
-  return (0);
-}
-
index 8dd71afcca424da3bdadfe7990b91a302e2cb7e4..92450abbc6efc21f0147931b21c1d3fa917cc3b3 100644 (file)
@@ -35,6 +35,7 @@
  *
  */
 
+#include <pcl/memory.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/common/time.h>
 #include <pcl/console/print.h>
@@ -44,7 +45,6 @@
 #include <pcl/visualization/pcl_visualizer.h>
 
 #include <boost/format.hpp>
-#include <boost/shared_ptr.hpp>
 
 #include <iostream>
 #include <mutex>
index 8baf0a7a4e9437abc961a581d427dff96d4a2d0c..7c93d2deec6f210d367483099b6b0aeb234c1463 100644 (file)
   * \author Radu Bogdan Rusu
   *
   * @b virtual_scanner takes in a .ply or a .vtk file of an object model, and virtually scans it
-  * in a raytracing fashion, saving the end results as PCD (Point Cloud Data) files. In addition, 
-  * it noisifies the PCD models, and downsamples them. 
+  * in a raytracing fashion, saving the end results as PCD (Point Cloud Data) files. In addition,
+  * it noisifies the PCD models, and downsamples them.
   * The viewpoint can be set to 1 or multiple views on a sphere.
   */
 
 #include <random>
 #include <string>
+
 #include <pcl/register_point_struct.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/io/vtk_lib_io.h>
 #include <pcl/filters/voxel_grid.h>
+#include <pcl/memory.h>  // for pcl::make_shared
 #include <pcl/point_types.h>
 #include <pcl/console/parse.h>
 #include <pcl/visualization/vtk.h>
-#include "boost.h"
+
+#include <boost/algorithm/string.hpp>  // for boost::is_any_of, boost::split, boost::token_compress_on, boost::trim
+#include <boost/filesystem.hpp>  // for boost::filesystem::create_directories, boost::filesystem::exists, boost::filesystem::extension, boost::filesystem::path
 
 using namespace pcl;
 
@@ -138,7 +142,7 @@ main (int argc, char** argv)
     PCL_ERROR ("Error: no .PLY or .VTK files given!\n");
     return (-1);
   }
-  
+
   std::stringstream filename_stream;
   if (!p_file_indices_ply.empty ())
     filename_stream << argv[p_file_indices_ply.at (0)];
@@ -146,9 +150,9 @@ main (int argc, char** argv)
     filename_stream << argv[p_file_indices_vtk.at (0)];
 
   filename = filename_stream.str ();
-  
+
   data = loadDataSet (filename.c_str ());
-  
+
   PCL_INFO ("Loaded model with %d vertices/points.\n", data->GetNumberOfPoints ());
 
   // Default scan parameters
@@ -207,7 +211,7 @@ main (int argc, char** argv)
   double temp_beam[3], beam[3], p[3];
   double p_coords[3], x[3], t;
   int subId;
+
   // Create a Icosahedron at center in origin and radius of 1
   vtkSmartPointer<vtkPlatonicSolidSource> icosa = vtkSmartPointer<vtkPlatonicSolidSource>::New ();
   icosa->SetSolidTypeToIcosahedron ();
@@ -300,7 +304,7 @@ main (int argc, char** argv)
       up[0] /= up_len;
       up[1] /= up_len;
       up[2] /= up_len;
-    
+
       // Output resulting vectors
       std::cerr << "Viewray Right Up:" << std::endl;
       std::cerr << viewray[0] << " " << viewray[1] << " " << viewray[2] << " " << std::endl;
@@ -329,7 +333,7 @@ main (int argc, char** argv)
       for (double hor = hor_start; hor <= hor_end; hor += sp.hor_res)
       {
         pid ++;
-      
+
         // Create a beam vector with (lat,long) angles (vert, hor) with the viewray
         tr2->Identity ();
         tr2->RotateWXYZ (hor, up);
@@ -347,11 +351,11 @@ main (int argc, char** argv)
           pcl::PointWithViewpoint pt;
           if (object_coordinates)
           {
-            pt.x = static_cast<float> (x[0]); 
-            pt.y = static_cast<float> (x[1]); 
+            pt.x = static_cast<float> (x[0]);
+            pt.y = static_cast<float> (x[1]);
             pt.z = static_cast<float> (x[2]);
-            pt.vp_x = static_cast<float> (eye[0]); 
-            pt.vp_y = static_cast<float> (eye[1]); 
+            pt.vp_x = static_cast<float> (eye[0]);
+            pt.vp_y = static_cast<float> (eye[1]);
             pt.vp_z = static_cast<float> (eye[2]);
           }
           else
@@ -393,7 +397,7 @@ main (int argc, char** argv)
 
     // Downsample and remove silly point duplicates
     pcl::PointCloud<pcl::PointWithViewpoint> cloud_downsampled;
-    grid.setInputCloud (boost::make_shared<pcl::PointCloud<pcl::PointWithViewpoint> > (cloud));
+    grid.setInputCloud (pcl::make_shared<pcl::PointCloud<pcl::PointWithViewpoint> > (cloud));
     //grid.filter (cloud_downsampled);
 
     // Saves the point cloud data to disk
index ef28f5eec60ed7d8917964a979da494e0f1e63cd..64a8d172e171aa29d386ed735fb1bb0081b01024 100644 (file)
@@ -41,6 +41,6 @@
 
 #include <pcl/pcl_macros.h>
 
-PCL_PRAGMA_WARNING("This header is deprecated and will be removed in an upcoming release.")
+PCL_DEPRECATED_HEADER(1, 12, "")
 
 #include <boost/random.hpp>
index de5a1aae22de3a2f23576c3bebfe4a143c358870..f2bc6f27e86a6b071ccde464343e8ffbd957edfc 100644 (file)
@@ -1,9 +1,9 @@
 #pragma once
 
-#include <boost/shared_ptr.hpp>
-
+#include <pcl/memory.h>
 #include <pcl/tracking/coherence.h>
 
+
 namespace pcl
 {
   namespace tracking
index e1fe8630f638c64e40cab9e9c02291ce57312a40..f1c687203571a5c0596a083d206b7b614ecf0755 100644 (file)
@@ -23,9 +23,9 @@ pcl::tracking::KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::weight ()
 {
   if (!use_normal_)
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
     for (int i = 0; i < particle_num_; i++)
       this->computeTransformedPointCloudWithoutNormal (particles_->points[i], *transed_reference_vector_[i]);
     
@@ -40,9 +40,9 @@ pcl::tracking::KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::weight ()
         change_counter_ = change_detector_interval_;
         coherence_->setTargetCloud (coherence_input);
         coherence_->initCompute ();
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
         for (int i = 0; i < particle_num_; i++)
         {
           IndicesPtr indices;
@@ -57,9 +57,9 @@ pcl::tracking::KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::weight ()
       --change_counter_;
       coherence_->setTargetCloud (coherence_input);
       coherence_->initCompute ();
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
       for (int i = 0; i < particle_num_; i++)
       {
         IndicesPtr indices;
@@ -74,9 +74,10 @@ pcl::tracking::KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::weight ()
     {
       indices_list[i] = IndicesPtr (new std::vector<int>);
     }
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(indices_list) \
+  num_threads(threads_)
     for (int i = 0; i < particle_num_; i++)
     {
       this->computeTransformedPointCloudWithNormal (particles_->points[i], *indices_list[i], *transed_reference_vector_[i]);
@@ -87,9 +88,10 @@ pcl::tracking::KLDAdaptiveParticleFilterOMPTracker<PointInT, StateT>::weight ()
     
     coherence_->setTargetCloud (coherence_input);
     coherence_->initCompute ();
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(indices_list) \
+  num_threads(threads_)
     for (int i = 0; i < particle_num_; i++)
     {
       coherence_->compute (transed_reference_vector_[i], indices_list[i], particles_->points[i].weight);
index bfc100bc462e5144a62a9ebe53159f7e49f5f6a2..6932574f319e1412602080c38a16b52cc2f97b23 100644 (file)
@@ -23,9 +23,9 @@ pcl::tracking::ParticleFilterOMPTracker<PointInT, StateT>::weight ()
 {
   if (!use_normal_)
   {
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
     for (int i = 0; i < particle_num_; i++)
       this->computeTransformedPointCloudWithoutNormal (particles_->points[i], *transed_reference_vector_[i]);
     
@@ -40,9 +40,9 @@ pcl::tracking::ParticleFilterOMPTracker<PointInT, StateT>::weight ()
         change_counter_ = change_detector_interval_;
         coherence_->setTargetCloud (coherence_input);
         coherence_->initCompute ();
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
         for (int i = 0; i < particle_num_; i++)
         {
           IndicesPtr indices;   // dummy
@@ -57,9 +57,9 @@ pcl::tracking::ParticleFilterOMPTracker<PointInT, StateT>::weight ()
       --change_counter_;
       coherence_->setTargetCloud (coherence_input);
       coherence_->initCompute ();
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  num_threads(threads_)
       for (int i = 0; i < particle_num_; i++)
       {
         IndicesPtr indices;     // dummy
@@ -74,9 +74,10 @@ pcl::tracking::ParticleFilterOMPTracker<PointInT, StateT>::weight ()
     {
       indices_list[i] = IndicesPtr (new std::vector<int>);
     }
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(indices_list) \
+  num_threads(threads_)
     for (int i = 0; i < particle_num_; i++)
     {
       this->computeTransformedPointCloudWithNormal (particles_->points[i], *indices_list[i], *transed_reference_vector_[i]);
@@ -87,9 +88,10 @@ pcl::tracking::ParticleFilterOMPTracker<PointInT, StateT>::weight ()
     
     coherence_->setTargetCloud (coherence_input);
     coherence_->initCompute ();
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(indices_list) \
+  num_threads(threads_)
     for (int i = 0; i < particle_num_; i++)
     {
       coherence_->compute (transed_reference_vector_[i], indices_list[i], particles_->points[i].weight);
index 16887e4bbabc95d21a62c9fc20436f0fe26f9b00..14a951baf0769547c004bd022e31920fb4d7dc24 100644 (file)
 #include <pcl/common/io.h>
 #include <pcl/common/utils.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace tracking
+{
+
 template <typename PointInT, typename IntensityT> inline void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::setTrackingWindowSize (int width, int height)
+PyramidalKLTTracker<PointInT, IntensityT>::setTrackingWindowSize (int width, int height)
 {
   track_width_ = width;
   track_height_ = height;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> inline void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::setPointsToTrack (const pcl::PointCloud<pcl::PointUV>::ConstPtr& keypoints)
+PyramidalKLTTracker<PointInT, IntensityT>::setPointsToTrack (const pcl::PointCloud<pcl::PointUV>::ConstPtr& keypoints)
 {
   if (keypoints->size () <= keypoints_nbr_)
     keypoints_ = keypoints;
@@ -70,9 +76,9 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::setPointsToTrack (cons
   keypoints_status_->indices.resize (keypoints_->size (), 0);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> inline void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::setPointsToTrack (const pcl::PointIndicesConstPtr& points)
+PyramidalKLTTracker<PointInT, IntensityT>::setPointsToTrack (const pcl::PointIndicesConstPtr& points)
 {
   assert ((input_ || ref_) && "[pcl::tracking::PyramidalKLTTracker] CALL setInputCloud FIRST!");
 
@@ -88,9 +94,9 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::setPointsToTrack (cons
   setPointsToTrack (keypoints);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> bool
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::initCompute ()
+PyramidalKLTTracker<PointInT, IntensityT>::initCompute ()
 {
   // std::cout << ">>> [PyramidalKLTTracker::initCompute]" << std::endl;
   if (!PCLBase<PointInT>::initCompute ())
@@ -154,14 +160,15 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::initCompute ()
     computePyramids (ref_, ref_pyramid_, pcl::BORDER_REFLECT_101);
     return (true);
   }
+
   initialized_ = true;
 
   return (true);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::derivatives (const FloatImage& src, FloatImage& grad_x, FloatImage& grad_y) const
+PyramidalKLTTracker<PointInT, IntensityT>::derivatives (const FloatImage& src, FloatImage& grad_x, FloatImage& grad_y) const
 {
   // std::cout << ">>> derivatives" << std::endl;
   ////////////////////////////////////////////////////////
@@ -214,9 +221,9 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::derivatives (const Flo
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::downsample (const FloatImageConstPtr& input,
+PyramidalKLTTracker<PointInT, IntensityT>::downsample (const FloatImageConstPtr& input,
                                                                FloatImageConstPtr& output) const
 {
   FloatImage smoothed (input->width, input->height);
@@ -229,9 +236,11 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::downsample (const Floa
     ii[i] = 2 * i;
 
   FloatImagePtr down (new FloatImage (width, height));
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) firstprivate (ii) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(down, height, output, smoothed, width) \
+  firstprivate(ii) \
+  num_threads(threads_)
   for (int j = 0; j < height; ++j)
   {
     int jj = 2*j;
@@ -242,12 +251,12 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::downsample (const Floa
   output = down;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::downsample (const FloatImageConstPtr& input,
-                                                                      FloatImageConstPtr& output,
-                                                                      FloatImageConstPtr& output_grad_x,
-                                                                      FloatImageConstPtr& output_grad_y) const
+PyramidalKLTTracker<PointInT, IntensityT>::downsample (const FloatImageConstPtr& input,
+                                                             FloatImageConstPtr& output,
+                                                             FloatImageConstPtr& output_grad_x,
+                                                             FloatImageConstPtr& output_grad_y) const
 {
   downsample (input, output);
   FloatImagePtr grad_x (new FloatImage (input->width, input->height));
@@ -257,27 +266,28 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::downsample (const Floa
   output_grad_y = grad_y;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::convolve (const FloatImageConstPtr& input, FloatImage& output) const
+PyramidalKLTTracker<PointInT, IntensityT>::convolve (const FloatImageConstPtr& input, FloatImage& output) const
 {
   FloatImagePtr tmp (new FloatImage (input->width, input->height));
   convolveRows (input, *tmp);
   convolveCols (tmp, output);
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::convolveRows (const FloatImageConstPtr& input, FloatImage& output) const
+PyramidalKLTTracker<PointInT, IntensityT>::convolveRows (const FloatImageConstPtr& input, FloatImage& output) const
 {
   int width = input->width;
   int height = input->height;
   int last = input->width - kernel_size_2_;
   int w = last - 1;
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(input, height, last, output, w, width) \
+  num_threads(threads_)
   for (int j = 0; j < height; ++j)
   {
     for (int i = kernel_size_2_; i < last; ++i)
@@ -297,9 +307,9 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::convolveRows (const Fl
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::convolveCols (const FloatImageConstPtr& input, FloatImage& output) const
+PyramidalKLTTracker<PointInT, IntensityT>::convolveCols (const FloatImageConstPtr& input, FloatImage& output) const
 {
   output = FloatImage (input->width, input->height);
 
@@ -308,9 +318,10 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::convolveCols (const Fl
   int last = input->height - kernel_size_2_;
   int h = last -1;
 
-#ifdef _OPENMP
-#pragma omp parallel for shared (output) num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(input, h, height, last, output, width) \
+  num_threads(threads_)
   for (int i = 0; i < width; ++i)
   {
     for (int j = kernel_size_2_; j < last; ++j)
@@ -329,20 +340,21 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::convolveCols (const Fl
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::computePyramids (const PointCloudInConstPtr& input,
-                                                                    std::vector<FloatImageConstPtr>& pyramid,
-                                                                    pcl::InterpolationType border_type) const
+PyramidalKLTTracker<PointInT, IntensityT>::computePyramids (const PointCloudInConstPtr& input,
+                                                            std::vector<FloatImageConstPtr>& pyramid,
+                                                            pcl::InterpolationType border_type) const
 {
   int step = 3;
   pyramid.resize (step * nb_levels_);
 
   FloatImageConstPtr previous;
   FloatImagePtr tmp (new FloatImage (input->width, input->height));
-#ifdef _OPENMP
-#pragma omp parallel for num_threads (threads_)
-#endif
+#pragma omp parallel for \
+  default(none) \
+  shared(input, tmp) \
+  num_threads(threads_)
   for (int i = 0; i < static_cast<int> (input->size ()); ++i)
     tmp->points[i] = intensity_ (input->points[i]);
   previous = tmp;
@@ -397,17 +409,17 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::computePyramids (const
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::spatialGradient (const FloatImage& img,
-                                                                    const FloatImage& grad_x,
-                                                                    const FloatImage& grad_y,
-                                                                    const Eigen::Array2i& location,
-                                                                    const Eigen::Array4f& weight,
-                                                                    Eigen::ArrayXXf& win,
-                                                                    Eigen::ArrayXXf& grad_x_win,
-                                                                    Eigen::ArrayXXf& grad_y_win,
-                                                                    Eigen::Array3f &covariance) const
+PyramidalKLTTracker<PointInT, IntensityT>::spatialGradient (const FloatImage& img,
+                                                            const FloatImage& grad_x,
+                                                            const FloatImage& grad_y,
+                                                            const Eigen::Array2i& location,
+                                                            const Eigen::Array4f& weight,
+                                                            Eigen::ArrayXXf& win,
+                                                            Eigen::ArrayXXf& grad_x_win,
+                                                            Eigen::ArrayXXf& grad_y_win,
+                                                            Eigen::Array3f &covariance) const
 {
   const int step = img.width;
   covariance.setZero ();
@@ -438,15 +450,15 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::spatialGradient (const
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::mismatchVector (const Eigen::ArrayXXf& prev,
-                                                                   const Eigen::ArrayXXf& prev_grad_x,
-                                                                   const Eigen::ArrayXXf& prev_grad_y,
-                                                                   const FloatImage& next,
-                                                                   const Eigen::Array2i& location,
-                                                                   const Eigen::Array4f& weight,
-                                                                   Eigen::Array2f &b) const
+PyramidalKLTTracker<PointInT, IntensityT>::mismatchVector (const Eigen::ArrayXXf& prev,
+                                                           const Eigen::ArrayXXf& prev_grad_x,
+                                                           const Eigen::ArrayXXf& prev_grad_y,
+                                                           const FloatImage& next,
+                                                           const Eigen::Array2i& location,
+                                                           const Eigen::Array4f& weight,
+                                                           Eigen::Array2f &b) const
 {
   const int step = next.width;
   b.setZero ();
@@ -467,16 +479,16 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::mismatchVector (const
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::track (const PointCloudInConstPtr& prev_input,
-                                                                 const PointCloudInConstPtr& input,
-                                                                 const std::vector<FloatImageConstPtr>& prev_pyramid,
-                                                                 const std::vector<FloatImageConstPtr>& pyramid,
-                                                                 const pcl::PointCloud<pcl::PointUV>::ConstPtr& prev_keypoints,
-                                                                 pcl::PointCloud<pcl::PointUV>::Ptr& keypoints,
-                                                                 std::vector<int>& status,
-                                                                 Eigen::Affine3f& motion) const
+PyramidalKLTTracker<PointInT, IntensityT>::track (const PointCloudInConstPtr& prev_input,
+                                                  const PointCloudInConstPtr& input,
+                                                  const std::vector<FloatImageConstPtr>& prev_pyramid,
+                                                  const std::vector<FloatImageConstPtr>& pyramid,
+                                                  const pcl::PointCloud<pcl::PointUV>::ConstPtr& prev_keypoints,
+                                                  pcl::PointCloud<pcl::PointUV>::Ptr& keypoints,
+                                                  std::vector<int>& status,
+                                                  Eigen::Affine3f& motion) const
 {
   std::vector<Eigen::Array2f, Eigen::aligned_allocator<Eigen::Array2f> > next_pts (prev_keypoints->size ());
   Eigen::Array2f half_win ((track_width_-1)*0.5f, (track_height_-1)*0.5f);
@@ -614,12 +626,13 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::track (const PointClou
       }
     }
   }
+
   motion = transformation_computer.getTransformation ();
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointInT, typename IntensityT> void
-pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::computeTracking ()
+PyramidalKLTTracker<PointInT, IntensityT>::computeTracking ()
 {
   if (!initialized_)
     return;
@@ -637,4 +650,8 @@ pcl::tracking::PyramidalKLTTracker<PointInT, IntensityT>::computeTracking ()
   keypoints_status_->indices = status;
 }
 
+} // namespace tracking
+} // namespace pcl
+
 #endif
+
index 2078d04741d214019bbb00f147459f27691077a2..47930d5221afe5b33fa246a883927c543a92f68f 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef PCL_TRACKING_IMPL_TRACKING_H_
 #define PCL_TRACKING_IMPL_TRACKING_H_
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/common/eigen.h>
 #include <ctime>
index f954f3ec9bc6df72725a04c844670fa5b1cf1675..c84551398a885f38b518d987b9bd35959b2cd465 100644 (file)
@@ -1,15 +1,15 @@
 #pragma once
 
-#include <boost/shared_ptr.hpp>
-
-#include <pcl/tracking/tracking.h>
-#include <pcl/tracking/tracker.h>
-#include <pcl/tracking/coherence.h>
+#include <pcl/memory.h>
 #include <pcl/filters/passthrough.h>
 #include <pcl/octree/octree_pointcloud_changedetector.h>
+#include <pcl/tracking/coherence.h>
+#include <pcl/tracking/tracker.h>
+#include <pcl/tracking/tracking.h>
 
 #include <Eigen/Dense>
 
+
 namespace pcl
 {
   namespace tracking
index 3e379fbb0ea6d51688851bd1e8cd61c426828342..4131ce6dc191b179ed90735110ff20da8b0edd3a 100644 (file)
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/tracking/tracker.h>
index 0308e1611788615b0c48063bc525439f4d00af18..7b3225881b55c7781f492589daa0d03788b66c8d 100644 (file)
@@ -40,6 +40,7 @@
 #pragma once
 
 #include <pcl/tracking/tracking.h>
+#include <pcl/memory.h>
 #include <pcl/pcl_base.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/search/search.h>
@@ -57,11 +58,11 @@ namespace pcl
     {
     protected:
       using PCLBase<PointInT>::deinitCompute;
-      
+
     public:
       using PCLBase<PointInT>::indices_;
       using PCLBase<PointInT>::input_;
-      
+
       using BaseClass = PCLBase<PointInT>;
       using Ptr = shared_ptr< Tracker<PointInT, StateT> >;
       using ConstPtr = shared_ptr< const Tracker<PointInT, StateT> >;
@@ -72,21 +73,21 @@ namespace pcl
       using PointCloudIn = pcl::PointCloud<PointInT>;
       using PointCloudInPtr = typename PointCloudIn::Ptr;
       using PointCloudInConstPtr = typename PointCloudIn::ConstPtr;
-      
+
       using PointCloudState = pcl::PointCloud<StateT>;
       using PointCloudStatePtr = typename PointCloudState::Ptr;
       using PointCloudStateConstPtr = typename PointCloudState::ConstPtr;
-      
+
     public:
       /** \brief Empty constructor. */
       Tracker (): search_ () {}
-      
-      /** \brief Base method for tracking for all points given in 
-        * <setInputCloud (), setIndices ()> using the indices in setIndices () 
+
+      /** \brief Base method for tracking for all points given in
+        * <setInputCloud (), setIndices ()> using the indices in setIndices ()
         */
-      void 
+      void
       compute ();
-      
+
     protected:
       /** \brief The tracker name. */
       std::string tracker_name_;
@@ -95,7 +96,7 @@ namespace pcl
       SearchPtr search_;
 
       /** \brief Get a string representation of the name of this class. */
-      inline const std::string& 
+      inline const std::string&
       getClassName () const { return (tracker_name_); }
 
       /** \brief This method should get called before starting the actual computation. */
@@ -106,25 +107,25 @@ namespace pcl
        * to estimate the features for every point in the input dataset.  This
        * is optional, if this is not set, it will only use the data in the
        * input cloud to estimate the features.  This is useful when you only
-       * need to compute the features for a downsampled cloud.  
+       * need to compute the features for a downsampled cloud.
        * \param search a pointer to a PointCloud message
        */
-      inline void 
+      inline void
       setSearchMethod (const SearchPtr &search) { search_ = search; }
 
       /** \brief Get a pointer to the point cloud dataset. */
-      inline SearchPtr 
+      inline SearchPtr
       getSearchMethod () { return (search_); }
-      
+
       /** \brief Get an instance of the result of tracking. */
-      virtual StateT 
+      virtual StateT
       getResult () const = 0;
-      
+
     private:
       /** \brief Abstract tracking method. */
       virtual void
       computeTracking () = 0;
-      
+
     public:
       PCL_MAKE_ALIGNED_OPERATOR_NEW
     };
index 110e14e686c6912eae6c728705d41a1ad6530c2e..b928606591852fcf35fde333a8872d0b0ba6e0dc 100644 (file)
 
 #include <pcl/point_types.h>
 
-#ifdef BUILD_Maintainer
-#  if defined __GNUC__
-#      pragma GCC system_header 
-#  elif defined _MSC_VER
-#    pragma warning(push, 1)
-#  endif
-#endif
-
 namespace pcl
 {
   namespace tracking
@@ -121,12 +113,6 @@ POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::tracking::_ParticleXYZR,
 )
 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::tracking::ParticleXYZR, pcl::tracking::_ParticleXYZR)
 
-#ifdef BUILD_Maintainer
-#  if defined _MSC_VER
-#    pragma warning(pop)
-#  endif
-#endif
-
 #ifdef PCL_NO_PRECOMPILE
 #include <pcl/tracking/impl/tracking.hpp>
 #endif
index e956bed8ab6c68c9de802abdae8cef5326bb4f16..990a5f5b2bc3de90e4568bd36f4b3cf383efdd86 100644 (file)
@@ -174,4 +174,3 @@ PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/vtk" ${vtk_incs})
 if(BUILD_TESTS)
   add_subdirectory(test)
 endif()
-
index 557eff2f1e5a762219f5d92f2fd4c371cd0ac211..7f7ec38519f50fa4a366cf569409394ae8d7cd93 100644 (file)
@@ -48,7 +48,6 @@
 #include <boost/shared_array.hpp>
 #define BOOST_PARAMETER_MAX_ARITY 7
 #include <boost/signals2.hpp>
-#include <boost/shared_ptr.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
index 260d05ef029a40bbf41122495fb2abba2751eb03..4f3e94d364a11bf416f48146cd9ad9e1bf7c93a3 100644 (file)
@@ -108,7 +108,7 @@ namespace pcl
       PCL_VISUALIZER_IMMEDIATE_RENDERING,
       PCL_VISUALIZER_SHADING,
       PCL_VISUALIZER_LUT,                   /**< colormap type \ref pcl::visualization::LookUpTableRepresentationProperties */
-      PCL_VISUALIZER_LUT_RANGE              /**< two doubles (min and max) or \ref pcl::visualization::LookUpTableRepresentationProperties::PCL_VISUALIZER_LUT_RANGE_AUTO */
+      PCL_VISUALIZER_LUT_RANGE              /**< two doubles (min and max) or ::PCL_VISUALIZER_LUT_RANGE_AUTO */
     };
 
     enum RenderingRepresentationProperties
@@ -142,7 +142,7 @@ namespace pcl
       * \param[in] colormap_type
       * \param[out] table a vtk lookup table
       * \note The list of available colormaps can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
-      */    
+      */
     PCL_EXPORTS bool
     getColormapLUT  (LookUpTableRepresentationProperties colormap_type, vtkSmartPointer<vtkLookupTable> &table);
 
@@ -192,36 +192,36 @@ namespace pcl
         /** \brief Computes View matrix for Camera (Based on gluLookAt)
           * \param[out] view_mat the resultant matrix
           */
-        void 
+        void
         computeViewMatrix (Eigen::Matrix4d& view_mat) const;
 
         /** \brief Computes Projection Matrix for Camera
           *  \param[out] proj the resultant matrix
           */
-        void 
+        void
         computeProjectionMatrix (Eigen::Matrix4d& proj) const;
 
-        /** \brief converts point to window coordiantes
-          * \param[in] pt xyz point to be converted
-          * \param[out] window_cord vector containing the pts' window X,Y, Z and 1
-          *
-          * This function computes the projection and view matrix every time.
-          * It is very inefficient to use this for every point in the point cloud!
-          */
-        template<typename PointT> void 
+        /**
+         * \brief Converts point to window coordinates
+         * \param[in] pt xyz point to be converted
+         * \param[out] window_cord vector containing the pts' window X,Y, Z and 1
+         * \note This function computes the projection and view matrix every time.
+         * It is very inefficient to use this for every point in the point cloud!
+         */
+        template<typename PointT> void
         cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord) const;
 
-        /** \brief converts point to window coordiantes
-          * \param[in] pt xyz point to be converted
-          * \param[out] window_cord vector containing the pts' window X,Y, Z and 1
-          * \param[in] composite_mat composite transformation matrix (proj*view)
-          *
-          * Use this function to compute window coordinates with a precomputed
-          * transformation function.  The typical composite matrix will be
-          * the projection matrix * the view matrix.  However, additional
-          * matrices like a camera disortion matrix can also be added.
-          */
-        template<typename PointT> void 
+        /**
+         * \brief Converts point to window coordinates
+         * \param[in] pt xyz point to be converted
+         * \param[out] window_cord vector containing the pts' window X,Y, Z and 1
+         * \param[in] composite_mat composite transformation matrix (proj*view)
+         *
+         * \note Use this function to compute window coordinates with a pre-computed transformation function.
+         * The typical composite matrix will be the projection matrix * the view matrix. However, additional matrices like
+         * a camera distortion matrix can also be added.
+         */
+        template<typename PointT> void
         cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord, const Eigen::Matrix4d& composite_mat) const;
     };
   }
index de3e20c852986ad3ce923b514a0da9eb08d9bf5b..61f24c9ad77298bd9ac184e4f1d0177471fba33e 100644 (file)
@@ -39,12 +39,6 @@ namespace pcl
 {
   namespace visualization
   {
-    /** \brief Converts point to window coordinates
-     * \param[in] pt xyz point to be converted
-     * \param[out] window_cord vector containing the pts' window X,Y, Z and 1
-     * \note This function computes the projection and view matrix every time.
-     * It is very inefficient to use this for every point in the point cloud!
-     */
     template<typename PointT> void
     Camera::cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord) const
     {
@@ -55,16 +49,6 @@ namespace pcl
       return;
     }
 
-
-    /** \brief converts point to window coordiantes
-     * \param[in] pt xyz point to be converted
-     * \param[out] window_cord vector containing the pts' window X,Y, Z and 1
-     * \param[in] composite_mat composite transformation matrix (proj*view)
-     *
-     * \note Use this function to compute window coordinates with a pre-computed transformation function.
-     * The typical composite matrix will be the projection matrix * the view matrix. However, additional matrices like
-     * a camera distortion matrix can also be added.
-     */
     template<typename PointT> void
     Camera::cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord, const Eigen::Matrix4d& composite_mat) const
     {
index 5579ea55d0fea41930d14a1310958aed5859cfb6..e9acf5db3eed10afda46ad6bacfcbd9dad0f308d 100644 (file)
  */
 
 #pragma once
+
 #include <vtkSmartPointer.h>
 #include <vtkPoints.h>
 #include <vtkPolygon.h>
 #include <vtkUnstructuredGrid.h>
 
-////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace visualization
+{
+
 template <typename PointT> vtkSmartPointer<vtkDataSet> 
-pcl::visualization::createPolygon (const typename pcl::PointCloud<PointT>::ConstPtr &cloud)
+createPolygon (const typename pcl::PointCloud<PointT>::ConstPtr &cloud)
 {
   vtkSmartPointer<vtkUnstructuredGrid> poly_grid;
   if (cloud->points.empty ())
@@ -70,9 +77,9 @@ pcl::visualization::createPolygon (const typename pcl::PointCloud<PointT>::Const
   return (poly_grid);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataSet> 
-pcl::visualization::createPolygon (const pcl::PlanarPolygon<PointT> &planar_polygon)
+createPolygon (const pcl::PlanarPolygon<PointT> &planar_polygon)
 {
   vtkSmartPointer<vtkUnstructuredGrid> poly_grid;
   if (planar_polygon.getContour ().empty ())
@@ -86,19 +93,19 @@ pcl::visualization::createPolygon (const pcl::PlanarPolygon<PointT> &planar_poly
 
   for (std::size_t i = 0; i < planar_polygon.getContour ().size (); ++i)
   {
-    poly_points->SetPoint (i, planar_polygon.getContour ()[i].x, 
-                              planar_polygon.getContour ()[i].y, 
+    poly_points->SetPoint (i, planar_polygon.getContour ()[i].x,
+                              planar_polygon.getContour ()[i].y,
                               planar_polygon.getContour ()[i].z);
     polygon->GetPointIds ()->SetId (i, i);
   }
 
   std::size_t closingContourId = planar_polygon.getContour ().size ();
   auto firstContour = planar_polygon.getContour ()[0];
-  poly_points->SetPoint (closingContourId, firstContour.x, 
-                                           firstContour.y, 
+  poly_points->SetPoint (closingContourId, firstContour.x,
+                                           firstContour.y,
                                            firstContour.z);
   polygon->GetPointIds ()->SetId (closingContourId, closingContourId);
-  
+
   allocVtkUnstructuredGrid (poly_grid);
   poly_grid->Allocate (1, 1);
   poly_grid->InsertNextCell (polygon->GetCellType (), polygon->GetPointIds ());
@@ -107,3 +114,6 @@ pcl::visualization::createPolygon (const pcl::PlanarPolygon<PointT> &planar_poly
   return (poly_grid);
 }
 
+} // namespace visualization
+} // namespace pcl
+
index ff268cbc7adfc1290723e042eef9fb8be86f1fd6..8d01ba028356790651e50f68929779c3436b3899 100644 (file)
@@ -38,6 +38,7 @@
 
 #pragma once
 
+#include <pcl/memory.h>
 #include <pcl/pcl_macros.h>
 #include <pcl/point_types.h>
 #include <pcl/console/print.h>
index df64ae1749c7656966648a2400e3cc6691ed8d97..b03582527619fea94959689996ab05e7875e20cf 100644 (file)
 
 #include <vtkDoubleArray.h>
 
-////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace visualization
+{
+
 template <typename PointT> bool
-pcl::visualization::PCLHistogramVisualizer::addFeatureHistogram (
-    const pcl::PointCloud<PointT> &cloud, int hsize, 
+PCLHistogramVisualizer::addFeatureHistogram (
+    const pcl::PointCloud<PointT> &cloud, int hsize,
     const std::string &id, int win_width, int win_height)
 {
   RenWinInteractMap::iterator am_it = wins_.find (id);
@@ -75,12 +81,12 @@ pcl::visualization::PCLHistogramVisualizer::addFeatureHistogram (
   return (true);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::visualization::PCLHistogramVisualizer::addFeatureHistogram (
-    const pcl::PointCloud<PointT> &cloud, 
+PCLHistogramVisualizer::addFeatureHistogram (
+    const pcl::PointCloud<PointT> &cloud,
     const std::string &field_name,
-    const int index, 
+    const int index,
     const std::string &id, int win_width, int win_height)
 {
   if (index < 0 || index >= cloud.points.size ())
@@ -129,10 +135,10 @@ pcl::visualization::PCLHistogramVisualizer::addFeatureHistogram (
   return (true);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
-    const pcl::PointCloud<PointT> &cloud, int hsize, 
+PCLHistogramVisualizer::updateFeatureHistogram (
+    const pcl::PointCloud<PointT> &cloud, int hsize,
     const std::string &id)
 {
   RenWinInteractMap::iterator am_it = wins_.find (id);
@@ -142,11 +148,11 @@ pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
     return (false);
   }
   RenWinInteract* renwinupd = &wins_[id];
-  
+
   vtkSmartPointer<vtkDoubleArray> xy_array = vtkSmartPointer<vtkDoubleArray>::New ();
   xy_array->SetNumberOfComponents (2);
   xy_array->SetNumberOfTuples (hsize);
-  
+
   // Parse the cloud data and store it in the array
   double xy[2];
   for (int d = 0; d < hsize; ++d)
@@ -159,10 +165,10 @@ pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
   return (true);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> bool
-pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
-    const pcl::PointCloud<PointT> &cloud, const std::string &field_name, const int index, 
+PCLHistogramVisualizer::updateFeatureHistogram (
+    const pcl::PointCloud<PointT> &cloud, const std::string &field_name, const int index,
     const std::string &id)
 {
   if (index < 0 || index >= cloud.points.size ())
@@ -170,7 +176,7 @@ pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
     PCL_ERROR ("[updateFeatureHistogram] Invalid point index (%d) given!\n", index);
     return (false);
   }
-  
+
   // Get the fields present in this cloud
   std::vector<pcl::PCLPointField> fields;
   // Check if our field exists
@@ -188,7 +194,7 @@ pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
     return (false);
   }
   RenWinInteract* renwinupd = &wins_[id];
-    
+
   vtkSmartPointer<vtkDoubleArray> xy_array = vtkSmartPointer<vtkDoubleArray>::New ();
   xy_array->SetNumberOfComponents (2);
   xy_array->SetNumberOfTuples (fields[field_idx].count);
@@ -204,10 +210,13 @@ pcl::visualization::PCLHistogramVisualizer::updateFeatureHistogram (
     xy[1] = data;
     xy_array->SetTuple (d, xy);
   }
-  
+
   reCreateActor (xy_array, renwinupd, cloud.fields[field_idx].count - 1);
   return (true);
 }
 
+} // namespace visualization
+} // namespace pcl
+
 #endif
 
index 1d2d451184f84fe9fff66b6e08892b222a2d4a5e..20ac237e22e149f40e4c50a3dcc4f251c1c82f6f 100644 (file)
 #ifndef PCL_VISUALUALIZATION_PCL_PLOTTER_IMPL_H_
 #define        PCL_VISUALUALIZATION_PCL_PLOTTER_IMPL_H_
 
+
+namespace pcl
+{
+
+namespace visualization
+{
+
 template <typename PointT> bool
-pcl::visualization::PCLPlotter::addFeatureHistogram (
-    const pcl::PointCloud<PointT> &cloud, int hsize, 
+PCLPlotter::addFeatureHistogram (
+    const pcl::PointCloud<PointT> &cloud, int hsize,
     const std::string &id, int win_width, int win_height)
 {
   std::vector<double> array_x(hsize), array_y(hsize);
-  
+
   // Parse the cloud data and store it in the array
   for (int i = 0; i < hsize; ++i)
   {
     array_x[i] = i;
     array_y[i] = cloud.points[0].histogram[i];
   }
-  
+
   this->addPlotData(array_x, array_y, id.c_str(), vtkChart::LINE);
   setWindowSize (win_width, win_height);
   return true;
@@ -59,10 +66,10 @@ pcl::visualization::PCLPlotter::addFeatureHistogram (
 
 
 template <typename PointT> bool
-pcl::visualization::PCLPlotter::addFeatureHistogram (
-    const pcl::PointCloud<PointT> &cloud, 
+PCLPlotter::addFeatureHistogram (
+    const pcl::PointCloud<PointT> &cloud,
     const std::string &field_name,
-    const int index, 
+    const int index,
     const std::string &id, int win_width, int win_height)
 {
   if (index < 0 || index >= cloud.points.size ())
@@ -83,7 +90,7 @@ pcl::visualization::PCLPlotter::addFeatureHistogram (
 
   int hsize = fields[field_idx].count;
   std::vector<double> array_x (hsize), array_y (hsize);
-  
+
   for (int i = 0; i < hsize; ++i)
   {
     array_x[i] = i;
@@ -92,11 +99,14 @@ pcl::visualization::PCLPlotter::addFeatureHistogram (
     memcpy (&data, reinterpret_cast<const char*> (&cloud.points[index]) + fields[field_idx].offset + i * sizeof (float), sizeof (float));
     array_y[i] = data;
   }
-  
+
   this->addPlotData(array_x, array_y, id.c_str(), vtkChart::LINE);
   setWindowSize (win_width, win_height);
   return (true);
 }
 
+} // namespace visualization
+} // namespace pcl
+
 #endif /* PCL_VISUALUALIZATION_PCL_PLOTTER_IMPL_H_ */
 
index b7bfcfc567674f592138bd279ab7a4f30e2cb166..4b4900e38082939e39b3c5389b628a33682e3427 100644 (file)
@@ -264,6 +264,7 @@ pcl::visualization::PCLVisualizer::convertPointCloudToVTKPolyData (
 
       std::copy (&cloud->points[i].x, &cloud->points[i].x + 3, &data[ptr]);
       j++;
+      ptr += 3;
     }
     nr_points = j;
     points->SetNumberOfPoints (nr_points);
@@ -1477,6 +1478,8 @@ pcl::visualization::PCLVisualizer::updatePointCloud (const typename pcl::PointCl
     return (false);
 
   vtkSmartPointer<vtkPolyData> polydata = reinterpret_cast<vtkPolyDataMapper*>(am_it->second.actor->GetMapper ())->GetInput ();
+  if (!polydata)
+      return false;
   // Convert the PointCloud to VTK PolyData
   convertPointCloudToVTKPolyData<PointT> (cloud, polydata, am_it->second.cells);
 
@@ -1584,6 +1587,8 @@ pcl::visualization::PCLVisualizer::updatePointCloud (const typename pcl::PointCl
 
   // Set the cells and the vertices
   vertices->SetCells (nr_points, cells);
+  // Set the cell count explicitly as the array doesn't get modified enough so the above method updates accordingly. See #4001 and #3452
+  vertices->SetNumberOfCells(nr_points);
 
   // Get the colors from the handler
   bool has_colors = false;
index 774ddfda572a99d34d9e658f44a55d109fbabcf2..c900f96752aa7ab9338ffdaa575e5ef93f3e7d36 100644 (file)
  *
  */
 
-#ifndef PCL_POINT_CLOUD_COLOR_HANDLERS_IMPL_HPP_
-#define PCL_POINT_CLOUD_COLOR_HANDLERS_IMPL_HPP_
+#pragma once
 
 #include <set>
 #include <map>
 
 #include <pcl/pcl_macros.h>
 #include <pcl/common/colors.h>
+#include <pcl/common/point_tests.h> // for pcl::isFinite
+
+
+namespace pcl
+{
+
+namespace visualization
+{
 
-///////////////////////////////////////////////////////////////////////////////////////////
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerCustom<PointT>::getColor () const
+PointCloudColorHandlerCustom<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -71,9 +77,9 @@ pcl::visualization::PointCloudColorHandlerCustom<PointT>::getColor () const
   return scalars;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerRandom<PointT>::getColor () const
+PointCloudColorHandlerRandom<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -89,8 +95,8 @@ pcl::visualization::PointCloudColorHandlerRandom<PointT>::getColor () const
   double r, g, b;
   pcl::visualization::getRandomColors (r, g, b);
 
-  int r_ = static_cast<int> (pcl_lrint (r * 255.0)), 
-      g_ = static_cast<int> (pcl_lrint (g * 255.0)), 
+  int r_ = static_cast<int> (pcl_lrint (r * 255.0)),
+      g_ = static_cast<int> (pcl_lrint (g * 255.0)),
       b_ = static_cast<int> (pcl_lrint (b * 255.0));
 
   // Color every point
@@ -104,9 +110,9 @@ pcl::visualization::PointCloudColorHandlerRandom<PointT>::getColor () const
   return scalars;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::visualization::PointCloudColorHandlerRGBField<PointT>::setInputCloud (
+PointCloudColorHandlerRGBField<PointT>::setInputCloud (
     const PointCloudConstPtr &cloud)
 {
   PointCloudColorHandler<PointT>::setInputCloud (cloud);
@@ -127,9 +133,9 @@ pcl::visualization::PointCloudColorHandlerRGBField<PointT>::setInputCloud (
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerRGBField<PointT>::getColor () const
+PointCloudColorHandlerRGBField<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -165,7 +171,7 @@ pcl::visualization::PointCloudColorHandlerRGBField<PointT>::getColor () const
     {
       // Copy the value at the specified field
       if (!std::isfinite (cloud_->points[cp].x) ||
-          !std::isfinite (cloud_->points[cp].y) || 
+          !std::isfinite (cloud_->points[cp].y) ||
           !std::isfinite (cloud_->points[cp].z))
         continue;
 
@@ -191,10 +197,10 @@ pcl::visualization::PointCloudColorHandlerRGBField<PointT>::getColor () const
   return scalars;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT>
-pcl::visualization::PointCloudColorHandlerHSVField<PointT>::PointCloudColorHandlerHSVField (const PointCloudConstPtr &cloud) : 
-  pcl::visualization::PointCloudColorHandler<PointT>::PointCloudColorHandler (cloud)
+PointCloudColorHandlerHSVField<PointT>::PointCloudColorHandlerHSVField (const PointCloudConstPtr &cloud) :
+  PointCloudColorHandler<PointT>::PointCloudColorHandler (cloud)
 {
   // Check for the presence of the "H" field
   field_idx_ = pcl::getFieldIndex<PointT> ("h", fields_);
@@ -222,9 +228,9 @@ pcl::visualization::PointCloudColorHandlerHSVField<PointT>::PointCloudColorHandl
   capable_ = true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerHSVField<PointT>::getColor () const
+PointCloudColorHandlerHSVField<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -359,9 +365,9 @@ pcl::visualization::PointCloudColorHandlerHSVField<PointT>::getColor () const
   return scalars;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::visualization::PointCloudColorHandlerGenericField<PointT>::setInputCloud (
+PointCloudColorHandlerGenericField<PointT>::setInputCloud (
     const PointCloudConstPtr &cloud)
 {
   PointCloudColorHandler<PointT>::setInputCloud (cloud);
@@ -372,9 +378,9 @@ pcl::visualization::PointCloudColorHandlerGenericField<PointT>::setInputCloud (
     capable_ = false;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerGenericField<PointT>::getColor () const
+PointCloudColorHandlerGenericField<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -432,9 +438,9 @@ pcl::visualization::PointCloudColorHandlerGenericField<PointT>::getColor () cons
   return scalars;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::visualization::PointCloudColorHandlerRGBAField<PointT>::setInputCloud (
+PointCloudColorHandlerRGBAField<PointT>::setInputCloud (
     const PointCloudConstPtr &cloud)
 {
   PointCloudColorHandler<PointT>::setInputCloud (cloud);
@@ -446,9 +452,9 @@ pcl::visualization::PointCloudColorHandlerRGBAField<PointT>::setInputCloud (
     capable_ = false;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerRGBAField<PointT>::getColor () const
+PointCloudColorHandlerRGBAField<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -500,9 +506,9 @@ pcl::visualization::PointCloudColorHandlerRGBAField<PointT>::getColor () const
   return scalars;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> void
-pcl::visualization::PointCloudColorHandlerLabelField<PointT>::setInputCloud (const PointCloudConstPtr &cloud)
+PointCloudColorHandlerLabelField<PointT>::setInputCloud (const PointCloudConstPtr &cloud)
 {
   PointCloudColorHandler<PointT>::setInputCloud (cloud);
   field_idx_ = pcl::getFieldIndex<PointT> ("label", fields_);
@@ -513,9 +519,9 @@ pcl::visualization::PointCloudColorHandlerLabelField<PointT>::setInputCloud (con
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT> vtkSmartPointer<vtkDataArray>
-pcl::visualization::PointCloudColorHandlerLabelField<PointT>::getColor () const
+PointCloudColorHandlerLabelField<PointT>::getColor () const
 {
   if (!capable_ || !cloud_)
     return nullptr;
@@ -558,5 +564,6 @@ pcl::visualization::PointCloudColorHandlerLabelField<PointT>::getColor () const
   return scalars;
 }
 
-#endif      // PCL_POINT_CLOUD_COLOR_HANDLERS_IMPL_HPP_
+} // namespace visualization
+} // namespace pcl
 
index 7b84fe5d104de02b708f326d67a538d3bd34adbb..11d44894a6ad893d5e7333b438e8fe08814135cb 100644 (file)
  * $Id: point_cloud_handlers.hpp 7678 2012-10-22 20:54:04Z rusu $
  *
  */
+
 #ifndef PCL_POINT_CLOUD_GEOMETRY_HANDLERS_IMPL_HPP_
 #define PCL_POINT_CLOUD_GEOMETRY_HANDLERS_IMPL_HPP_
 
 #include <pcl/pcl_macros.h>
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
+namespace visualization
+{
+
 template <typename PointT>
-pcl::visualization::PointCloudGeometryHandlerXYZ<PointT>::PointCloudGeometryHandlerXYZ (const PointCloudConstPtr &cloud) 
-  : pcl::visualization::PointCloudGeometryHandler<PointT>::PointCloudGeometryHandler (cloud)
+PointCloudGeometryHandlerXYZ<PointT>::PointCloudGeometryHandlerXYZ (const PointCloudConstPtr &cloud)
+  : PointCloudGeometryHandler<PointT>::PointCloudGeometryHandler (cloud)
 {
   field_x_idx_ = pcl::getFieldIndex<PointT> ("x", fields_);
   if (field_x_idx_ == -1)
@@ -58,9 +65,9 @@ pcl::visualization::PointCloudGeometryHandlerXYZ<PointT>::PointCloudGeometryHand
   capable_ = true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void 
-pcl::visualization::PointCloudGeometryHandlerXYZ<PointT>::getGeometry (vtkSmartPointer<vtkPoints> &points) const
+
+template <typename PointT> void
+PointCloudGeometryHandlerXYZ<PointT>::getGeometry (vtkSmartPointer<vtkPoints> &points) const
 {
   if (!capable_)
     return;
@@ -109,10 +116,10 @@ pcl::visualization::PointCloudGeometryHandlerXYZ<PointT>::getGeometry (vtkSmartP
   }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
+
 template <typename PointT>
-pcl::visualization::PointCloudGeometryHandlerSurfaceNormal<PointT>::PointCloudGeometryHandlerSurfaceNormal (const PointCloudConstPtr &cloud) 
-  : pcl::visualization::PointCloudGeometryHandler<PointT>::PointCloudGeometryHandler (cloud)
+PointCloudGeometryHandlerSurfaceNormal<PointT>::PointCloudGeometryHandlerSurfaceNormal (const PointCloudConstPtr &cloud)
+  : PointCloudGeometryHandler<PointT>::PointCloudGeometryHandler (cloud)
 {
   field_x_idx_ = pcl::getFieldIndex<PointT> ("normal_x", fields_);
   if (field_x_idx_ == -1)
@@ -126,9 +133,9 @@ pcl::visualization::PointCloudGeometryHandlerSurfaceNormal<PointT>::PointCloudGe
   capable_ = true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////
-template <typename PointT> void 
-pcl::visualization::PointCloudGeometryHandlerSurfaceNormal<PointT>::getGeometry (vtkSmartPointer<vtkPoints> &points) const
+
+template <typename PointT> void
+PointCloudGeometryHandlerSurfaceNormal<PointT>::getGeometry (vtkSmartPointer<vtkPoints> &points) const
 {
   if (!capable_)
     return;
@@ -150,6 +157,9 @@ pcl::visualization::PointCloudGeometryHandlerSurfaceNormal<PointT>::getGeometry
   }
 }
 
+} // namespace visualization
+} // namespace pcl
+
 #define PCL_INSTANTIATE_PointCloudGeometryHandlerXYZ(T) template class PCL_EXPORTS pcl::visualization::PointCloudGeometryHandlerXYZ<T>;
 #define PCL_INSTANTIATE_PointCloudGeometryHandlerSurfaceNormal(T) template class PCL_EXPORTS pcl::visualization::PointCloudGeometryHandlerSurfaceNormal<T>;
 
index dab4491b5464db9fd1f10d6ff9babac03983af84..2b076c48a6441cbdf0a4bcead6603a4e83795e97 100644 (file)
  *
  */
 
+#pragma once
+
 #include <thread>
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace pcl
+{
+
 template<typename PointSource, typename PointTarget> void
-pcl::RegistrationVisualizer<PointSource, PointTarget>::startDisplay ()
+RegistrationVisualizer<PointSource, PointTarget>::startDisplay ()
 {
   // Create and start the rendering thread. This will open the display window.
   viewer_thread_ = std::thread (&pcl::RegistrationVisualizer<PointSource, PointTarget>::runDisplay, this);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::RegistrationVisualizer<PointSource, PointTarget>::stopDisplay ()
+RegistrationVisualizer<PointSource, PointTarget>::stopDisplay ()
 {
   // Stop the rendering thread. This will kill the display window.
   viewer_thread_.~thread ();
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::RegistrationVisualizer<PointSource, PointTarget>::runDisplay ()
+RegistrationVisualizer<PointSource, PointTarget>::runDisplay ()
 {
   // Open 3D viewer
   viewer_
@@ -179,9 +184,9 @@ pcl::RegistrationVisualizer<PointSource, PointTarget>::runDisplay ()
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
+
 template<typename PointSource, typename PointTarget> void
-pcl::RegistrationVisualizer<PointSource, PointTarget>::updateIntermediateCloud (
+RegistrationVisualizer<PointSource, PointTarget>::updateIntermediateCloud (
     const pcl::PointCloud<PointSource> &cloud_src,
     const std::vector<int> &indices_src,
     const pcl::PointCloud<PointTarget> &cloud_tgt,
@@ -212,3 +217,6 @@ pcl::RegistrationVisualizer<PointSource, PointTarget>::updateIntermediateCloud (
   // Unlock local buffers
   visualizer_updating_mutex_.unlock ();
 }
+
+} // namespace pcl
+
index a74de876e156b9705a99ef1d10ea69cac2b9dfcf..f4180e941c6a914fd566144bc22824024e5f2ede 100644 (file)
@@ -98,7 +98,7 @@ namespace pcl
         this->transform_->SetMatrix (t->GetMatrix());
       }
       
-      void applyInternals (vtkContext2D *painter)
+      void applyInternals (vtkContext2D *painter) const
       {
         painter->ApplyPen (pen_);
         painter->ApplyBrush (brush_);
@@ -397,7 +397,7 @@ namespace pcl
        * \return[in] array containing the width and height of the window
        */
       int *
-      getWindowSize ();
+      getWindowSize () const;
 
       /** \brief displays all the figures added in a window.
        */    
index 7e0f4c32006b3ba6e7ea26aae0dd3fa18264d0ad..3aeeb58556d0dcbe7f67f74de5f266d9f1467f2e 100644 (file)
@@ -373,7 +373,7 @@ namespace pcl
           * \return[in] array containing the width and height of the window
           */
         int*
-        getWindowSize ();
+        getWindowSize () const;
 
         /** \brief Return a pointer to the underlying VTK RenderWindow used. */
         vtkSmartPointer<vtkRenderWindow>
index 4348c69aecb7f23c2cb3983d5dc3c5914d6e7c30..908b9de98073b02aa9c311233d1915f73325fc89 100644 (file)
@@ -103,7 +103,7 @@ namespace pcl
           */
         PCLVisualizer (const std::string &name = "", const bool create_interactor = true);
 
-        /** \brief PCL Visualizer constructor. It looks through the passed argv arguments to find the "-cam *.cam" argument. 
+        /** \brief PCL Visualizer constructor. It looks through the passed argv arguments to find the "-cam *.cam" argument.
           *        If the search failed, the name for cam file is calculated with boost uuid. If there is no such file, camera is not initilalized.
           * \param[in] argc
           * \param[in] argv
@@ -113,10 +113,10 @@ namespace pcl
           */
         PCLVisualizer (int &argc, char **argv, const std::string &name = "",
             PCLVisualizerInteractorStyle* style = PCLVisualizerInteractorStyle::New (), const bool create_interactor = true);
-            
+
         /** \brief PCL Visualizer constructor.
-          * \param[in] custom vtk renderer
-          * \param[in] custom vtk render window
+          * \param[in] ren custom vtk renderer
+          * \param[in] wind custom vtk render window
           * \param[in] create_interactor if true (default), create an interactor, false otherwise
           */
         PCLVisualizer (vtkSmartPointer<vtkRenderer> ren, vtkSmartPointer<vtkRenderWindow> wind, const std::string &name = "", const bool create_interactor = true);
@@ -124,8 +124,8 @@ namespace pcl
         /** \brief PCL Visualizer constructor.
           * \param[in] argc
           * \param[in] argv
-          * \param[in] custom vtk renderer
-          * \param[in] custom vtk render window
+          * \param[in] ren custom vtk renderer
+          * \param[in] wind custom vtk render window
           * \param[in] style interactor style (defaults to PCLVisualizerInteractorStyle)
           * \param[in] create_interactor if true (default), create an interactor, false otherwise
           */
@@ -286,11 +286,11 @@ namespace pcl
         spinOnce (int time = 1, bool force_redraw = false);
 
         /** \brief Adds a widget which shows an interactive axes display for orientation
-         *  \param[in] interactor - Pointer to the vtk interactor object used by the PCLVisualizer window 
+         *  \param[in] interactor - Pointer to the vtk interactor object used by the PCLVisualizer window
          */
         void
         addOrientationMarkerWidgetAxes (vtkRenderWindowInteractor* interactor);
-        
+
         /** \brief Disables the Orientatation Marker Widget so it is removed from the renderer */
         void
         removeOrientationMarkerWidgetAxes ();
@@ -466,7 +466,7 @@ namespace pcl
         /** \brief Update a text to screen
           * \param[in] text the text to update
           * \param[in] xpos the new X position on screen
-          * \param[in] ypos the new Y position on screen 
+          * \param[in] ypos the new Y position on screen
           * \param[in] id the text object id (default: equal to the "text" parameter)
           */
         bool
@@ -477,21 +477,21 @@ namespace pcl
         /** \brief Update a text to screen
           * \param[in] text the text to update
           * \param[in] xpos the new X position on screen
-          * \param[in] ypos the new Y position on screen 
+          * \param[in] ypos the new Y position on screen
           * \param[in] r the red color value
           * \param[in] g the green color value
           * \param[in] b the blue color value
           * \param[in] id the text object id (default: equal to the "text" parameter)
           */
         bool
-        updateText (const std::string &text, 
+        updateText (const std::string &text,
                     int xpos, int ypos, double r, double g, double b,
                     const std::string &id = "");
 
         /** \brief Update a text to screen
           * \param[in] text the text to update
           * \param[in] xpos the new X position on screen
-          * \param[in] ypos the new Y position on screen 
+          * \param[in] ypos the new Y position on screen
           * \param[in] fontsize the fontsize of the text
           * \param[in] r the red color value
           * \param[in] g the green color value
@@ -499,13 +499,13 @@ namespace pcl
           * \param[in] id the text object id (default: equal to the "text" parameter)
           */
         bool
-        updateText (const std::string &text, 
+        updateText (const std::string &text,
                     int xpos, int ypos, int fontsize, double r, double g, double b,
                     const std::string &id = "");
 
-        /** \brief Set the pose of an existing shape. 
-          * 
-          * Returns false if the shape doesn't exist, true if the pose was successfully 
+        /** \brief Set the pose of an existing shape.
+          *
+          * Returns false if the shape doesn't exist, true if the pose was successfully
           * updated.
           *
           * \param[in] id the shape or cloud object id (i.e., given on \a addLine etc.)
@@ -630,7 +630,7 @@ namespace pcl
             const typename pcl::PointCloud<pcl::PrincipalCurvatures>::ConstPtr &pcs,
             int level = 100, float scale = 1.0f,
             const std::string &id = "cloud", int viewport = 0);
-        
+
         /** \brief Add the estimated principal curvatures of a Point Cloud to screen.
           * \param[in] cloud the input point cloud dataset containing the XYZ data
           * \param[in] normals the input point cloud dataset containing the normal data
@@ -1067,7 +1067,7 @@ namespace pcl
                             int viewport = 0)
         {
           // If Nth not given, display all correspondences
-          return (addCorrespondences<PointT> (source_points, target_points, 
+          return (addCorrespondences<PointT> (source_points, target_points,
                                               correspondences, 1, id, viewport));
         }
 
@@ -1158,7 +1158,7 @@ namespace pcl
         bool
         setPointCloudRenderingProperties (int property, double val1, double val2,
                                           const std::string &id = "cloud", int viewport = 0);
-        
+
        /** \brief Set the rendering properties of a PointCloud
          * \param[in] property the property type
          * \param[in] value the value to be set
@@ -1179,7 +1179,7 @@ namespace pcl
         bool
         getPointCloudRenderingProperties (int property, double &value,
                                           const std::string &id = "cloud");
-        
+
        /** \brief Get the rendering properties of a PointCloud
          * \param[in] property the property type
          * \param[out] val1 the resultant property value
@@ -1193,13 +1193,13 @@ namespace pcl
         getPointCloudRenderingProperties (RenderingProperties property, double &val1, double &val2, double &val3,
                                           const std::string &id = "cloud");
 
-        /** \brief Set whether the point cloud is selected or not 
+        /** \brief Set whether the point cloud is selected or not
          *  \param[in] selected whether the cloud is selected or not (true = selected)
          *  \param[in] id the point cloud object id (default: cloud)
          */
         bool
         setPointCloudSelected (const bool selected, const std::string &id = "cloud" );
-        
+
        /** \brief Set the rendering properties of a shape
          * \param[in] property the property type
          * \param[in] value the value to be set
@@ -1256,8 +1256,8 @@ namespace pcl
           * \param[in] ymax the maximum Y coordinate for the viewport (0.0 <= 1.0)
           * \param[in] viewport the id of the new viewport
           *
-          * \note If no renderer for the current window exists, one will be created, and 
-          * the viewport will be set to 0 ('all'). In case one or multiple renderers do 
+          * \note If no renderer for the current window exists, one will be created, and
+          * the viewport will be set to 0 ('all'). In case one or multiple renderers do
           * exist, the viewport ID will be set to the total number of renderers - 1.
           */
         void
@@ -1780,7 +1780,7 @@ namespace pcl
 
         /** \brief Get camera file for camera parameter saving/restoring.
           * \note This will be valid only when valid "-cam" option were available in command line
-          * or a saved camera file were automatically loaded. 
+          * or a saved camera file were automatically loaded.
           * \sa cameraParamsSet (), cameraFileLoaded ()
           */
         std::string
@@ -1892,21 +1892,21 @@ namespace pcl
         {
           return (win_);
         }
-        
+
         /** \brief Return a pointer to the underlying VTK Renderer Collection. */
         vtkSmartPointer<vtkRendererCollection>
         getRendererCollection ()
         {
           return (rens_);
         }
-        
+
         /** \brief Return a pointer to the CloudActorMap this visualizer uses. */
         CloudActorMapPtr
         getCloudActorMap ()
         {
           return (cloud_actor_map_);
         }
-        
+
         /** \brief Return a pointer to the ShapeActorMap this visualizer uses. */
         ShapeActorMapPtr
         getShapeActorMap ()
@@ -1931,7 +1931,7 @@ namespace pcl
         /** \brief Use Vertex Buffer Objects renderers.
           * This is an optimization for the obsolete OpenGL backend. Modern OpenGL2 backend (VTK â‰¥ 6.3) uses vertex
           * buffer objects by default, transparently for the user.
-          * \param[in] use_vbos set to true to use VBOs 
+          * \param[in] use_vbos set to true to use VBOs
           */
         void
         setUseVbos (bool use_vbos);
@@ -1959,13 +1959,13 @@ namespace pcl
           * attached to a given vtkRenderWindow
           * \param[in,out] iren the vtkRenderWindowInteractor object to set up
           * \param[in,out] win a vtkRenderWindow object that the interactor is attached to
-          * \param[in,out] style a vtkInteractorStyle object 
+          * \param[in,out] style a vtkInteractorStyle object
           */
         void
         setupInteractor (vtkRenderWindowInteractor *iren,
                          vtkRenderWindow *win,
                          vtkInteractorStyle *style);
-        
+
         /** \brief Get a pointer to the current interactor style used. */
         inline vtkSmartPointer<PCLVisualizerInteractorStyle>
         getInteractorStyle ()
@@ -2013,7 +2013,7 @@ namespace pcl
           {
             return (new ExitMainLoopTimerCallback);
           }
-          void 
+          void
           Execute (vtkObject*, unsigned long event_id, void*) override;
 
           int right_timer_id;
@@ -2026,7 +2026,7 @@ namespace pcl
           {
             return (new ExitCallback);
           }
-          void 
+          void
           Execute (vtkObject*, unsigned long event_id, void*) override;
 
           PCLVisualizer* pcl_visualizer;
@@ -2041,7 +2041,7 @@ namespace pcl
           FPSCallback (const FPSCallback& src) : vtkCommand (src), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated), last_fps (src.last_fps) {}
           FPSCallback& operator = (const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; last_fps = src.last_fps; return (*this); }
 
-          void 
+          void
           Execute (vtkObject*, unsigned long event_id, void*) override;
 
           vtkTextActor *actor;
@@ -2083,7 +2083,7 @@ namespace pcl
 
         /** \brief Internal pointer to widget which contains a set of axes */
         vtkSmartPointer<vtkOrientationMarkerWidget> axes_widget_;
-        
+
         /** \brief Boolean that holds whether or not the camera parameters were manually initialized */
         bool camera_set_;
 
@@ -2113,7 +2113,7 @@ namespace pcl
           * \param[in] actor a pointer to the vtk actor object
           * \param[in] viewport port where the actor should be added to (default: 0/all)
           *
-          * \note If viewport is set to 0, the actor will be added to all existing 
+          * \note If viewport is set to 0, the actor will be added to all existing
           * renders. To select a specific viewport use an integer between 1 and N.
           */
         void
@@ -2136,7 +2136,7 @@ namespace pcl
         void
         createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
                                    vtkSmartPointer<vtkActor> &actor,
-                                   bool use_scalars = true);
+                                   bool use_scalars = true) const;
 
         /** \brief Internal method. Creates a vtk actor from a vtk polydata object.
           * \param[in] data the vtk polydata object to create an actor for
@@ -2146,7 +2146,7 @@ namespace pcl
         void
         createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
                                    vtkSmartPointer<vtkLODActor> &actor,
-                                   bool use_scalars = true);
+                                   bool use_scalars = true) const;
 
         /** \brief Converts a PCL templated PointCloud object to a vtk polydata object.
           * \param[in] cloud the input PCL PointCloud dataset
@@ -2298,7 +2298,7 @@ namespace pcl
           * \param[in] tex_mat texture material in PCL format
           * \param[out] vtk_tex texture material in VTK format
           * \return 0 on success and -1 else.
-          * \note for now only image based textures are supported, image file must be in 
+          * \note for now only image based textures are supported, image file must be in
           * tex_file attribute of \a tex_mat.
           */
         int
@@ -2311,7 +2311,7 @@ namespace pcl
           */
         std::string
         getUniqueCameraFile (int argc, char **argv);
-        
+
         //There's no reason these conversion functions shouldn't be public and static so others can use them.
       public:
         /** \brief Convert Eigen::Matrix4f to vtkMatrix4x4
@@ -2331,7 +2331,7 @@ namespace pcl
         convertToVtkMatrix (const Eigen::Vector4f &origin,
                             const Eigen::Quaternion<float> &orientation,
                             vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
-        
+
         /** \brief Convert vtkMatrix4x4 to an Eigen4f
           * \param[in] vtk_matrix the original VTK 4x4 matrix
           * \param[out] m the resultant Eigen 4x4 matrix
index 243109098cc8a5863c5be282809ae122838f1b9a..62bb8ce1514dcc3e9c729810b4dc26e265940c02 100644 (file)
@@ -114,7 +114,7 @@ namespace pcl
           * This virtual method should not be overriden or used. The default implementation
           * is provided only for backwards compatibility with handlers that were written
           * before PCL 1.10.0 and will be removed in future. */
-        PCL_DEPRECATED("use getColor() without parameters instead")
+        PCL_DEPRECATED(1, 12, "use getColor() without parameters instead")
         virtual bool
         getColor (vtkSmartPointer<vtkDataArray> &scalars) const {
           scalars = getColor ();
@@ -616,7 +616,7 @@ namespace pcl
           * This virtual method should not be overriden or used. The default implementation
           * is provided only for backwards compatibility with handlers that were written
           * before PCL 1.10.0 and will be removed in future. */
-        PCL_DEPRECATED("use getColor() without parameters instead")
+        PCL_DEPRECATED(1, 12, "use getColor() without parameters instead")
         virtual bool
         getColor (vtkSmartPointer<vtkDataArray> &scalars) const {
           scalars = getColor ();
index 5720a5ad9f5567c6aadadb4073b2bb8a32d13bb9..38eee9e29fdfc6e32ae4ccd468ec766ae84e5847 100644 (file)
@@ -71,7 +71,7 @@ namespace pcl
         performSinglePick (vtkRenderWindowInteractor *iren, float &x, float &y, float &z);
 
         int
-        performAreaPick (vtkRenderWindowInteractor *iren, std::vector<int> &indices);
+        performAreaPick (vtkRenderWindowInteractor *iren, std::vector<int> &indices) const;
 
       private:
         float x_, y_, z_;
index af6d24ca930436ebeb162c7567005f148dfcb25e..270abc84844d6cd139d3768329bf689ae92105c5 100644 (file)
@@ -42,6 +42,7 @@ class vtkUnsignedCharArray;
 class vtkOpenGLExtensionManager;
 class vtkRenderWindow;
 
+PCL_DEPRECATED(1, 13, "The OpenGL backend of VTK is deprecated. Please switch to the OpenGL2 backend.")
 class PCL_EXPORTS vtkVertexBufferObject : public vtkObject
 {
 public:
index 3bc4f9f128503ee576cf653afe5576ad11ff6ad1..bfe8efffb3eaabca4af18639a0a9b5ee1beeb988 100644 (file)
@@ -22,6 +22,7 @@
 #pragma once
 
 #include <pcl/pcl_exports.h>
+#include <pcl/pcl_macros.h>
 
 #include "vtkMapper.h"
 #include "vtkSmartPointer.h"
@@ -34,6 +35,7 @@ class vtkShader2;
 class vtkShaderProgram2;
 class vtkVertexBufferObject;
 
+PCL_DEPRECATED(1, 13, "The OpenGL backend of VTK is deprecated. Please switch to the OpenGL2 backend.")
 class PCL_EXPORTS vtkVertexBufferObjectMapper : public vtkMapper
 {
 public:
index 919bdc673f69ffdb4b8fa45e03fe8bedae65c051..b0b32a1af2d504c5d66802b091ed87fab16fe507 100644 (file)
@@ -38,7 +38,7 @@
 #include <pcl/visualization/cloud_viewer.h>
 #include <pcl/visualization/pcl_visualizer.h>
 #include <pcl/visualization/boost.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 #include <mutex>
 #include <thread>
index b489f66396017c14ab6fa3a5c487b99445b9465d..08170e707604f7b054a397c4516bb65feb21cfdd 100644 (file)
@@ -45,7 +45,7 @@
 #include <pcl/kdtree/kdtree_flann.h>
 #include <pcl/io/pcd_io.h>
 #include <pcl/visualization/eigen.h>
-#include <pcl/make_shared.h>
+#include <pcl/memory.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 void
index 9384cd26e631e6827c8493172601b41bd00660bc..44fff8d87ee9ca6878fcf1ae89c8f6bb61604293 100644 (file)
@@ -349,7 +349,7 @@ pcl::visualization::PCLPainter2D::setWindowSize (int w, int h)
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 int*
-pcl::visualization::PCLPainter2D::getWindowSize ()
+pcl::visualization::PCLPainter2D::getWindowSize () const
 {
   int *sz = new int[2];
   sz[0] = win_width_;
index 3acd233253095bbe12e628df5f8ce4043f01cab8..81b97d752a5961829055d7e481336bf578fbba84 100644 (file)
@@ -542,7 +542,7 @@ pcl::visualization::PCLPlotter::setWindowSize (int w, int h)
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 int*
-pcl::visualization::PCLPlotter::getWindowSize ()
+pcl::visualization::PCLPlotter::getWindowSize () const
 {
   int *sz = new int[2];
   sz[0] = win_width_;
index e1966ae45f591fbad39f74cc5908b702c0d067e9..bb41994946f617ddb41631efd887790a9e8ffb67 100644 (file)
@@ -1107,7 +1107,7 @@ getDefaultScalarInterpolationForDataSet (vtkDataSet* data)
 void
 pcl::visualization::PCLVisualizer::createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
                                                               vtkSmartPointer<vtkLODActor> &actor,
-                                                              bool use_scalars)
+                                                              bool use_scalars) const
 {
   // If actor is not initialized, initialize it here
   if (!actor)
@@ -1185,7 +1185,7 @@ pcl::visualization::PCLVisualizer::createActorFromVTKDataSet (const vtkSmartPoin
 void
 pcl::visualization::PCLVisualizer::createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
                                                               vtkSmartPointer<vtkActor> &actor,
-                                                              bool use_scalars)
+                                                              bool use_scalars) const
 {
   // If actor is not initialized, initialize it here
   if (!actor)
@@ -1926,10 +1926,10 @@ pcl::visualization::PCLVisualizer::getCameraFile () const
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
+PCL_DEPRECATED(1, 12, "This method can safely not be called anymore as we're just re-rendering all scenes now.")
 void
 pcl::visualization::PCLVisualizer::updateCamera ()
 {
-  PCL_WARN ("[pcl::visualization::PCLVisualizer::updateCamera()] This method was deprecated, just re-rendering all scenes now.");
   rens_->InitTraversal ();
   // Update the camera parameters
   win_->Render ();
index 2c8c485cca4645322d605d1998c5941c49800da3..c12ecd415aabd1991034a550f0fc799e736b549c 100644 (file)
@@ -686,12 +686,17 @@ pcl::visualization::PointCloudGeometryHandler<pcl::PCLPointCloud2>::getGeometry
 
   vtkSmartPointer<vtkFloatArray> data = vtkSmartPointer<vtkFloatArray>::New ();
   data->SetNumberOfComponents (3);
+  
   vtkIdType nr_points = cloud_->width * cloud_->height;
+  
+  if (!data->Resize(nr_points))
+  {
+    PCL_ERROR("[point_cloud_handlers::getGeometry] Failed to allocate space for points in VTK array.");
+    throw std::bad_alloc();
+  }
+    
 
   // Add all points
-  float dim;
-  vtkIdType j = 0;    // true point index
-  float* pts = static_cast<float*> (malloc (nr_points * 3 * sizeof (float)));
   int point_offset = 0;
 
   // If the dataset has no invalid values, just copy all of them
@@ -699,43 +704,36 @@ pcl::visualization::PointCloudGeometryHandler<pcl::PCLPointCloud2>::getGeometry
   {
     for (vtkIdType i = 0; i < nr_points; ++i, point_offset+=cloud_->point_step)
     {
-      // Copy the value at the specified field
-      memcpy (&dim, &cloud_->data[point_offset + cloud_->fields[field_x_idx_].offset], sizeof (float));
-      pts[i * 3 + 0] = dim;
+      const float* ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_x_idx_].offset]);
+      data->InsertNextValue(*ptr);
 
-      memcpy (&dim, &cloud_->data[point_offset + cloud_->fields[field_y_idx_].offset], sizeof (float));
-      pts[i * 3 + 1] = dim;
+      ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_y_idx_].offset]);
+      data->InsertNextValue(*ptr);
 
-      memcpy (&dim, &cloud_->data[point_offset + cloud_->fields[field_z_idx_].offset], sizeof (float));
-      pts[i * 3 + 2] = dim;
+      ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_z_idx_].offset]);
+      data->InsertNextValue(*ptr);
     }
-    data->SetArray (&pts[0], nr_points * 3, 0);
     points->SetData (data);
   }
   else
   {
     for (vtkIdType i = 0; i < nr_points; ++i, point_offset+=cloud_->point_step)
     {
-      // Copy the value at the specified field
-      memcpy (&dim, &cloud_->data[point_offset + cloud_->fields[field_x_idx_].offset], sizeof (float));
-      if (!std::isfinite (dim))
+      const float* ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_x_idx_].offset]);
+      if (!std::isfinite (*ptr))
         continue;
-      pts[j * 3 + 0] = dim;
+      data->InsertNextValue(*ptr);
 
-      memcpy (&dim, &cloud_->data[point_offset + cloud_->fields[field_y_idx_].offset], sizeof (float));
-      if (!std::isfinite (dim))
+      ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_y_idx_].offset]);
+      if (!std::isfinite (*ptr))
         continue;
-      pts[j * 3 + 1] = dim;
+      data->InsertNextValue(*ptr);
 
-      memcpy (&dim, &cloud_->data[point_offset + cloud_->fields[field_z_idx_].offset], sizeof (float));
-      if (!std::isfinite (dim))
+      ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_z_idx_].offset]);
+      if (!std::isfinite (*ptr))
         continue;
-      pts[j * 3 + 2] = dim;
-
-      // Set j and increment
-      j++;
+      data->InsertNextValue(*ptr);
     }
-    data->SetArray (&pts[0], j * 3, 0);
     points->SetData (data);
   }
 }
index 1b5aad906fc1d56c0e77004d57d879df1f96134a..e9348cc6277a120da3577c8b0ba6714cbbcd81a1 100644 (file)
@@ -167,7 +167,7 @@ pcl::visualization::PointPickingCallback::performSinglePick (
 /////////////////////////////////////////////////////////////////////////////////////////////
 int
 pcl::visualization::PointPickingCallback::performAreaPick (vtkRenderWindowInteractor *iren,
-                                                           std::vector<int> &indices)
+                                                           std::vector<int> &indices) const
 {
   vtkAreaPicker *picker = static_cast<vtkAreaPicker*> (iren->GetPicker ());
   vtkRenderer *ren = iren->FindPokedRenderer (iren->GetEventPosition ()[0], iren->GetEventPosition ()[1]);